@oomol-lab/open-flow 0.1.0-beta.16 → 0.1.0-beta.18
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/browser/{createResourceDialog-DRUIXBbz.js → createResourceDialog-DlrAMxmo.js} +2 -2
- package/dist/browser/flow-authoring.js +1464 -1463
- package/dist/browser/flow-change.js +1 -0
- package/dist/browser/{flowChanges-iuoam3Bx.js → flowChanges-DR6bsnz-.js} +1745 -1484
- package/dist/browser/{flowWorkspace-B0UAQ-s7.js → flowWorkspace-fsNhVe8S.js} +32429 -29399
- package/dist/browser/{i18n-JtW9O5x3.js → i18n-9ypjMjOo.js} +167 -27
- package/dist/browser/{inputValues-DICmJoN-.js → inputValues-MIPdGucY.js} +2 -2
- package/dist/browser/licenses.md +48 -0
- package/dist/browser/{markdownContent-tWc7bRAs.js → markdownContent-BBgH9ZIV.js} +13 -13
- package/dist/browser/theme.css +9 -9
- package/dist/browser/ui.css +1 -1
- package/dist/browser/ui.d.ts +9 -0
- package/dist/browser/ui.js +1219 -1022
- package/dist/browser/{useValueChanged-DSookOEC.js → useValueChanged-BY05Usw-.js} +3 -3
- package/dist/browser/workbench.css +1 -1
- package/dist/browser/workbench.js +931 -629
- package/dist/browser/{workbenchSelect-DgxXqCAa.js → workbenchSelect-CwP6rphY.js} +4 -3
- package/dist/common/control-api-conformance.js +389 -394
- package/dist/common/control-api-errors.d.ts +5 -0
- package/dist/common/control-api.d.ts +1 -6
- package/dist/common/control-api.js +1019 -1003
- package/dist/common/control-requests.js +1 -0
- package/dist/common/engine-contract.d.ts +2 -0
- package/dist/common/flow-encoding.js +1 -0
- package/dist/common/flow-semantics.js +2802 -2767
- package/dist/common/integration-trigger.d.ts +23 -1
- package/dist/common/integration-trigger.js +188 -52
- package/dist/common/mcp.js +409 -391
- package/dist/common/provider-triggers.js +890 -842
- package/dist/common/runtime-contract.d.ts +2 -1
- package/dist/common/runtime-contract.js +99 -28
- package/dist/common/scheduler.js +1255 -1254
- package/package.json +1 -1
|
@@ -99,13 +99,13 @@ var o = "LIST_RECORDS_ITERATOR_NOT_AVAILABLE", s = {
|
|
|
99
99
|
};
|
|
100
100
|
let n = l(e.checkpoint), r = await f(e, t, n), i = [], a = 0;
|
|
101
101
|
for (let e of r.records) {
|
|
102
|
-
let n =
|
|
102
|
+
let n = m(e.fields?.[t.triggerField]);
|
|
103
103
|
n == null ? a += 1 : i.push({
|
|
104
104
|
record: e,
|
|
105
105
|
value: n
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
-
let o = i.flatMap(({ record: e, value: r }) => r == n.cursor && n.boundaryIds.includes(e.id) ? [] : [
|
|
108
|
+
let o = i.flatMap(({ record: e, value: r }) => r == n.cursor && n.boundaryIds.includes(e.id) ? [] : [ie(t, e, r)]), s = p(n, r, i);
|
|
109
109
|
return {
|
|
110
110
|
checkpoint: s.checkpoint,
|
|
111
111
|
events: o,
|
|
@@ -126,7 +126,7 @@ function c(e) {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
function l(t) {
|
|
129
|
-
let n =
|
|
129
|
+
let n = h(t), r = m(n?.cursor), i = n?.boundaryIds;
|
|
130
130
|
if (r == null || !Array.isArray(i) || i.some((e) => typeof e != "string")) throw new e("Airtable checkpoint is invalid; recreate the Trigger.");
|
|
131
131
|
let a = u(n?.pending);
|
|
132
132
|
return {
|
|
@@ -138,7 +138,7 @@ function l(t) {
|
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
140
|
function u(e) {
|
|
141
|
-
let t =
|
|
141
|
+
let t = h(e), n = m(t?.cursor), r = t?.boundaryIds;
|
|
142
142
|
return n == null || !Array.isArray(r) || r.some((e) => typeof e != "string") ? null : {
|
|
143
143
|
boundaryIds: r,
|
|
144
144
|
cursor: n,
|
|
@@ -146,16 +146,16 @@ function u(e) {
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
async function d(t, n) {
|
|
149
|
-
let r = await
|
|
150
|
-
|
|
151
|
-
let i =
|
|
149
|
+
let r = await le(t, n, ae(n));
|
|
150
|
+
ue(r, "seed list");
|
|
151
|
+
let i = de(r.data);
|
|
152
152
|
if (i.records.length == 0) return {
|
|
153
153
|
boundaryIds: [],
|
|
154
154
|
cursor: t.now.toISOString()
|
|
155
155
|
};
|
|
156
|
-
let a =
|
|
156
|
+
let a = m(i.records[0]?.fields?.[n.triggerField]);
|
|
157
157
|
if (a == null) throw new e("The Airtable trigger field is not a time field.");
|
|
158
|
-
let o = i.records.filter((e) =>
|
|
158
|
+
let o = i.records.filter((e) => m(e.fields?.[n.triggerField]) === a).map(({ id: e }) => e);
|
|
159
159
|
return o.length == i.records.length && i.offset ? {
|
|
160
160
|
boundaryIds: [],
|
|
161
161
|
cursor: a,
|
|
@@ -168,13 +168,13 @@ async function d(t, n) {
|
|
|
168
168
|
async function f(e, t, n) {
|
|
169
169
|
let r = [], i = n.offset, a = Math.min(Math.ceil(t.maxRecordsPerPoll / 100), 10);
|
|
170
170
|
for (let s = 0; s < a; s += 1) {
|
|
171
|
-
let a = await
|
|
172
|
-
if (i != null && a.status == 422 &&
|
|
171
|
+
let a = await le(e, t, oe(t, n, i));
|
|
172
|
+
if (i != null && a.status == 422 && fe(a.data) == o) return {
|
|
173
173
|
offsetWentStale: !0,
|
|
174
174
|
records: r
|
|
175
175
|
};
|
|
176
|
-
|
|
177
|
-
let s =
|
|
176
|
+
ue(a, "record list");
|
|
177
|
+
let s = de(a.data);
|
|
178
178
|
if (r.push(...s.records), !s.offset) return {
|
|
179
179
|
offsetWentStale: !1,
|
|
180
180
|
records: r
|
|
@@ -197,9 +197,9 @@ function p(e, t, n) {
|
|
|
197
197
|
checkpoint: r,
|
|
198
198
|
hasMore: !1
|
|
199
199
|
};
|
|
200
|
-
let i =
|
|
200
|
+
let i = te(e.pending, ee(n));
|
|
201
201
|
return t.offset == null ? {
|
|
202
|
-
checkpoint: i == null ? r :
|
|
202
|
+
checkpoint: i == null ? r : ne(r, i),
|
|
203
203
|
hasMore: !1
|
|
204
204
|
} : {
|
|
205
205
|
checkpoint: {
|
|
@@ -210,22 +210,22 @@ function p(e, t, n) {
|
|
|
210
210
|
hasMore: !0
|
|
211
211
|
};
|
|
212
212
|
}
|
|
213
|
-
function
|
|
213
|
+
function ee(e) {
|
|
214
214
|
if (e.length == 0) return;
|
|
215
215
|
let t = e.reduce((e, t) => t.value > e ? t.value : e, e[0].value);
|
|
216
|
-
return
|
|
216
|
+
return re(t, e.filter(({ value: e }) => e == t).map(({ record: e }) => e.id));
|
|
217
217
|
}
|
|
218
|
-
function
|
|
219
|
-
return e == null ? t : t == null ? e :
|
|
218
|
+
function te(e, t) {
|
|
219
|
+
return e == null ? t : t == null ? e : ne(e, t);
|
|
220
220
|
}
|
|
221
|
-
function
|
|
221
|
+
function ne(e, t) {
|
|
222
222
|
return t.cursor > e.cursor ? t : e.cursor > t.cursor ? e : e.cursorExclusive === !0 || t.cursorExclusive === !0 ? {
|
|
223
223
|
boundaryIds: [],
|
|
224
224
|
cursor: e.cursor,
|
|
225
225
|
cursorExclusive: !0
|
|
226
|
-
} :
|
|
226
|
+
} : re(e.cursor, [.../* @__PURE__ */ new Set([...e.boundaryIds, ...t.boundaryIds])]);
|
|
227
227
|
}
|
|
228
|
-
function
|
|
228
|
+
function re(e, t) {
|
|
229
229
|
return t.length > 200 ? {
|
|
230
230
|
boundaryIds: [],
|
|
231
231
|
cursor: e,
|
|
@@ -235,7 +235,7 @@ function te(e, t) {
|
|
|
235
235
|
cursor: e
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function ie(e, t, n) {
|
|
239
239
|
return {
|
|
240
240
|
dedupeKey: `${t.id}:${n}`,
|
|
241
241
|
payload: {
|
|
@@ -249,10 +249,10 @@ function ne(e, t, n) {
|
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
|
-
function
|
|
252
|
+
function ae(e) {
|
|
253
253
|
return {
|
|
254
254
|
fields: [e.triggerField],
|
|
255
|
-
filterByFormula:
|
|
255
|
+
filterByFormula: ce([se(e.triggerField), ...e.formula.length == 0 ? [] : [e.formula]]),
|
|
256
256
|
pageSize: 100,
|
|
257
257
|
sort: [{
|
|
258
258
|
direction: "desc",
|
|
@@ -261,11 +261,11 @@ function re(e) {
|
|
|
261
261
|
...e.view.length == 0 ? {} : { view: e.view }
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
|
-
function
|
|
264
|
+
function oe(e, t, n) {
|
|
265
265
|
let r = `DATETIME_PARSE("${t.cursor}", "YYYY-MM-DDTHH:mm:ss.SSSZ")`, i = t.cursorExclusive === !0 ? `IS_AFTER({${e.triggerField}}, ${r})` : `NOT(IS_BEFORE({${e.triggerField}}, ${r}))`, a = e.fields.includes(e.triggerField) ? e.fields : [...e.fields, e.triggerField];
|
|
266
266
|
return {
|
|
267
|
-
filterByFormula:
|
|
268
|
-
|
|
267
|
+
filterByFormula: ce([
|
|
268
|
+
se(e.triggerField),
|
|
269
269
|
i,
|
|
270
270
|
...e.formula.length == 0 ? [] : [e.formula]
|
|
271
271
|
]),
|
|
@@ -279,13 +279,13 @@ function ie(e, t, n) {
|
|
|
279
279
|
...n == null ? {} : { offset: n }
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
|
-
function
|
|
282
|
+
function se(e) {
|
|
283
283
|
return `NOT({${e}} = BLANK())`;
|
|
284
284
|
}
|
|
285
|
-
function
|
|
285
|
+
function ce(e) {
|
|
286
286
|
return `AND(${e.join(", ")})`;
|
|
287
287
|
}
|
|
288
|
-
async function
|
|
288
|
+
async function le(e, t, r) {
|
|
289
289
|
let i = `/${t.baseId}/${encodeURIComponent(t.tableIdOrName)}/listRecords`;
|
|
290
290
|
try {
|
|
291
291
|
return await e.connector.execute({
|
|
@@ -297,71 +297,71 @@ async function se(e, t, r) {
|
|
|
297
297
|
throw new n(`Airtable proxy request to ${i} failed.`, { cause: e });
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
|
-
function
|
|
301
|
-
if (!(r.status >= 200 && r.status < 300)) throw r.status == 401 || r.status == 403 ? new t(`Airtable ${i} rejected the Connection.`) : r.status == 404 ? new e("The Airtable base or table was not found.") : r.status == 422 &&
|
|
300
|
+
function ue(r, i) {
|
|
301
|
+
if (!(r.status >= 200 && r.status < 300)) throw r.status == 401 || r.status == 403 ? new t(`Airtable ${i} rejected the Connection.`) : r.status == 404 ? new e("The Airtable base or table was not found.") : r.status == 422 && fe(r.data) !== o ? new e("Airtable rejected the trigger field, formula, or view.") : new n(`Airtable ${i} failed with status ${r.status}.`);
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
let t =
|
|
303
|
+
function de(e) {
|
|
304
|
+
let t = h(e);
|
|
305
305
|
return {
|
|
306
306
|
records: Array.isArray(t?.records) ? t.records : [],
|
|
307
307
|
...typeof t?.offset == "string" ? { offset: t.offset } : {}
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
|
-
function
|
|
311
|
-
let t =
|
|
310
|
+
function fe(e) {
|
|
311
|
+
let t = h(e)?.error;
|
|
312
312
|
if (typeof t == "string") return t;
|
|
313
|
-
let n =
|
|
313
|
+
let n = h(t)?.type;
|
|
314
314
|
return typeof n == "string" ? n : "";
|
|
315
315
|
}
|
|
316
|
-
function
|
|
316
|
+
function m(e) {
|
|
317
317
|
if (typeof e != "string" || e.length == 0) return null;
|
|
318
318
|
let t = new Date(e);
|
|
319
319
|
return Number.isNaN(t.getTime()) ? null : t.toISOString();
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function h(e) {
|
|
322
322
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
323
323
|
}
|
|
324
324
|
//#endregion
|
|
325
325
|
//#region src/trigger/providers/signature.ts
|
|
326
|
-
var
|
|
327
|
-
function
|
|
328
|
-
return
|
|
326
|
+
var g = new TextEncoder();
|
|
327
|
+
function pe(e) {
|
|
328
|
+
return g.encode(e);
|
|
329
329
|
}
|
|
330
|
-
function
|
|
331
|
-
return e != null &&
|
|
330
|
+
function me(e, t) {
|
|
331
|
+
return e != null && be(g.encode(e), g.encode(t));
|
|
332
332
|
}
|
|
333
|
-
async function
|
|
334
|
-
let r = n == null ? void 0 :
|
|
335
|
-
return r != null &&
|
|
333
|
+
async function he(e, t, n) {
|
|
334
|
+
let r = n == null ? void 0 : ve(n);
|
|
335
|
+
return r != null && be(r, await _e(e, t));
|
|
336
336
|
}
|
|
337
|
-
async function
|
|
338
|
-
let r = n == null ? void 0 :
|
|
339
|
-
return r != null &&
|
|
337
|
+
async function ge(e, t, n) {
|
|
338
|
+
let r = n == null ? void 0 : ye(n);
|
|
339
|
+
return r != null && be(r, await _e(e, t));
|
|
340
340
|
}
|
|
341
|
-
async function
|
|
342
|
-
let n = await crypto.subtle.importKey("raw",
|
|
341
|
+
async function _e(e, t) {
|
|
342
|
+
let n = await crypto.subtle.importKey("raw", g.encode(e), {
|
|
343
343
|
hash: "SHA-256",
|
|
344
344
|
name: "HMAC"
|
|
345
345
|
}, !1, ["sign"]), r = t.reduce((e, t) => e + t.byteLength, 0), i = new Uint8Array(r), a = 0;
|
|
346
346
|
for (let e of t) i.set(e, a), a += e.byteLength;
|
|
347
347
|
return new Uint8Array(await crypto.subtle.sign("HMAC", n, i));
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function ve(e) {
|
|
350
350
|
try {
|
|
351
351
|
return Uint8Array.from(atob(e), (e) => e.charCodeAt(0));
|
|
352
352
|
} catch {
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
-
function
|
|
356
|
+
function ye(e) {
|
|
357
357
|
if (!(e.length == 0 || e.length % 2 != 0 || !/^[0-9a-f]+$/i.test(e))) return Uint8Array.from({ length: e.length / 2 }, (t, n) => Number.parseInt(e.slice(n * 2, n * 2 + 2), 16));
|
|
358
358
|
}
|
|
359
|
-
function
|
|
359
|
+
function be(e, t) {
|
|
360
360
|
let n = e.byteLength ^ t.byteLength, r = Math.max(e.byteLength, t.byteLength);
|
|
361
361
|
for (let i = 0; i < r; i += 1) n |= (e[i] ?? 0) ^ (t[i] ?? 0);
|
|
362
362
|
return n == 0;
|
|
363
363
|
}
|
|
364
|
-
var
|
|
364
|
+
var xe = {
|
|
365
365
|
initialState: {
|
|
366
366
|
checkpoint: null,
|
|
367
367
|
subscription: {}
|
|
@@ -434,7 +434,7 @@ var ye = {
|
|
|
434
434
|
},
|
|
435
435
|
async receive(e) {
|
|
436
436
|
let t = e.header("x-hub-signature-256");
|
|
437
|
-
if (!t?.startsWith("sha256=") || !await
|
|
437
|
+
if (!t?.startsWith("sha256=") || !await ge(e.callbackSecret, [e.rawBody], t.slice(7))) return {
|
|
438
438
|
body: "",
|
|
439
439
|
contentType: "text/plain",
|
|
440
440
|
outcome: "respond",
|
|
@@ -449,7 +449,7 @@ var ye = {
|
|
|
449
449
|
outcome: "ignored",
|
|
450
450
|
reason: "GitHub ping handshake."
|
|
451
451
|
};
|
|
452
|
-
let r =
|
|
452
|
+
let r = Se(e.config);
|
|
453
453
|
if (!r.events.includes("*") && !r.events.includes(n)) return {
|
|
454
454
|
outcome: "ignored",
|
|
455
455
|
reason: "GitHub event is not subscribed."
|
|
@@ -466,38 +466,38 @@ var ye = {
|
|
|
466
466
|
};
|
|
467
467
|
},
|
|
468
468
|
async reconcile(e) {
|
|
469
|
-
let t =
|
|
469
|
+
let t = Ee(e.state), n = Se(e.config), r = De(t);
|
|
470
470
|
if (!e.active) {
|
|
471
|
-
if (r ??= await
|
|
472
|
-
let t = await
|
|
473
|
-
endpoint: `${
|
|
471
|
+
if (r ??= await we(e, n), r != null) {
|
|
472
|
+
let t = await v(e, "hook delete", {
|
|
473
|
+
endpoint: `${_(n)}/${r}`,
|
|
474
474
|
method: "DELETE"
|
|
475
475
|
});
|
|
476
|
-
t.status != 404 &&
|
|
476
|
+
t.status != 404 && y(t, "hook delete");
|
|
477
477
|
}
|
|
478
|
-
return await t.saveSubscription({},
|
|
478
|
+
return await t.saveSubscription({}, Oe(e.now)), { outcome: "ready" };
|
|
479
479
|
}
|
|
480
|
-
let o =
|
|
480
|
+
let o = Ce(e.endpointUrl, e.callbackSecret, n);
|
|
481
481
|
if (r == null) {
|
|
482
|
-
let t = await
|
|
482
|
+
let t = await v(e, "hook create", {
|
|
483
483
|
body: o,
|
|
484
|
-
endpoint:
|
|
484
|
+
endpoint: _(n),
|
|
485
485
|
method: "POST"
|
|
486
486
|
});
|
|
487
|
-
if (t.status == 201) r =
|
|
487
|
+
if (t.status == 201) r = Te(t.data);
|
|
488
488
|
else if (t.status == 422) {
|
|
489
|
-
if (r = await
|
|
490
|
-
} else throw
|
|
489
|
+
if (r = await we(e, n), r == null) throw new i("GitHub rejected the webhook configuration.");
|
|
490
|
+
} else throw y(t, "hook create"), new a(`GitHub hook create returned unexpected status ${t.status}.`);
|
|
491
491
|
}
|
|
492
|
-
let s = await
|
|
492
|
+
let s = await v(e, "hook update", {
|
|
493
493
|
body: o,
|
|
494
|
-
endpoint: `${
|
|
494
|
+
endpoint: `${_(n)}/${r}`,
|
|
495
495
|
method: "PATCH"
|
|
496
496
|
});
|
|
497
|
-
return s.status == 404 ? (await t.saveSubscription({}, e.now), { outcome: "pending" }) : (
|
|
497
|
+
return s.status == 404 ? (await t.saveSubscription({}, e.now), { outcome: "pending" }) : (y(s, "hook update"), await t.saveSubscription({ hookId: r }, Oe(e.now)), { outcome: "ready" });
|
|
498
498
|
}
|
|
499
499
|
};
|
|
500
|
-
function
|
|
500
|
+
function Se(e) {
|
|
501
501
|
return {
|
|
502
502
|
events: [...new Set(e.events)],
|
|
503
503
|
insecureSsl: e.insecureSsl ?? !1,
|
|
@@ -505,10 +505,10 @@ function be(e) {
|
|
|
505
505
|
repo: e.repo
|
|
506
506
|
};
|
|
507
507
|
}
|
|
508
|
-
function
|
|
508
|
+
function _(e) {
|
|
509
509
|
return `/repos/${encodeURIComponent(e.owner)}/${encodeURIComponent(e.repo)}/hooks`;
|
|
510
510
|
}
|
|
511
|
-
function
|
|
511
|
+
function Ce(e, t, n) {
|
|
512
512
|
return {
|
|
513
513
|
active: !0,
|
|
514
514
|
config: {
|
|
@@ -521,10 +521,10 @@ function Se(e, t, n) {
|
|
|
521
521
|
name: "web"
|
|
522
522
|
};
|
|
523
523
|
}
|
|
524
|
-
async function
|
|
524
|
+
async function we(e, t) {
|
|
525
525
|
for (let n = 1; n <= 10; n += 1) {
|
|
526
|
-
let r = await
|
|
527
|
-
endpoint:
|
|
526
|
+
let r = await v(e, "hook list", {
|
|
527
|
+
endpoint: _(t),
|
|
528
528
|
method: "GET",
|
|
529
529
|
query: {
|
|
530
530
|
page: n,
|
|
@@ -532,50 +532,50 @@ async function Ce(e, t) {
|
|
|
532
532
|
}
|
|
533
533
|
});
|
|
534
534
|
if (r.status == 404) return null;
|
|
535
|
-
|
|
535
|
+
y(r, "hook list");
|
|
536
536
|
let i = Array.isArray(r.data) ? r.data : [];
|
|
537
537
|
for (let t of i) {
|
|
538
|
-
let n =
|
|
539
|
-
if (
|
|
538
|
+
let n = ke(t);
|
|
539
|
+
if (ke(n?.config)?.url === e.endpointUrl && (typeof n?.id == "number" || typeof n?.id == "string")) return String(n.id);
|
|
540
540
|
}
|
|
541
541
|
if (i.length < 100) return null;
|
|
542
542
|
}
|
|
543
543
|
return null;
|
|
544
544
|
}
|
|
545
|
-
async function
|
|
545
|
+
async function v(e, t, n) {
|
|
546
546
|
try {
|
|
547
547
|
return await e.connector.execute(n, e.signal);
|
|
548
548
|
} catch (e) {
|
|
549
549
|
throw e instanceof r ? e : new a(`GitHub ${t} request failed.`, { cause: e });
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
function
|
|
552
|
+
function y(e, t) {
|
|
553
553
|
if (e.status >= 200 && e.status < 300) return;
|
|
554
|
-
let n =
|
|
554
|
+
let n = ke(e.data)?.message;
|
|
555
555
|
throw e.status == 403 && typeof n == "string" && /rate limit/i.test(n) ? new a(`GitHub ${t} was rate limited.`) : [401, 403].includes(e.status) ? new r(`GitHub ${t} rejected the Connection.`) : [404, 422].includes(e.status) ? new i(`GitHub ${t} rejected the subscription.`) : new a(`GitHub ${t} failed with status ${e.status}.`);
|
|
556
556
|
}
|
|
557
|
-
function
|
|
558
|
-
let t =
|
|
557
|
+
function Te(e) {
|
|
558
|
+
let t = ke(e)?.id;
|
|
559
559
|
if (typeof t != "number" && typeof t != "string") throw new a("GitHub hook response is missing its ID.");
|
|
560
560
|
return String(t);
|
|
561
561
|
}
|
|
562
|
-
function
|
|
562
|
+
function Ee(e) {
|
|
563
563
|
if (e == null) throw new i("GitHub Integration state is missing.");
|
|
564
564
|
return e;
|
|
565
565
|
}
|
|
566
|
-
function
|
|
566
|
+
function De(e) {
|
|
567
567
|
let t = e.subscription.hookId;
|
|
568
568
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
569
569
|
}
|
|
570
|
-
function
|
|
570
|
+
function Oe(e) {
|
|
571
571
|
return new Date(e.getTime() + 2592e6);
|
|
572
572
|
}
|
|
573
|
-
function
|
|
573
|
+
function ke(e) {
|
|
574
574
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
575
575
|
}
|
|
576
576
|
//#endregion
|
|
577
577
|
//#region src/trigger/providers/gitlab/on-project-event.ts
|
|
578
|
-
var
|
|
578
|
+
var Ae = [
|
|
579
579
|
"push",
|
|
580
580
|
"tag_push",
|
|
581
581
|
"issues",
|
|
@@ -593,7 +593,7 @@ var ke = [
|
|
|
593
593
|
"emoji",
|
|
594
594
|
"resource_access_token",
|
|
595
595
|
"resource_deploy_token"
|
|
596
|
-
],
|
|
596
|
+
], je = /* @__PURE__ */ new Map([
|
|
597
597
|
["Push Hook", "push"],
|
|
598
598
|
["Tag Push Hook", "tag_push"],
|
|
599
599
|
["Issue Hook", "issues"],
|
|
@@ -611,7 +611,7 @@ var ke = [
|
|
|
611
611
|
["Emoji Hook", "emoji"],
|
|
612
612
|
["Resource Access Token Hook", "resource_access_token"],
|
|
613
613
|
["Resource Deploy Token Hook", "resource_deploy_token"]
|
|
614
|
-
]),
|
|
614
|
+
]), Me = {
|
|
615
615
|
initialState: {
|
|
616
616
|
checkpoint: null,
|
|
617
617
|
subscription: {}
|
|
@@ -622,7 +622,7 @@ var ke = [
|
|
|
622
622
|
properties: {
|
|
623
623
|
events: {
|
|
624
624
|
items: {
|
|
625
|
-
enum:
|
|
625
|
+
enum: Ae,
|
|
626
626
|
type: "string"
|
|
627
627
|
},
|
|
628
628
|
minItems: 1,
|
|
@@ -684,7 +684,7 @@ var ke = [
|
|
|
684
684
|
type: "integration"
|
|
685
685
|
},
|
|
686
686
|
receive(e) {
|
|
687
|
-
if (!
|
|
687
|
+
if (!me(e.header("x-gitlab-token"), e.callbackSecret)) return {
|
|
688
688
|
body: "",
|
|
689
689
|
contentType: "text/plain",
|
|
690
690
|
outcome: "respond",
|
|
@@ -695,12 +695,12 @@ var ke = [
|
|
|
695
695
|
outcome: "ignored",
|
|
696
696
|
reason: "GitLab event header is missing."
|
|
697
697
|
};
|
|
698
|
-
let n =
|
|
698
|
+
let n = je.get(t);
|
|
699
699
|
if (n == null) return {
|
|
700
700
|
outcome: "ignored",
|
|
701
701
|
reason: "GitLab event header is unknown."
|
|
702
702
|
};
|
|
703
|
-
if (!
|
|
703
|
+
if (!Ne(e.config).events.includes(n)) return {
|
|
704
704
|
outcome: "ignored",
|
|
705
705
|
reason: "GitLab event is not subscribed."
|
|
706
706
|
};
|
|
@@ -717,36 +717,36 @@ var ke = [
|
|
|
717
717
|
};
|
|
718
718
|
},
|
|
719
719
|
async reconcile(e) {
|
|
720
|
-
let t =
|
|
720
|
+
let t = Re(e.state), n = Ne(e.config), r = ze(t);
|
|
721
721
|
if (!e.active) {
|
|
722
|
-
let i = r == null ? await
|
|
723
|
-
for (let t of i ?? []) await
|
|
724
|
-
return await t.saveSubscription({},
|
|
722
|
+
let i = r == null ? await Fe(e, n) : [r];
|
|
723
|
+
for (let t of i ?? []) await Ie(e, n, t);
|
|
724
|
+
return await t.saveSubscription({}, Be(e.now)), { outcome: "ready" };
|
|
725
725
|
}
|
|
726
|
-
let a = await
|
|
726
|
+
let a = await Fe(e, n);
|
|
727
727
|
if (a == null) throw new i("The GitLab project does not exist or is not visible.");
|
|
728
728
|
let o = r ?? a[0];
|
|
729
729
|
if (o == null) {
|
|
730
|
-
let t = await
|
|
731
|
-
body:
|
|
732
|
-
endpoint:
|
|
730
|
+
let t = await x(e, "hook create", {
|
|
731
|
+
body: Pe(e.endpointUrl, e.callbackSecret, n),
|
|
732
|
+
endpoint: b(n),
|
|
733
733
|
method: "POST"
|
|
734
734
|
});
|
|
735
|
-
|
|
735
|
+
S(t, "hook create"), o = Le(t.data);
|
|
736
736
|
} else {
|
|
737
|
-
let r = await
|
|
738
|
-
body:
|
|
739
|
-
endpoint: `${
|
|
737
|
+
let r = await x(e, "hook update", {
|
|
738
|
+
body: Pe(e.endpointUrl, e.callbackSecret, n),
|
|
739
|
+
endpoint: `${b(n)}/${o}`,
|
|
740
740
|
method: "PUT"
|
|
741
741
|
});
|
|
742
742
|
if (r.status == 404) return await t.saveSubscription({}, e.now), { outcome: "pending" };
|
|
743
|
-
|
|
743
|
+
S(r, "hook update");
|
|
744
744
|
}
|
|
745
|
-
for (let t of a.filter((e) => e != o)) await
|
|
746
|
-
return await t.saveSubscription({ hookId: o },
|
|
745
|
+
for (let t of a.filter((e) => e != o)) await Ie(e, n, t);
|
|
746
|
+
return await t.saveSubscription({ hookId: o }, Be(e.now)), { outcome: "ready" };
|
|
747
747
|
}
|
|
748
748
|
};
|
|
749
|
-
function
|
|
749
|
+
function Ne(e) {
|
|
750
750
|
return {
|
|
751
751
|
events: e.events,
|
|
752
752
|
insecureSsl: e.insecureSsl ?? !1,
|
|
@@ -754,10 +754,10 @@ function Me(e) {
|
|
|
754
754
|
pushBranchFilter: e.pushBranchFilter ?? ""
|
|
755
755
|
};
|
|
756
756
|
}
|
|
757
|
-
function
|
|
757
|
+
function b(e) {
|
|
758
758
|
return `/projects/${encodeURIComponent(e.project)}/hooks`;
|
|
759
759
|
}
|
|
760
|
-
function
|
|
760
|
+
function Pe(e, t, n) {
|
|
761
761
|
return {
|
|
762
762
|
branch_filter_strategy: "wildcard",
|
|
763
763
|
description: "Managed by Open Flow.",
|
|
@@ -766,14 +766,14 @@ function Ne(e, t, n) {
|
|
|
766
766
|
push_events_branch_filter: n.pushBranchFilter,
|
|
767
767
|
url: e,
|
|
768
768
|
token: t,
|
|
769
|
-
...Object.fromEntries(
|
|
769
|
+
...Object.fromEntries(Ae.map((e) => [`${e}_events`, n.events.includes(e)]))
|
|
770
770
|
};
|
|
771
771
|
}
|
|
772
|
-
async function
|
|
772
|
+
async function Fe(e, t) {
|
|
773
773
|
let n = [];
|
|
774
774
|
for (let r = 1; r <= 10; r += 1) {
|
|
775
|
-
let i = await
|
|
776
|
-
endpoint:
|
|
775
|
+
let i = await x(e, "hook list", {
|
|
776
|
+
endpoint: b(t),
|
|
777
777
|
method: "GET",
|
|
778
778
|
query: {
|
|
779
779
|
page: r,
|
|
@@ -781,59 +781,59 @@ async function Pe(e, t) {
|
|
|
781
781
|
}
|
|
782
782
|
});
|
|
783
783
|
if (i.status == 404) return null;
|
|
784
|
-
|
|
784
|
+
S(i, "hook list");
|
|
785
785
|
let a = Array.isArray(i.data) ? i.data : [];
|
|
786
786
|
for (let t of a) {
|
|
787
|
-
let r =
|
|
787
|
+
let r = Ve(t);
|
|
788
788
|
r?.url === e.endpointUrl && (typeof r.id == "number" || typeof r.id == "string") && n.push(String(r.id));
|
|
789
789
|
}
|
|
790
790
|
if (a.length < 100) break;
|
|
791
791
|
}
|
|
792
792
|
return n;
|
|
793
793
|
}
|
|
794
|
-
async function
|
|
795
|
-
let r = await
|
|
796
|
-
endpoint: `${
|
|
794
|
+
async function Ie(e, t, n) {
|
|
795
|
+
let r = await x(e, "hook delete", {
|
|
796
|
+
endpoint: `${b(t)}/${n}`,
|
|
797
797
|
method: "DELETE"
|
|
798
798
|
});
|
|
799
|
-
r.status != 404 &&
|
|
799
|
+
r.status != 404 && S(r, "hook delete");
|
|
800
800
|
}
|
|
801
|
-
async function
|
|
801
|
+
async function x(e, t, n) {
|
|
802
802
|
try {
|
|
803
803
|
return await e.connector.execute(n, e.signal);
|
|
804
804
|
} catch (e) {
|
|
805
805
|
throw e instanceof r ? e : new a(`GitLab ${t} request failed.`, { cause: e });
|
|
806
806
|
}
|
|
807
807
|
}
|
|
808
|
-
function
|
|
808
|
+
function S(e, t) {
|
|
809
809
|
if (!(e.status >= 200 && e.status < 300)) throw e.status == 401 || e.status == 403 ? new r(`GitLab ${t} rejected the Connection.`) : [
|
|
810
810
|
400,
|
|
811
811
|
404,
|
|
812
812
|
422
|
|
813
813
|
].includes(e.status) ? new i(`GitLab ${t} rejected the subscription.`) : new a(`GitLab ${t} failed with status ${e.status}.`);
|
|
814
814
|
}
|
|
815
|
-
function
|
|
816
|
-
let t =
|
|
815
|
+
function Le(e) {
|
|
816
|
+
let t = Ve(e)?.id;
|
|
817
817
|
if (typeof t != "number" && typeof t != "string") throw new a("GitLab hook response is missing its ID.");
|
|
818
818
|
return String(t);
|
|
819
819
|
}
|
|
820
|
-
function
|
|
820
|
+
function Re(e) {
|
|
821
821
|
if (e == null) throw new i("GitLab Integration state is missing.");
|
|
822
822
|
return e;
|
|
823
823
|
}
|
|
824
|
-
function
|
|
824
|
+
function ze(e) {
|
|
825
825
|
let t = e.subscription.hookId;
|
|
826
826
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
827
827
|
}
|
|
828
|
-
function
|
|
828
|
+
function Be(e) {
|
|
829
829
|
return new Date(e.getTime() + 2592e6);
|
|
830
830
|
}
|
|
831
|
-
function
|
|
831
|
+
function Ve(e) {
|
|
832
832
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
833
833
|
}
|
|
834
834
|
//#endregion
|
|
835
835
|
//#region src/trigger/providers/gmail/on-message-received.ts
|
|
836
|
-
var
|
|
836
|
+
var He = 25, Ue = 5, We = {
|
|
837
837
|
snapshot: {
|
|
838
838
|
configSchema: {
|
|
839
839
|
additionalProperties: !1,
|
|
@@ -858,7 +858,7 @@ var Ve = 25, He = 5, Ue = {
|
|
|
858
858
|
type: "array"
|
|
859
859
|
},
|
|
860
860
|
maxMessagesPerPoll: {
|
|
861
|
-
default:
|
|
861
|
+
default: He,
|
|
862
862
|
maximum: 100,
|
|
863
863
|
minimum: 1,
|
|
864
864
|
type: "integer"
|
|
@@ -929,20 +929,20 @@ var Ve = 25, He = 5, Ue = {
|
|
|
929
929
|
type: "poll"
|
|
930
930
|
},
|
|
931
931
|
async poll(e) {
|
|
932
|
-
let t =
|
|
932
|
+
let t = Ge(e.config);
|
|
933
933
|
if (e.checkpoint === null) return {
|
|
934
|
-
checkpoint: { historyId: await
|
|
934
|
+
checkpoint: { historyId: await Ke(e) },
|
|
935
935
|
events: []
|
|
936
936
|
};
|
|
937
|
-
let n =
|
|
937
|
+
let n = qe(e.checkpoint), r = await Je(e, t.labelNamesOrIds), { candidates: i, lastPage: a } = await Ye(e, n, r, t.maxMessagesPerPoll), o = Xe(n.historyId, a), s = [], c = 0;
|
|
938
938
|
for (let n of i) {
|
|
939
|
-
let i = await
|
|
939
|
+
let i = await Ze(e, n.id);
|
|
940
940
|
if (i != null) {
|
|
941
|
-
if (!await
|
|
941
|
+
if (!await Qe(e, i, t, r)) {
|
|
942
942
|
c += 1;
|
|
943
943
|
continue;
|
|
944
944
|
}
|
|
945
|
-
s.push(
|
|
945
|
+
s.push(tt(i));
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
948
|
return {
|
|
@@ -953,39 +953,39 @@ var Ve = 25, He = 5, Ue = {
|
|
|
953
953
|
};
|
|
954
954
|
}
|
|
955
955
|
};
|
|
956
|
-
function
|
|
956
|
+
function Ge(e) {
|
|
957
957
|
return {
|
|
958
958
|
includeDrafts: e.includeDrafts ?? !1,
|
|
959
959
|
includeSpamAndTrash: e.includeSpamAndTrash ?? !1,
|
|
960
960
|
labelNamesOrIds: e.labelNamesOrIds ?? [],
|
|
961
|
-
maxMessagesPerPoll: e.maxMessagesPerPoll ??
|
|
961
|
+
maxMessagesPerPoll: e.maxMessagesPerPoll ?? He,
|
|
962
962
|
readStatus: e.readStatus ?? "All",
|
|
963
963
|
search: (e.search ?? "").trim(),
|
|
964
964
|
sender: (e.sender ?? "").trim()
|
|
965
965
|
};
|
|
966
966
|
}
|
|
967
|
-
async function
|
|
968
|
-
let t = await
|
|
969
|
-
|
|
970
|
-
let r =
|
|
967
|
+
async function Ke(e) {
|
|
968
|
+
let t = await C(e, "/users/me/profile");
|
|
969
|
+
w(t, "profile fetch");
|
|
970
|
+
let r = E(t.data)?.historyId;
|
|
971
971
|
if (typeof r != "string" || r.length == 0) throw new n("Gmail profile historyId is missing.");
|
|
972
972
|
return r;
|
|
973
973
|
}
|
|
974
|
-
function
|
|
975
|
-
let n =
|
|
974
|
+
function qe(t) {
|
|
975
|
+
let n = E(t);
|
|
976
976
|
if (typeof n?.historyId != "string" || n.historyId.length == 0) throw new e("Gmail checkpoint historyId is missing; recreate the Trigger.");
|
|
977
977
|
return {
|
|
978
978
|
historyId: n.historyId,
|
|
979
979
|
...typeof n.pageToken == "string" ? { pageToken: n.pageToken } : {}
|
|
980
980
|
};
|
|
981
981
|
}
|
|
982
|
-
async function
|
|
982
|
+
async function Je(t, n) {
|
|
983
983
|
if (n.length == 0) return [];
|
|
984
|
-
let r = await
|
|
985
|
-
|
|
986
|
-
let i =
|
|
984
|
+
let r = await C(t, "/users/me/labels");
|
|
985
|
+
w(r, "labels list");
|
|
986
|
+
let i = E(r.data)?.labels, a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
|
|
987
987
|
if (Array.isArray(i)) for (let e of i) {
|
|
988
|
-
let t =
|
|
988
|
+
let t = E(e);
|
|
989
989
|
typeof t?.id == "string" && t.id.length != 0 && (a.add(t.id), typeof t.name == "string" && t.name.length > 0 && o.set(t.name.toLowerCase(), t.id));
|
|
990
990
|
}
|
|
991
991
|
return [...new Set(n.map((t) => {
|
|
@@ -994,10 +994,10 @@ async function qe(t, n) {
|
|
|
994
994
|
return n;
|
|
995
995
|
}))];
|
|
996
996
|
}
|
|
997
|
-
async function
|
|
997
|
+
async function Ye(t, n, r, i) {
|
|
998
998
|
let a = /* @__PURE__ */ new Map(), o = n.pageToken, s = {};
|
|
999
|
-
for (let c = 0; c <
|
|
1000
|
-
let c = await
|
|
999
|
+
for (let c = 0; c < Ue; c += 1) {
|
|
1000
|
+
let c = await C(t, "/users/me/history", {
|
|
1001
1001
|
historyTypes: "messageAdded",
|
|
1002
1002
|
labelId: r[0],
|
|
1003
1003
|
maxResults: i,
|
|
@@ -1005,7 +1005,7 @@ async function Je(t, n, r, i) {
|
|
|
1005
1005
|
startHistoryId: n.historyId
|
|
1006
1006
|
});
|
|
1007
1007
|
if (c.status == 404) throw new e("Gmail history checkpoint expired; recreate the Trigger.");
|
|
1008
|
-
|
|
1008
|
+
w(c, "history list"), s = E(c.data) ?? {};
|
|
1009
1009
|
for (let e of s.history ?? []) for (let t of e.messagesAdded ?? []) {
|
|
1010
1010
|
let e = t.message?.id;
|
|
1011
1011
|
e != null && e.length > 0 && !a.has(e) && a.set(e, { id: e });
|
|
@@ -1017,7 +1017,7 @@ async function Je(t, n, r, i) {
|
|
|
1017
1017
|
lastPage: s
|
|
1018
1018
|
};
|
|
1019
1019
|
}
|
|
1020
|
-
function
|
|
1020
|
+
function Xe(e, t) {
|
|
1021
1021
|
if (t.nextPageToken) return {
|
|
1022
1022
|
checkpoint: {
|
|
1023
1023
|
historyId: e,
|
|
@@ -1031,32 +1031,32 @@ function Ye(e, t) {
|
|
|
1031
1031
|
hasMore: !1
|
|
1032
1032
|
};
|
|
1033
1033
|
}
|
|
1034
|
-
async function
|
|
1035
|
-
let n = await
|
|
1036
|
-
return n.status == 404 ? null : (
|
|
1034
|
+
async function Ze(e, t) {
|
|
1035
|
+
let n = await C(e, `/users/me/messages/${encodeURIComponent(t)}`, { format: "metadata" });
|
|
1036
|
+
return n.status == 404 ? null : (w(n, "message metadata fetch"), E(n.data) ?? null);
|
|
1037
1037
|
}
|
|
1038
|
-
async function
|
|
1038
|
+
async function Qe(e, t, n, r) {
|
|
1039
1039
|
let i = t.labelIds ?? [];
|
|
1040
1040
|
if (!n.includeSpamAndTrash && (i.includes("SPAM") || i.includes("TRASH")) || !n.includeDrafts && i.includes("DRAFT") || n.readStatus == "Unread" && !i.includes("UNREAD") || n.readStatus == "Read" && i.includes("UNREAD") || !r.every((e) => i.includes(e))) return !1;
|
|
1041
|
-
let a =
|
|
1042
|
-
return a.length == 0 || await
|
|
1041
|
+
let a = $e(n);
|
|
1042
|
+
return a.length == 0 || await et(e, t, a, n.includeSpamAndTrash);
|
|
1043
1043
|
}
|
|
1044
|
-
function
|
|
1044
|
+
function $e(e) {
|
|
1045
1045
|
let t = e.search.length == 0 ? [] : [e.search], n = e.sender.replaceAll("\"", "").trim();
|
|
1046
1046
|
return n.length > 0 && t.push(`from:${/\s/.test(n) ? `"${n}"` : n}`), t.join(" ");
|
|
1047
1047
|
}
|
|
1048
|
-
async function
|
|
1049
|
-
let i =
|
|
1048
|
+
async function et(e, t, n, r) {
|
|
1049
|
+
let i = T(t.payload?.headers ?? [], "Message-ID").replace(/^</, "").replace(/>$/, "");
|
|
1050
1050
|
if (i.length == 0) return !1;
|
|
1051
|
-
let a = await
|
|
1051
|
+
let a = await C(e, "/users/me/messages", {
|
|
1052
1052
|
includeSpamTrash: r ? "true" : void 0,
|
|
1053
1053
|
q: `${n} rfc822msgid:${i}`
|
|
1054
1054
|
});
|
|
1055
|
-
|
|
1056
|
-
let o =
|
|
1057
|
-
return Array.isArray(o) && o.some((e) =>
|
|
1055
|
+
w(a, "query match");
|
|
1056
|
+
let o = E(a.data)?.messages;
|
|
1057
|
+
return Array.isArray(o) && o.some((e) => E(e)?.id === t.id);
|
|
1058
1058
|
}
|
|
1059
|
-
function
|
|
1059
|
+
function tt(e) {
|
|
1060
1060
|
let t = e.payload?.headers ?? [];
|
|
1061
1061
|
return {
|
|
1062
1062
|
dedupeKey: e.id,
|
|
@@ -1064,15 +1064,15 @@ function et(e) {
|
|
|
1064
1064
|
historyId: e.historyId ?? null,
|
|
1065
1065
|
labelIds: e.labelIds ?? [],
|
|
1066
1066
|
messageId: e.id,
|
|
1067
|
-
messageTimestamp:
|
|
1068
|
-
sender:
|
|
1069
|
-
subject:
|
|
1067
|
+
messageTimestamp: nt(e.internalDate, T(t, "Date")),
|
|
1068
|
+
sender: T(t, "From"),
|
|
1069
|
+
subject: T(t, "Subject"),
|
|
1070
1070
|
threadId: e.threadId ?? "",
|
|
1071
|
-
to:
|
|
1071
|
+
to: T(t, "To")
|
|
1072
1072
|
}
|
|
1073
1073
|
};
|
|
1074
1074
|
}
|
|
1075
|
-
async function
|
|
1075
|
+
async function C(e, t, r = {}) {
|
|
1076
1076
|
try {
|
|
1077
1077
|
return await e.connector.execute({
|
|
1078
1078
|
endpoint: t,
|
|
@@ -1083,13 +1083,13 @@ async function w(e, t, r = {}) {
|
|
|
1083
1083
|
throw new n(`Gmail proxy request to ${t} failed.`, { cause: e });
|
|
1084
1084
|
}
|
|
1085
1085
|
}
|
|
1086
|
-
function
|
|
1086
|
+
function w(e, r) {
|
|
1087
1087
|
if (!(e.status >= 200 && e.status < 300)) throw e.status == 401 || e.status == 403 ? new t(`Gmail ${r} rejected the Connection.`) : new n(`Gmail ${r} failed with status ${e.status}.`);
|
|
1088
1088
|
}
|
|
1089
|
-
function
|
|
1089
|
+
function T(e, t) {
|
|
1090
1090
|
return e.find((e) => e.name.toLowerCase() == t.toLowerCase())?.value ?? "";
|
|
1091
1091
|
}
|
|
1092
|
-
function
|
|
1092
|
+
function nt(e, t) {
|
|
1093
1093
|
let n = e == null ? NaN : Number(e);
|
|
1094
1094
|
if (Number.isFinite(n)) {
|
|
1095
1095
|
let e = new Date(n);
|
|
@@ -1098,21 +1098,21 @@ function tt(e, t) {
|
|
|
1098
1098
|
let r = Date.parse(t);
|
|
1099
1099
|
return Number.isNaN(r) ? "" : new Date(r).toISOString();
|
|
1100
1100
|
}
|
|
1101
|
-
function
|
|
1101
|
+
function E(e) {
|
|
1102
1102
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
1103
1103
|
}
|
|
1104
1104
|
//#endregion
|
|
1105
1105
|
//#region src/trigger/providers/google-calendar/on-event-changed.ts
|
|
1106
|
-
var
|
|
1106
|
+
var D = [
|
|
1107
1107
|
"created",
|
|
1108
1108
|
"updated",
|
|
1109
1109
|
"cancelled"
|
|
1110
|
-
],
|
|
1110
|
+
], rt = /* @__PURE__ */ new Set([
|
|
1111
1111
|
"rateLimitExceeded",
|
|
1112
1112
|
"userRateLimitExceeded",
|
|
1113
1113
|
"quotaExceeded",
|
|
1114
1114
|
"usageLimits"
|
|
1115
|
-
]),
|
|
1115
|
+
]), it = {
|
|
1116
1116
|
snapshot: {
|
|
1117
1117
|
configSchema: {
|
|
1118
1118
|
additionalProperties: !1,
|
|
@@ -1123,9 +1123,9 @@ var O = [
|
|
|
1123
1123
|
type: "string"
|
|
1124
1124
|
},
|
|
1125
1125
|
changes: {
|
|
1126
|
-
default:
|
|
1126
|
+
default: D,
|
|
1127
1127
|
items: {
|
|
1128
|
-
enum:
|
|
1128
|
+
enum: D,
|
|
1129
1129
|
type: "string"
|
|
1130
1130
|
},
|
|
1131
1131
|
minItems: 1,
|
|
@@ -1164,7 +1164,7 @@ var O = [
|
|
|
1164
1164
|
},
|
|
1165
1165
|
calendarId: { type: "string" },
|
|
1166
1166
|
changeType: {
|
|
1167
|
-
enum:
|
|
1167
|
+
enum: D,
|
|
1168
1168
|
type: "string"
|
|
1169
1169
|
},
|
|
1170
1170
|
created: { type: ["string", "null"] },
|
|
@@ -1215,22 +1215,22 @@ var O = [
|
|
|
1215
1215
|
type: "poll"
|
|
1216
1216
|
},
|
|
1217
1217
|
async poll(e) {
|
|
1218
|
-
let t =
|
|
1219
|
-
if (e.checkpoint === null) return
|
|
1220
|
-
let n =
|
|
1221
|
-
return n.calendarId === t.calendarId ? "seedTimeMin" in n ?
|
|
1218
|
+
let t = at(e.config);
|
|
1219
|
+
if (e.checkpoint === null) return st(e, t, e.now.toISOString());
|
|
1220
|
+
let n = ot(e.checkpoint);
|
|
1221
|
+
return n.calendarId === t.calendarId ? "seedTimeMin" in n ? st(e, t, n.seedTimeMin, n.pageToken) : ct(e, t, n) : st(e, t, e.now.toISOString());
|
|
1222
1222
|
}
|
|
1223
1223
|
};
|
|
1224
|
-
function
|
|
1224
|
+
function at(e) {
|
|
1225
1225
|
return {
|
|
1226
1226
|
calendarId: e.calendarId,
|
|
1227
|
-
changes: new Set(e.changes ??
|
|
1227
|
+
changes: new Set(e.changes ?? D),
|
|
1228
1228
|
matchTerm: (e.matchTerm ?? "").trim(),
|
|
1229
1229
|
maxEventsPerPoll: e.maxEventsPerPoll ?? 100
|
|
1230
1230
|
};
|
|
1231
1231
|
}
|
|
1232
|
-
function
|
|
1233
|
-
let n =
|
|
1232
|
+
function ot(t) {
|
|
1233
|
+
let n = O(t), r = typeof n?.pageToken == "string" ? n.pageToken : void 0, i = typeof n?.calendarId == "string" ? n.calendarId : void 0;
|
|
1234
1234
|
if (typeof n?.syncToken == "string" && n.syncToken.length > 0) return {
|
|
1235
1235
|
calendarId: i,
|
|
1236
1236
|
...r == null ? {} : { pageToken: r },
|
|
@@ -1243,25 +1243,25 @@ function at(t) {
|
|
|
1243
1243
|
};
|
|
1244
1244
|
throw new e("Google Calendar checkpoint is invalid; recreate the Trigger.");
|
|
1245
1245
|
}
|
|
1246
|
-
async function
|
|
1246
|
+
async function st(e, t, r, i) {
|
|
1247
1247
|
let a = i;
|
|
1248
1248
|
for (let i = 0; i < 2; i += 1) {
|
|
1249
|
-
let i = await
|
|
1249
|
+
let i = await ft(e, t.calendarId, {
|
|
1250
1250
|
maxResults: 2500,
|
|
1251
1251
|
pageToken: a,
|
|
1252
1252
|
showDeleted: "true",
|
|
1253
1253
|
singleEvents: "false",
|
|
1254
1254
|
timeMin: r
|
|
1255
1255
|
});
|
|
1256
|
-
if (a != null &&
|
|
1256
|
+
if (a != null && mt(i)) return {
|
|
1257
1257
|
checkpoint: {
|
|
1258
1258
|
calendarId: t.calendarId,
|
|
1259
1259
|
seedTimeMin: r
|
|
1260
1260
|
},
|
|
1261
1261
|
events: []
|
|
1262
1262
|
};
|
|
1263
|
-
|
|
1264
|
-
let o =
|
|
1263
|
+
pt(e, i, "seed full sync");
|
|
1264
|
+
let o = O(i.data) ?? {};
|
|
1265
1265
|
if (o.nextSyncToken) return {
|
|
1266
1266
|
checkpoint: {
|
|
1267
1267
|
calendarId: t.calendarId,
|
|
@@ -1282,17 +1282,17 @@ async function ot(e, t, r, i) {
|
|
|
1282
1282
|
hasMore: !0
|
|
1283
1283
|
};
|
|
1284
1284
|
}
|
|
1285
|
-
async function
|
|
1285
|
+
async function ct(e, t, r) {
|
|
1286
1286
|
let i = [], a = 0, o = r.pageToken;
|
|
1287
1287
|
for (let s = 0; s < 5; s += 1) {
|
|
1288
|
-
let s = await
|
|
1288
|
+
let s = await ft(e, t.calendarId, {
|
|
1289
1289
|
maxResults: t.maxEventsPerPoll,
|
|
1290
1290
|
pageToken: o,
|
|
1291
1291
|
showDeleted: "true",
|
|
1292
1292
|
singleEvents: "false",
|
|
1293
1293
|
syncToken: r.syncToken
|
|
1294
1294
|
});
|
|
1295
|
-
if (o != null &&
|
|
1295
|
+
if (o != null && mt(s)) return {
|
|
1296
1296
|
checkpoint: {
|
|
1297
1297
|
calendarId: t.calendarId,
|
|
1298
1298
|
syncToken: r.syncToken
|
|
@@ -1300,16 +1300,16 @@ async function st(e, t, r) {
|
|
|
1300
1300
|
events: i,
|
|
1301
1301
|
filtered: a
|
|
1302
1302
|
};
|
|
1303
|
-
|
|
1304
|
-
let c =
|
|
1303
|
+
pt(e, s, "incremental sync");
|
|
1304
|
+
let c = O(s.data) ?? {};
|
|
1305
1305
|
for (let e of c.items ?? []) {
|
|
1306
1306
|
if (e.id == null || e.id.length == 0) continue;
|
|
1307
|
-
let n =
|
|
1308
|
-
if (!t.changes.has(n) || !
|
|
1307
|
+
let n = lt(e);
|
|
1308
|
+
if (!t.changes.has(n) || !ut(e, t.matchTerm)) {
|
|
1309
1309
|
a += 1;
|
|
1310
1310
|
continue;
|
|
1311
1311
|
}
|
|
1312
|
-
i.push(
|
|
1312
|
+
i.push(dt(e, e.id, n, t.calendarId));
|
|
1313
1313
|
}
|
|
1314
1314
|
if (c.nextSyncToken) return {
|
|
1315
1315
|
checkpoint: {
|
|
@@ -1333,12 +1333,12 @@ async function st(e, t, r) {
|
|
|
1333
1333
|
hasMore: !0
|
|
1334
1334
|
};
|
|
1335
1335
|
}
|
|
1336
|
-
function
|
|
1336
|
+
function lt(e) {
|
|
1337
1337
|
if (e.status == "cancelled") return "cancelled";
|
|
1338
|
-
let t =
|
|
1338
|
+
let t = vt(e.created), n = vt(e.updated);
|
|
1339
1339
|
return t != null && t == n ? "created" : "updated";
|
|
1340
1340
|
}
|
|
1341
|
-
function
|
|
1341
|
+
function ut(e, t) {
|
|
1342
1342
|
if (t.length == 0) return !0;
|
|
1343
1343
|
let n = t.toLowerCase();
|
|
1344
1344
|
return [
|
|
@@ -1348,14 +1348,14 @@ function lt(e, t) {
|
|
|
1348
1348
|
...(e.attendees ?? []).map(({ email: e }) => e)
|
|
1349
1349
|
].some((e) => typeof e == "string" && e.toLowerCase().includes(n));
|
|
1350
1350
|
}
|
|
1351
|
-
function
|
|
1351
|
+
function dt(e, t, n, r) {
|
|
1352
1352
|
return {
|
|
1353
1353
|
dedupeKey: `${t}:${e.updated ?? e.etag ?? ""}`,
|
|
1354
1354
|
payload: {
|
|
1355
1355
|
attendeeEmails: (e.attendees ?? []).flatMap(({ email: e }) => e == null || e.length == 0 ? [] : [e]),
|
|
1356
1356
|
calendarId: r,
|
|
1357
1357
|
changeType: n,
|
|
1358
|
-
created:
|
|
1358
|
+
created: _t(e.created),
|
|
1359
1359
|
creatorEmail: e.creator?.email ?? null,
|
|
1360
1360
|
description: e.description ?? null,
|
|
1361
1361
|
end: e.end ?? null,
|
|
@@ -1369,11 +1369,11 @@ function ut(e, t, n, r) {
|
|
|
1369
1369
|
start: e.start ?? null,
|
|
1370
1370
|
status: e.status ?? "",
|
|
1371
1371
|
summary: e.summary ?? null,
|
|
1372
|
-
updated:
|
|
1372
|
+
updated: _t(e.updated)
|
|
1373
1373
|
}
|
|
1374
1374
|
};
|
|
1375
1375
|
}
|
|
1376
|
-
async function
|
|
1376
|
+
async function ft(e, t, r) {
|
|
1377
1377
|
let i = `/calendars/${encodeURIComponent(t)}/events`;
|
|
1378
1378
|
try {
|
|
1379
1379
|
return await e.connector.execute({
|
|
@@ -1385,176 +1385,158 @@ async function dt(e, t, r) {
|
|
|
1385
1385
|
throw new n(`Google Calendar proxy request to ${i} failed.`, { cause: e });
|
|
1386
1386
|
}
|
|
1387
1387
|
}
|
|
1388
|
-
function
|
|
1389
|
-
if (!(i.status >= 200 && i.status < 300)) throw i.status == 410 || i.status == 400 &&
|
|
1390
|
-
}
|
|
1391
|
-
function pt(e) {
|
|
1392
|
-
return e.status == 400 && !ht(e.data);
|
|
1388
|
+
function pt(r, i, a) {
|
|
1389
|
+
if (!(i.status >= 200 && i.status < 300)) throw i.status == 410 || i.status == 400 && gt(i.data) ? new e("Google Calendar sync token expired; recreate the Trigger.") : i.status == 400 || i.status == 404 && r.checkpoint === null ? new e(`Google Calendar ${a} rejected the configuration.`) : i.status == 401 ? new t(`Google Calendar ${a} rejected the Connection.`) : i.status == 403 ? ht(i.data).some((e) => rt.has(e)) ? new n(`Google Calendar ${a} was rate limited.`) : new t(`Google Calendar ${a} rejected the Connection.`) : new n(`Google Calendar ${a} failed with status ${i.status}.`);
|
|
1393
1390
|
}
|
|
1394
1391
|
function mt(e) {
|
|
1395
|
-
|
|
1392
|
+
return e.status == 400 && !gt(e.data);
|
|
1393
|
+
}
|
|
1394
|
+
function ht(e) {
|
|
1395
|
+
let t = O(O(e)?.error)?.errors;
|
|
1396
1396
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
1397
|
-
let t =
|
|
1397
|
+
let t = O(e)?.reason;
|
|
1398
1398
|
return typeof t == "string" ? [t] : [];
|
|
1399
1399
|
}) : [];
|
|
1400
1400
|
}
|
|
1401
|
-
function
|
|
1402
|
-
if (
|
|
1403
|
-
let t =
|
|
1401
|
+
function gt(e) {
|
|
1402
|
+
if (ht(e).includes("fullSyncRequired")) return !0;
|
|
1403
|
+
let t = O(O(e)?.error)?.message;
|
|
1404
1404
|
return typeof t == "string" && t.includes("fullSyncRequired");
|
|
1405
1405
|
}
|
|
1406
|
-
function
|
|
1406
|
+
function _t(e) {
|
|
1407
1407
|
if (e == null || e.length == 0) return null;
|
|
1408
1408
|
let t = Date.parse(e);
|
|
1409
1409
|
return Number.isNaN(t) ? null : new Date(t).toISOString();
|
|
1410
1410
|
}
|
|
1411
|
-
function
|
|
1411
|
+
function vt(e) {
|
|
1412
1412
|
if (e == null || e.length == 0) return null;
|
|
1413
1413
|
let t = Date.parse(e);
|
|
1414
1414
|
return Number.isNaN(t) ? null : Math.floor(t / 1e3);
|
|
1415
1415
|
}
|
|
1416
|
-
function
|
|
1416
|
+
function O(e) {
|
|
1417
1417
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
1418
1418
|
}
|
|
1419
1419
|
//#endregion
|
|
1420
1420
|
//#region src/trigger/providers/google-drive/changes.ts
|
|
1421
|
-
var
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
driveId: {
|
|
1432
|
-
description: "Optional shared drive ID. Omit it to monitor the connected account.",
|
|
1433
|
-
maxLength: 256,
|
|
1434
|
-
minLength: 1,
|
|
1435
|
-
type: "string"
|
|
1436
|
-
},
|
|
1437
|
-
includeCorpusRemovals: {
|
|
1438
|
-
default: !1,
|
|
1439
|
-
description: "Include the accessible file resource when an item leaves the change corpus.",
|
|
1440
|
-
type: "boolean"
|
|
1441
|
-
},
|
|
1442
|
-
includeItemsFromAllDrives: {
|
|
1443
|
-
default: !0,
|
|
1444
|
-
description: "Include items from My Drive and shared drives.",
|
|
1445
|
-
type: "boolean"
|
|
1446
|
-
},
|
|
1447
|
-
includeRemoved: {
|
|
1448
|
-
default: !0,
|
|
1449
|
-
description: "Include changes caused by deletion or loss of access.",
|
|
1450
|
-
type: "boolean"
|
|
1451
|
-
},
|
|
1452
|
-
pageSize: {
|
|
1453
|
-
default: Ct,
|
|
1454
|
-
description: "Maximum changes included in one Flow Run.",
|
|
1455
|
-
maximum: 100,
|
|
1456
|
-
minimum: 1,
|
|
1457
|
-
type: "integer"
|
|
1458
|
-
},
|
|
1459
|
-
restrictToMyDrive: {
|
|
1460
|
-
default: !1,
|
|
1461
|
-
description: "Restrict changes to the My Drive hierarchy.",
|
|
1462
|
-
type: "boolean"
|
|
1463
|
-
}
|
|
1421
|
+
var yt = 6012e5, bt = 36e5, xt = 6e4, St = 6e4, Ct = 2, wt = 100, Tt = new TextEncoder(), Et = "nextPageToken,newStartPageToken,changes(fileId,kind,changeType,removed,time,driveId,file(id,name,mimeType,webViewLink,createdTime,modifiedTime,size,driveId,parents,shared,starred,trashed))", Dt = {
|
|
1422
|
+
configSchema: {
|
|
1423
|
+
additionalProperties: !1,
|
|
1424
|
+
description: "Configuration for googledrive.changes_detected.",
|
|
1425
|
+
properties: {
|
|
1426
|
+
driveId: {
|
|
1427
|
+
description: "Optional shared drive ID. Omit it to monitor the connected account.",
|
|
1428
|
+
maxLength: 256,
|
|
1429
|
+
minLength: 1,
|
|
1430
|
+
type: "string"
|
|
1464
1431
|
},
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
description: "Uses a Google Drive changes.watch channel and triggers when Drive changes are available.",
|
|
1470
|
-
displayName: "Google Drive: Changes Detected",
|
|
1471
|
-
endpoint: {
|
|
1472
|
-
body: {
|
|
1473
|
-
allowArray: !1,
|
|
1474
|
-
allowEmpty: !0,
|
|
1475
|
-
formats: ["json"]
|
|
1432
|
+
includeCorpusRemovals: {
|
|
1433
|
+
default: !1,
|
|
1434
|
+
description: "Include the accessible file resource when an item leaves the change corpus.",
|
|
1435
|
+
type: "boolean"
|
|
1476
1436
|
},
|
|
1477
|
-
|
|
1478
|
-
|
|
1437
|
+
includeItemsFromAllDrives: {
|
|
1438
|
+
default: !0,
|
|
1439
|
+
description: "Include items from My Drive and shared drives.",
|
|
1440
|
+
type: "boolean"
|
|
1441
|
+
},
|
|
1442
|
+
includeRemoved: {
|
|
1443
|
+
default: !0,
|
|
1444
|
+
description: "Include changes caused by deletion or loss of access.",
|
|
1445
|
+
type: "boolean"
|
|
1446
|
+
},
|
|
1447
|
+
pageSize: {
|
|
1448
|
+
default: wt,
|
|
1449
|
+
description: "Maximum changes included in one Flow Run.",
|
|
1450
|
+
maximum: 100,
|
|
1451
|
+
minimum: 1,
|
|
1452
|
+
type: "integer"
|
|
1453
|
+
},
|
|
1454
|
+
restrictToMyDrive: {
|
|
1455
|
+
default: !1,
|
|
1456
|
+
description: "Restrict changes to the My Drive hierarchy.",
|
|
1457
|
+
type: "boolean"
|
|
1458
|
+
}
|
|
1479
1459
|
},
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1460
|
+
title: "Google Drive Changes Config",
|
|
1461
|
+
type: "object"
|
|
1462
|
+
},
|
|
1463
|
+
definitionVersion: 1,
|
|
1464
|
+
description: "Uses a Google Drive changes.watch channel and triggers when Drive changes are available.",
|
|
1465
|
+
displayName: "Google Drive: Changes Detected",
|
|
1466
|
+
endpoint: {
|
|
1467
|
+
body: {
|
|
1468
|
+
allowArray: !1,
|
|
1469
|
+
allowEmpty: !0,
|
|
1470
|
+
formats: ["json"]
|
|
1471
|
+
},
|
|
1472
|
+
methods: ["POST"],
|
|
1473
|
+
successStatus: 204
|
|
1474
|
+
},
|
|
1475
|
+
key: "googledrive.changes_detected",
|
|
1476
|
+
name: "changes_detected",
|
|
1477
|
+
payloadSchema: {
|
|
1478
|
+
additionalProperties: !1,
|
|
1479
|
+
properties: { events: {
|
|
1480
|
+
items: {
|
|
1481
|
+
additionalProperties: !1,
|
|
1482
|
+
properties: {
|
|
1483
|
+
changeId: { type: "string" },
|
|
1484
|
+
changeType: { type: ["string", "null"] },
|
|
1485
|
+
driveId: { type: ["string", "null"] },
|
|
1486
|
+
file: { type: ["object", "null"] },
|
|
1487
|
+
fileId: { type: ["string", "null"] },
|
|
1488
|
+
notification: {
|
|
1489
|
+
additionalProperties: !1,
|
|
1490
|
+
properties: {
|
|
1491
|
+
changedTypes: {
|
|
1492
|
+
items: { type: "string" },
|
|
1493
|
+
type: "array"
|
|
1503
1494
|
},
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
"messageNumber",
|
|
1508
|
-
"resourceUri"
|
|
1509
|
-
],
|
|
1510
|
-
type: "object"
|
|
1495
|
+
messageNumber: { type: ["string", "null"] },
|
|
1496
|
+
resourceState: { type: "string" },
|
|
1497
|
+
resourceUri: { type: ["string", "null"] }
|
|
1511
1498
|
},
|
|
1512
|
-
|
|
1513
|
-
|
|
1499
|
+
required: [
|
|
1500
|
+
"resourceState",
|
|
1501
|
+
"changedTypes",
|
|
1502
|
+
"messageNumber",
|
|
1503
|
+
"resourceUri"
|
|
1504
|
+
],
|
|
1505
|
+
type: "object"
|
|
1514
1506
|
},
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
"changeType",
|
|
1518
|
-
"removed",
|
|
1519
|
-
"time",
|
|
1520
|
-
"fileId",
|
|
1521
|
-
"driveId",
|
|
1522
|
-
"file",
|
|
1523
|
-
"notification"
|
|
1524
|
-
],
|
|
1525
|
-
type: "object"
|
|
1507
|
+
removed: { type: "boolean" },
|
|
1508
|
+
time: { type: ["string", "null"] }
|
|
1526
1509
|
},
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1510
|
+
required: [
|
|
1511
|
+
"changeId",
|
|
1512
|
+
"changeType",
|
|
1513
|
+
"removed",
|
|
1514
|
+
"time",
|
|
1515
|
+
"fileId",
|
|
1516
|
+
"driveId",
|
|
1517
|
+
"file",
|
|
1518
|
+
"notification"
|
|
1519
|
+
],
|
|
1520
|
+
type: "object"
|
|
1521
|
+
},
|
|
1522
|
+
type: "array"
|
|
1523
|
+
} },
|
|
1524
|
+
required: ["events"],
|
|
1525
|
+
title: "Google Drive Changes Payload",
|
|
1526
|
+
type: "object"
|
|
1535
1527
|
},
|
|
1528
|
+
provider: "googledrive",
|
|
1529
|
+
type: "integration"
|
|
1530
|
+
}, Ot = {
|
|
1531
|
+
initialState: {
|
|
1532
|
+
checkpoint: null,
|
|
1533
|
+
subscription: { channels: [] }
|
|
1534
|
+
},
|
|
1535
|
+
snapshot: Dt,
|
|
1536
1536
|
async receive(e) {
|
|
1537
|
-
let t =
|
|
1538
|
-
if (
|
|
1539
|
-
|
|
1540
|
-
contentType: "text/plain",
|
|
1541
|
-
outcome: "respond",
|
|
1542
|
-
status: 404
|
|
1543
|
-
};
|
|
1544
|
-
let s = kt(t), c = s.find((t) => t.id == n && Date.parse(t.expiration) > e.now.getTime());
|
|
1545
|
-
if (c == null || !Ht(o, await Vt(e.callbackSecret, n)) || c.resourceId != null && c.resourceId != r) return {
|
|
1546
|
-
body: "",
|
|
1547
|
-
contentType: "text/plain",
|
|
1548
|
-
outcome: "respond",
|
|
1549
|
-
status: 404
|
|
1550
|
-
};
|
|
1551
|
-
if (c.resourceId ?? (s = s.map((e) => e.id == n ? {
|
|
1552
|
-
...e,
|
|
1553
|
-
resourceId: r
|
|
1554
|
-
} : e), await j(t, s, e.now)), i != "sync" && i != "change") return {
|
|
1555
|
-
outcome: "ignored",
|
|
1556
|
-
reason: "Google Drive notification state is not actionable."
|
|
1557
|
-
};
|
|
1537
|
+
let t = await Kt(e);
|
|
1538
|
+
if (t.outcome != "wake") return t;
|
|
1539
|
+
let n = k(e.state), r = e.header("x-goog-resource-state");
|
|
1558
1540
|
if (!e.admit) return e.current ? {
|
|
1559
1541
|
body: "",
|
|
1560
1542
|
contentType: "text/plain",
|
|
@@ -1568,75 +1550,73 @@ var vt = 6012e5, yt = 36e5, bt = 6e4, xt = 6e4, St = 2, Ct = 100, wt = new TextE
|
|
|
1568
1550
|
outcome: "ignored",
|
|
1569
1551
|
reason: "The Team cannot admit Trigger events."
|
|
1570
1552
|
};
|
|
1571
|
-
let
|
|
1572
|
-
if (p == null) throw new a("Google Drive changes response is missing its next checkpoint.");
|
|
1573
|
-
let m = {
|
|
1553
|
+
let i = await It(e, n.checkpoint), a = {
|
|
1574
1554
|
changedTypes: (e.header("x-goog-changed") ?? "").split(",").map((e) => e.trim()).filter((e) => e.length > 0),
|
|
1575
1555
|
messageNumber: e.header("x-goog-message-number") ?? null,
|
|
1576
|
-
resourceState:
|
|
1556
|
+
resourceState: r,
|
|
1577
1557
|
resourceUri: e.header("x-goog-resource-uri") ?? null
|
|
1578
|
-
},
|
|
1579
|
-
checkpoint:
|
|
1580
|
-
continue:
|
|
1581
|
-
dedupeKey:
|
|
1558
|
+
}, o = i.changes.map((e) => Ht(e, a)), s = {
|
|
1559
|
+
checkpoint: i.checkpoint,
|
|
1560
|
+
continue: i.hasMore,
|
|
1561
|
+
dedupeKey: i.dedupeKey
|
|
1582
1562
|
};
|
|
1583
|
-
return
|
|
1584
|
-
...
|
|
1563
|
+
return o.length == 0 ? {
|
|
1564
|
+
...s,
|
|
1585
1565
|
outcome: "ignored",
|
|
1586
1566
|
reason: "Google Drive change page is empty."
|
|
1587
1567
|
} : {
|
|
1588
|
-
...
|
|
1568
|
+
...s,
|
|
1589
1569
|
outcome: "event",
|
|
1590
|
-
payload: { events:
|
|
1570
|
+
payload: { events: o }
|
|
1591
1571
|
};
|
|
1592
1572
|
},
|
|
1593
1573
|
async reconcile(e) {
|
|
1594
|
-
let t =
|
|
1595
|
-
if (i.length != n.length && (n = i, await
|
|
1574
|
+
let t = k(e.state), n = jt(t), r = e.now.getTime(), i = n.filter((e) => Date.parse(e.expiration) > r);
|
|
1575
|
+
if (i.length != n.length && (n = i, await A(t, n, e.now)), !e.active) return await Nt(e, n);
|
|
1596
1576
|
let a = n.filter((e) => e.state == "creating" && e.resourceId != null).toSorted((e, t) => Date.parse(t.createdAt) - Date.parse(e.createdAt))[0];
|
|
1597
1577
|
a != null && (n = n.map((e) => ({
|
|
1598
1578
|
...e,
|
|
1599
1579
|
state: e.id == a.id ? "active" : "retiring"
|
|
1600
|
-
})), await
|
|
1601
|
-
let o = n.find((e) => e.state == "active"), s = n.filter((e) => e.state == "creating").filter((e) => Date.parse(e.createdAt) +
|
|
1580
|
+
})), await A(t, n, e.now));
|
|
1581
|
+
let o = n.find((e) => e.state == "active"), s = n.filter((e) => e.state == "creating").filter((e) => Date.parse(e.createdAt) + xt <= r);
|
|
1602
1582
|
if (s.length > 0) {
|
|
1603
1583
|
let r = new Set(s.map((e) => e.id));
|
|
1604
1584
|
n = n.map((e) => r.has(e.id) ? {
|
|
1605
1585
|
...e,
|
|
1606
1586
|
state: "retiring"
|
|
1607
|
-
} : e), await
|
|
1587
|
+
} : e), await A(t, n, e.now);
|
|
1608
1588
|
}
|
|
1609
1589
|
if (o = n.find((e) => e.state == "active"), o != null) {
|
|
1610
1590
|
try {
|
|
1611
|
-
n = await
|
|
1591
|
+
n = await Pt(e, n);
|
|
1612
1592
|
} catch {
|
|
1613
1593
|
return { outcome: "ready" };
|
|
1614
1594
|
}
|
|
1615
|
-
if (o = n.find((e) => e.state == "active"), o != null && Date.parse(o.expiration) -
|
|
1595
|
+
if (o = n.find((e) => e.state == "active"), o != null && Date.parse(o.expiration) - bt > r) return await A(t, n, j(n, e.now)), { outcome: "ready" };
|
|
1616
1596
|
}
|
|
1617
|
-
return n.some((e) => e.state == "creating") || n.filter((e) => e.resourceId == null).length >=
|
|
1597
|
+
return n.some((e) => e.state == "creating") || n.filter((e) => e.resourceId == null).length >= Ct ? (await A(t, n, j(n, e.now)), { outcome: o == null ? "pending" : "ready" }) : await Mt(e, n);
|
|
1618
1598
|
}
|
|
1619
1599
|
};
|
|
1620
|
-
function
|
|
1600
|
+
function k(e) {
|
|
1621
1601
|
if (e == null) throw new i("Google Drive Integration state is missing.");
|
|
1622
1602
|
return e;
|
|
1623
1603
|
}
|
|
1624
|
-
function
|
|
1604
|
+
function kt(e) {
|
|
1625
1605
|
return {
|
|
1626
1606
|
...typeof e.driveId == "string" ? { driveId: e.driveId } : {},
|
|
1627
1607
|
includeCorpusRemovals: e.includeCorpusRemovals ?? !1,
|
|
1628
1608
|
includeItemsFromAllDrives: e.includeItemsFromAllDrives ?? !0,
|
|
1629
1609
|
includeRemoved: e.includeRemoved ?? !0,
|
|
1630
|
-
pageSize: e.pageSize ??
|
|
1610
|
+
pageSize: e.pageSize ?? wt,
|
|
1631
1611
|
restrictToMyDrive: e.restrictToMyDrive ?? !1
|
|
1632
1612
|
};
|
|
1633
1613
|
}
|
|
1634
|
-
function
|
|
1635
|
-
let t =
|
|
1614
|
+
function At(e) {
|
|
1615
|
+
let t = N(e) ? M(e.pageToken) : void 0;
|
|
1636
1616
|
if (t == null) throw new i("Google Drive checkpoint pageToken is missing.");
|
|
1637
1617
|
return t;
|
|
1638
1618
|
}
|
|
1639
|
-
function
|
|
1619
|
+
function jt(e) {
|
|
1640
1620
|
let t = e.subscription.channels;
|
|
1641
1621
|
if (!Array.isArray(t)) throw new i("Google Drive channel state is invalid.");
|
|
1642
1622
|
let n = t.map((e) => {
|
|
@@ -1659,24 +1639,24 @@ function kt(e) {
|
|
|
1659
1639
|
if (new Set(n.map((e) => e.id)).size != n.length) throw new i("Google Drive channel IDs are duplicated.");
|
|
1660
1640
|
return n;
|
|
1661
1641
|
}
|
|
1662
|
-
async function
|
|
1663
|
-
let n =
|
|
1664
|
-
n.checkpoint === null ? (s = await
|
|
1642
|
+
async function Mt(e, t) {
|
|
1643
|
+
let n = k(e.state), o = kt(e.config), s;
|
|
1644
|
+
n.checkpoint === null ? (s = await Ft(e), await n.saveCheckpoint({ pageToken: s })) : s = At(n.checkpoint);
|
|
1665
1645
|
let c = {
|
|
1666
1646
|
createdAt: e.now.toISOString(),
|
|
1667
|
-
expiration: new Date(e.now.getTime() +
|
|
1647
|
+
expiration: new Date(e.now.getTime() + yt).toISOString(),
|
|
1668
1648
|
id: crypto.randomUUID(),
|
|
1669
1649
|
state: "creating"
|
|
1670
1650
|
};
|
|
1671
|
-
t = [...t, c], await
|
|
1651
|
+
t = [...t, c], await A(n, t, new Date(e.now.getTime() + xt));
|
|
1672
1652
|
let l;
|
|
1673
1653
|
try {
|
|
1674
|
-
l = await
|
|
1654
|
+
l = await Rt(e, {
|
|
1675
1655
|
body: {
|
|
1676
1656
|
address: e.endpointUrl,
|
|
1677
1657
|
expiration: String(Date.parse(c.expiration)),
|
|
1678
1658
|
id: c.id,
|
|
1679
|
-
token: await
|
|
1659
|
+
token: await Ut(e.callbackSecret, c.id),
|
|
1680
1660
|
type: "web_hook"
|
|
1681
1661
|
},
|
|
1682
1662
|
endpoint: "/changes/watch",
|
|
@@ -1690,11 +1670,11 @@ async function At(e, t) {
|
|
|
1690
1670
|
}
|
|
1691
1671
|
}, "changes.watch");
|
|
1692
1672
|
} catch (a) {
|
|
1693
|
-
throw (a instanceof r || a instanceof i) && await
|
|
1673
|
+
throw (a instanceof r || a instanceof i) && await A(n, t.filter((e) => e.id != c.id), e.now), a;
|
|
1694
1674
|
}
|
|
1695
|
-
let u =
|
|
1675
|
+
let u = M(l.resourceId);
|
|
1696
1676
|
if (u == null) throw new a("Google Drive changes.watch response is missing resourceId.");
|
|
1697
|
-
let d =
|
|
1677
|
+
let d = Gt(l.expiration) ?? c.expiration;
|
|
1698
1678
|
t = t.map((e) => e.id == c.id ? {
|
|
1699
1679
|
...e,
|
|
1700
1680
|
expiration: d,
|
|
@@ -1703,64 +1683,75 @@ async function At(e, t) {
|
|
|
1703
1683
|
} : e.state == "active" ? {
|
|
1704
1684
|
...e,
|
|
1705
1685
|
state: "retiring"
|
|
1706
|
-
} : e), await
|
|
1686
|
+
} : e), await A(n, t, j(t, e.now));
|
|
1707
1687
|
try {
|
|
1708
|
-
t = await
|
|
1688
|
+
t = await Pt(e, t);
|
|
1709
1689
|
} catch {
|
|
1710
1690
|
return { outcome: "ready" };
|
|
1711
1691
|
}
|
|
1712
|
-
return await
|
|
1692
|
+
return await A(n, t, j(t, e.now)), { outcome: "ready" };
|
|
1713
1693
|
}
|
|
1714
|
-
async function
|
|
1715
|
-
let n =
|
|
1694
|
+
async function Nt(e, t) {
|
|
1695
|
+
let n = k(e.state);
|
|
1716
1696
|
return t.some((e) => e.state == "active" || e.state == "creating") && (t = t.map((e) => ({
|
|
1717
1697
|
...e,
|
|
1718
1698
|
state: "retiring"
|
|
1719
|
-
})), await
|
|
1699
|
+
})), await A(n, t, e.now)), t = await Pt(e, t), t.length == 0 ? { outcome: "ready" } : (await A(n, t, j(t, e.now)), { outcome: "pending" });
|
|
1720
1700
|
}
|
|
1721
|
-
async function
|
|
1722
|
-
let n =
|
|
1701
|
+
async function Pt(e, t) {
|
|
1702
|
+
let n = k(e.state);
|
|
1723
1703
|
for (let r of t) {
|
|
1724
1704
|
if (r.state != "retiring" && r.state != "stopping" || r.resourceId == null) continue;
|
|
1725
1705
|
let i = t.map((e) => e.id == r.id ? {
|
|
1726
1706
|
...e,
|
|
1727
1707
|
state: "stopping"
|
|
1728
1708
|
} : e);
|
|
1729
|
-
await
|
|
1709
|
+
await A(n, i, new Date(e.now.getTime() + St)), await Lt(e, r), t = i.filter((e) => e.id != r.id), await A(n, t, e.now);
|
|
1730
1710
|
}
|
|
1731
1711
|
return t;
|
|
1732
1712
|
}
|
|
1733
|
-
async function
|
|
1734
|
-
let n = await
|
|
1713
|
+
async function Ft(e) {
|
|
1714
|
+
let t = kt(e.config), n = await Rt(e, {
|
|
1735
1715
|
endpoint: "/changes/startPageToken",
|
|
1736
1716
|
method: "GET",
|
|
1737
1717
|
query: {
|
|
1738
1718
|
...t.driveId == null ? {} : { driveId: t.driveId },
|
|
1739
1719
|
supportsAllDrives: !0
|
|
1740
1720
|
}
|
|
1741
|
-
}, "changes.getStartPageToken"), r =
|
|
1721
|
+
}, "changes.getStartPageToken"), r = N(n) ? M(n.startPageToken) : void 0;
|
|
1742
1722
|
if (r == null) throw new a("Google Drive startPageToken response is invalid.");
|
|
1743
1723
|
return r;
|
|
1744
1724
|
}
|
|
1745
|
-
async function
|
|
1746
|
-
|
|
1725
|
+
async function It(e, t) {
|
|
1726
|
+
let n = kt(e.config), r = At(t), i = await Rt(e, {
|
|
1747
1727
|
endpoint: "/changes",
|
|
1748
1728
|
method: "GET",
|
|
1749
1729
|
query: {
|
|
1750
|
-
...
|
|
1751
|
-
fields:
|
|
1752
|
-
includeCorpusRemovals:
|
|
1753
|
-
includeItemsFromAllDrives:
|
|
1754
|
-
includeRemoved:
|
|
1755
|
-
pageSize:
|
|
1756
|
-
pageToken:
|
|
1757
|
-
restrictToMyDrive:
|
|
1730
|
+
...n.driveId == null ? {} : { driveId: n.driveId },
|
|
1731
|
+
fields: Et,
|
|
1732
|
+
includeCorpusRemovals: n.includeCorpusRemovals,
|
|
1733
|
+
includeItemsFromAllDrives: n.driveId != null || n.includeItemsFromAllDrives,
|
|
1734
|
+
includeRemoved: n.includeCorpusRemovals || n.includeRemoved,
|
|
1735
|
+
pageSize: n.pageSize,
|
|
1736
|
+
pageToken: r,
|
|
1737
|
+
restrictToMyDrive: n.restrictToMyDrive,
|
|
1758
1738
|
supportsAllDrives: !0
|
|
1759
1739
|
}
|
|
1760
1740
|
}, "changes.list");
|
|
1741
|
+
for (let e of ["nextPageToken", "newStartPageToken"]) if (i[e] !== void 0 && M(i[e]) == null) throw new a(`Google Drive changes response contains an invalid ${e}.`);
|
|
1742
|
+
let o = M(i.nextPageToken), s = o ?? M(i.newStartPageToken);
|
|
1743
|
+
if (s == null) throw new a("Google Drive changes response is missing its next checkpoint.");
|
|
1744
|
+
if (i.changes != null && (!Array.isArray(i.changes) || !i.changes.every(N))) throw new a("Google Drive changes response contains invalid changes.");
|
|
1745
|
+
if (o === r) throw new a("Google Drive changes continuation did not advance.");
|
|
1746
|
+
return {
|
|
1747
|
+
changes: i.changes ?? [],
|
|
1748
|
+
checkpoint: { pageToken: s },
|
|
1749
|
+
dedupeKey: `${n.driveId ?? "my-drive"}:${r}`,
|
|
1750
|
+
hasMore: o != null
|
|
1751
|
+
};
|
|
1761
1752
|
}
|
|
1762
|
-
async function
|
|
1763
|
-
let n = await
|
|
1753
|
+
async function Lt(e, t) {
|
|
1754
|
+
let n = await zt(e, {
|
|
1764
1755
|
body: {
|
|
1765
1756
|
id: t.id,
|
|
1766
1757
|
resourceId: t.resourceId
|
|
@@ -1768,31 +1759,31 @@ async function Ft(e, t) {
|
|
|
1768
1759
|
endpoint: "/channels/stop",
|
|
1769
1760
|
method: "POST"
|
|
1770
1761
|
});
|
|
1771
|
-
n.status >= 200 && n.status < 300 || n.status == 404 ||
|
|
1762
|
+
n.status >= 200 && n.status < 300 || n.status == 404 || Bt(n, "channels.stop");
|
|
1772
1763
|
}
|
|
1773
|
-
async function
|
|
1774
|
-
let r = await
|
|
1775
|
-
if (r.status >= 200 && r.status < 300 &&
|
|
1776
|
-
|
|
1764
|
+
async function Rt(e, t, n) {
|
|
1765
|
+
let r = await zt(e, t);
|
|
1766
|
+
if (r.status >= 200 && r.status < 300 && N(r.data)) return r.data;
|
|
1767
|
+
Bt(r, n);
|
|
1777
1768
|
}
|
|
1778
|
-
async function
|
|
1769
|
+
async function zt(e, t) {
|
|
1779
1770
|
try {
|
|
1780
1771
|
return await e.connector.execute(t, e.signal);
|
|
1781
1772
|
} catch (e) {
|
|
1782
1773
|
throw e instanceof r ? e : new a("Google Drive proxy request failed.", { cause: e });
|
|
1783
1774
|
}
|
|
1784
1775
|
}
|
|
1785
|
-
function
|
|
1786
|
-
let n =
|
|
1776
|
+
function Bt(e, t) {
|
|
1777
|
+
let n = Vt(e.data);
|
|
1787
1778
|
throw e.status == 401 || e.status == 403 && !n.toLowerCase().includes("ratelimit") ? new r(`Google Drive ${t} requires Connection reauthorization.`) : e.status == 408 || e.status == 429 || e.status >= 500 ? new a(`Google Drive ${t} is temporarily unavailable.`) : new i(`Google Drive ${t} rejected the subscription${n == "" ? "." : ` with ${n}.`}`);
|
|
1788
1779
|
}
|
|
1789
|
-
function
|
|
1790
|
-
if (!
|
|
1780
|
+
function Vt(e) {
|
|
1781
|
+
if (!N(e) || !N(e.error)) return "";
|
|
1791
1782
|
let t = e.error.errors;
|
|
1792
|
-
return Array.isArray(t) &&
|
|
1783
|
+
return Array.isArray(t) && N(t[0]) && typeof t[0].reason == "string" ? t[0].reason : typeof e.error.status == "string" ? e.error.status : "";
|
|
1793
1784
|
}
|
|
1794
|
-
function
|
|
1795
|
-
let n =
|
|
1785
|
+
function Ht(e, t) {
|
|
1786
|
+
let n = M(e.driveId), r = M(e.fileId), i = M(e.time), a = M(e.changeType), o = e.removed === !0;
|
|
1796
1787
|
return {
|
|
1797
1788
|
changeId: [
|
|
1798
1789
|
n ?? "my-drive",
|
|
@@ -1803,51 +1794,107 @@ function Bt(e, t) {
|
|
|
1803
1794
|
].join(":"),
|
|
1804
1795
|
changeType: a ?? null,
|
|
1805
1796
|
driveId: n ?? null,
|
|
1806
|
-
file:
|
|
1797
|
+
file: N(e.file) ? e.file : null,
|
|
1807
1798
|
fileId: r ?? null,
|
|
1808
1799
|
notification: t,
|
|
1809
1800
|
removed: o,
|
|
1810
1801
|
time: i ?? null
|
|
1811
1802
|
};
|
|
1812
1803
|
}
|
|
1813
|
-
async function
|
|
1804
|
+
async function A(e, t, n) {
|
|
1814
1805
|
await e.saveSubscription({ channels: t }, n);
|
|
1815
1806
|
}
|
|
1816
|
-
function
|
|
1817
|
-
let n = e.map((e) => e.state == "active" ? Date.parse(e.expiration) -
|
|
1807
|
+
function j(e, t) {
|
|
1808
|
+
let n = e.map((e) => e.state == "active" ? Date.parse(e.expiration) - bt : e.state == "creating" ? Date.parse(e.createdAt) + xt : e.resourceId == null ? Date.parse(e.expiration) : t.getTime() + St), r = n.length == 0 ? t.getTime() + St : Math.min(...n);
|
|
1818
1809
|
return new Date(Math.max(t.getTime(), r));
|
|
1819
1810
|
}
|
|
1820
|
-
async function
|
|
1821
|
-
let n = await crypto.subtle.importKey("raw",
|
|
1811
|
+
async function Ut(e, t) {
|
|
1812
|
+
let n = await crypto.subtle.importKey("raw", Tt.encode(e), {
|
|
1822
1813
|
hash: "SHA-256",
|
|
1823
1814
|
name: "HMAC"
|
|
1824
|
-
}, !1, ["sign"]), r = new Uint8Array(await crypto.subtle.sign("HMAC", n,
|
|
1815
|
+
}, !1, ["sign"]), r = new Uint8Array(await crypto.subtle.sign("HMAC", n, Tt.encode(`google-drive-channel/v1/${t}`)));
|
|
1825
1816
|
return btoa(String.fromCharCode(...r)).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
1826
1817
|
}
|
|
1827
|
-
function
|
|
1818
|
+
function Wt(e, t) {
|
|
1828
1819
|
if (e.length != t.length) return !1;
|
|
1829
1820
|
let n = 0;
|
|
1830
1821
|
for (let r = 0; r < t.length; r += 1) n |= e.charCodeAt(r) ^ t.charCodeAt(r);
|
|
1831
1822
|
return n == 0;
|
|
1832
1823
|
}
|
|
1833
|
-
function
|
|
1824
|
+
function Gt(e) {
|
|
1834
1825
|
let t = typeof e == "string" || typeof e == "number" ? Number(e) : NaN;
|
|
1835
1826
|
return Number.isFinite(t) && t > 0 ? new Date(t).toISOString() : void 0;
|
|
1836
1827
|
}
|
|
1837
|
-
function
|
|
1828
|
+
function M(e) {
|
|
1838
1829
|
return typeof e == "string" && e.length > 0 ? e : void 0;
|
|
1839
1830
|
}
|
|
1840
|
-
function
|
|
1831
|
+
function N(e) {
|
|
1841
1832
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1842
1833
|
}
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1834
|
+
async function Kt(e) {
|
|
1835
|
+
let t = k(e.state), n = e.header("x-goog-channel-id"), r = e.header("x-goog-resource-id"), i = e.header("x-goog-resource-state"), a = e.header("x-goog-channel-token");
|
|
1836
|
+
if (n == null || r == null || i == null || a == null) return {
|
|
1837
|
+
body: "",
|
|
1838
|
+
contentType: "text/plain",
|
|
1839
|
+
outcome: "respond",
|
|
1840
|
+
status: 404
|
|
1841
|
+
};
|
|
1842
|
+
let o = jt(t), s = o.find((t) => t.id == n && Date.parse(t.expiration) > e.now.getTime());
|
|
1843
|
+
return s == null || !Wt(a, await Ut(e.callbackSecret, n)) || s.resourceId != null && s.resourceId != r ? {
|
|
1844
|
+
body: "",
|
|
1845
|
+
contentType: "text/plain",
|
|
1846
|
+
outcome: "respond",
|
|
1847
|
+
status: 404
|
|
1848
|
+
} : (s.resourceId ?? (o = o.map((e) => e.id == n ? {
|
|
1849
|
+
...e,
|
|
1850
|
+
resourceId: r
|
|
1851
|
+
} : e), await A(t, o, e.now)), i != "sync" && i != "change" ? {
|
|
1852
|
+
outcome: "ignored",
|
|
1853
|
+
reason: "Google Drive notification state is not actionable."
|
|
1854
|
+
} : { outcome: "wake" });
|
|
1855
|
+
}
|
|
1856
|
+
var qt = {
|
|
1857
|
+
initialState: Ot.initialState,
|
|
1858
|
+
reconcile: Ot.reconcile,
|
|
1859
|
+
receive: Kt,
|
|
1860
|
+
listener: {
|
|
1861
|
+
intervalMs: 3e5,
|
|
1862
|
+
async read(e) {
|
|
1863
|
+
let t = await It(e, e.checkpoint);
|
|
1864
|
+
return {
|
|
1865
|
+
checkpoint: t.checkpoint,
|
|
1866
|
+
dedupeKey: t.dedupeKey,
|
|
1867
|
+
hasMore: t.hasMore,
|
|
1868
|
+
payload: t.changes.length == 0 ? null : { events: t.changes }
|
|
1869
|
+
};
|
|
1870
|
+
}
|
|
1871
|
+
},
|
|
1872
|
+
snapshot: {
|
|
1873
|
+
...Dt,
|
|
1874
|
+
configSchema: {
|
|
1875
|
+
...Dt.configSchema,
|
|
1876
|
+
description: "Configuration for googledrive.watch_changes."
|
|
1877
|
+
},
|
|
1878
|
+
key: "googledrive.watch_changes",
|
|
1879
|
+
name: "watch_changes",
|
|
1880
|
+
displayName: "Google Drive: Watch Changes",
|
|
1881
|
+
description: "Monitors Drive changes using notifications and periodic scans of the same change stream.",
|
|
1882
|
+
payloadSchema: {
|
|
1883
|
+
type: "object",
|
|
1884
|
+
additionalProperties: !1,
|
|
1885
|
+
properties: { events: {
|
|
1886
|
+
type: "array",
|
|
1887
|
+
items: { type: "object" }
|
|
1888
|
+
} },
|
|
1889
|
+
required: ["events"]
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
}, P = "application/vnd.google-apps.folder", Jt = "nextPageToken,incompleteSearch,files(id,name,mimeType,createdTime,modifiedTime,parents,trashed,webViewLink,driveId,size,version,lastModifyingUser(displayName,emailAddress))", Yt = /* @__PURE__ */ new Set([
|
|
1846
1893
|
"rateLimitExceeded",
|
|
1847
1894
|
"userRateLimitExceeded",
|
|
1848
1895
|
"dailyLimitExceeded",
|
|
1849
1896
|
"sharingRateLimitExceeded"
|
|
1850
|
-
]),
|
|
1897
|
+
]), Xt = /* @__PURE__ */ new Set(["insufficientFilePermissions", "appNotAuthorizedToFile"]), Zt = {
|
|
1851
1898
|
snapshot: {
|
|
1852
1899
|
configSchema: {
|
|
1853
1900
|
additionalProperties: !1,
|
|
@@ -1961,16 +2008,16 @@ var Wt = "application/vnd.google-apps.folder", Gt = "nextPageToken,incompleteSea
|
|
|
1961
2008
|
type: "poll"
|
|
1962
2009
|
},
|
|
1963
2010
|
async poll(e) {
|
|
1964
|
-
let t =
|
|
1965
|
-
if (e.checkpoint === null) return
|
|
1966
|
-
let n =
|
|
1967
|
-
return n.changeType === t.changeType ?
|
|
1968
|
-
checkpoint:
|
|
2011
|
+
let t = Qt(e.config);
|
|
2012
|
+
if (e.checkpoint === null) return en(e, t);
|
|
2013
|
+
let n = $t(e.checkpoint);
|
|
2014
|
+
return n.changeType === t.changeType ? nn(e, t, n) : {
|
|
2015
|
+
checkpoint: tn(e.now, t.changeType),
|
|
1969
2016
|
events: []
|
|
1970
2017
|
};
|
|
1971
2018
|
}
|
|
1972
2019
|
};
|
|
1973
|
-
function
|
|
2020
|
+
function Qt(e) {
|
|
1974
2021
|
return {
|
|
1975
2022
|
changeType: e.changeType,
|
|
1976
2023
|
driveId: e.driveId ?? "",
|
|
@@ -1981,7 +2028,7 @@ function Yt(e) {
|
|
|
1981
2028
|
namePrefix: e.namePrefix ?? ""
|
|
1982
2029
|
};
|
|
1983
2030
|
}
|
|
1984
|
-
function
|
|
2031
|
+
function $t(t) {
|
|
1985
2032
|
let n = F(t);
|
|
1986
2033
|
if (typeof n?.since != "string" || Number.isNaN(Date.parse(n.since))) throw new e("Google Drive checkpoint is invalid; recreate the Trigger.");
|
|
1987
2034
|
let r = n.boundaryKeys;
|
|
@@ -1995,23 +2042,23 @@ function Xt(t) {
|
|
|
1995
2042
|
...Array.isArray(r) ? { boundaryKeys: r.filter((e) => typeof e == "string") } : {}
|
|
1996
2043
|
};
|
|
1997
2044
|
}
|
|
1998
|
-
async function
|
|
1999
|
-
let i = await
|
|
2045
|
+
async function en(t, r) {
|
|
2046
|
+
let i = await dn(t, `/drive/v3/files/${encodeURIComponent(r.folderId)}`, {
|
|
2000
2047
|
fields: "id,name,mimeType,driveId,trashed",
|
|
2001
2048
|
supportsAllDrives: "true"
|
|
2002
2049
|
});
|
|
2003
|
-
|
|
2050
|
+
fn(i, "folder probe");
|
|
2004
2051
|
let a = F(i.data);
|
|
2005
2052
|
if (a == null) throw new n("Google Drive folder probe returned no payload.");
|
|
2006
|
-
if (a.mimeType !==
|
|
2053
|
+
if (a.mimeType !== P) throw new e("Google Drive folderId does not point to a folder.");
|
|
2007
2054
|
if (a.trashed === !0) throw new e("The Google Drive folder is in the trash.");
|
|
2008
2055
|
if (r.driveId.length > 0 && (a.driveId ?? "") !== r.driveId) throw new e("The configured Google Drive shared drive does not contain this folder.");
|
|
2009
2056
|
return {
|
|
2010
|
-
checkpoint:
|
|
2057
|
+
checkpoint: tn(t.now, r.changeType),
|
|
2011
2058
|
events: []
|
|
2012
2059
|
};
|
|
2013
2060
|
}
|
|
2014
|
-
function
|
|
2061
|
+
function tn(e, t) {
|
|
2015
2062
|
let n = e.toISOString();
|
|
2016
2063
|
return {
|
|
2017
2064
|
changeType: t,
|
|
@@ -2019,11 +2066,11 @@ function Qt(e, t) {
|
|
|
2019
2066
|
since: n
|
|
2020
2067
|
};
|
|
2021
2068
|
}
|
|
2022
|
-
async function
|
|
2023
|
-
let r =
|
|
2069
|
+
async function nn(e, t, n) {
|
|
2070
|
+
let r = on(t, n.since, n.floor), i = `${t.driveId}|${r}`, a = n.pageQuery == i ? n.pageToken : void 0, o = await dn(e, "/drive/v3/files", {
|
|
2024
2071
|
corpora: t.driveId.length == 0 ? "allDrives" : "drive",
|
|
2025
2072
|
driveId: t.driveId.length == 0 ? void 0 : t.driveId,
|
|
2026
|
-
fields:
|
|
2073
|
+
fields: Jt,
|
|
2027
2074
|
includeItemsFromAllDrives: "true",
|
|
2028
2075
|
pageSize: t.maxFilesPerPoll,
|
|
2029
2076
|
pageToken: a,
|
|
@@ -2031,74 +2078,74 @@ async function $t(e, t, n) {
|
|
|
2031
2078
|
spaces: "drive",
|
|
2032
2079
|
supportsAllDrives: "true"
|
|
2033
2080
|
});
|
|
2034
|
-
|
|
2081
|
+
fn(o, "files list");
|
|
2035
2082
|
let s = F(o.data) ?? {}, c = new Set(n.boundaryKeys ?? []), l = [], u = [], d = a == null ? void 0 : n.maxSeen;
|
|
2036
2083
|
for (let e of s.files ?? []) {
|
|
2037
2084
|
if (e.id == null || e.id.length == 0) continue;
|
|
2038
|
-
let n =
|
|
2085
|
+
let n = ln(e, t.changeType);
|
|
2039
2086
|
if (n == null) continue;
|
|
2040
|
-
let r =
|
|
2041
|
-
u.push(r.dedupeKey),
|
|
2087
|
+
let r = un(e, e.id, n, t.changeType);
|
|
2088
|
+
u.push(r.dedupeKey), gn(n, d) && (d = n), c.has(r.dedupeKey) || l.push(r);
|
|
2042
2089
|
}
|
|
2043
2090
|
if (s.incompleteSearch === !0) {
|
|
2044
|
-
let e = a == null ? {} :
|
|
2091
|
+
let e = a == null ? {} : rn(a, i, d);
|
|
2045
2092
|
return {
|
|
2046
|
-
checkpoint:
|
|
2093
|
+
checkpoint: an(n, t.changeType, n.since, u, e),
|
|
2047
2094
|
events: l
|
|
2048
2095
|
};
|
|
2049
2096
|
}
|
|
2050
2097
|
if (s.nextPageToken) return {
|
|
2051
|
-
checkpoint:
|
|
2098
|
+
checkpoint: an(n, t.changeType, n.since, u, rn(s.nextPageToken, i, d)),
|
|
2052
2099
|
events: l,
|
|
2053
2100
|
hasMore: !0
|
|
2054
2101
|
};
|
|
2055
2102
|
let f = d ?? n.since;
|
|
2056
2103
|
return {
|
|
2057
|
-
checkpoint:
|
|
2104
|
+
checkpoint: an(n, t.changeType, f, u),
|
|
2058
2105
|
events: l
|
|
2059
2106
|
};
|
|
2060
2107
|
}
|
|
2061
|
-
function
|
|
2108
|
+
function rn(e, t, n) {
|
|
2062
2109
|
return {
|
|
2063
2110
|
pageQuery: t,
|
|
2064
2111
|
pageToken: e,
|
|
2065
2112
|
...n == null ? {} : { maxSeen: n }
|
|
2066
2113
|
};
|
|
2067
2114
|
}
|
|
2068
|
-
function
|
|
2115
|
+
function an(e, t, n, r, i = {}) {
|
|
2069
2116
|
let a = [.../* @__PURE__ */ new Set([...e.boundaryKeys ?? [], ...r])].map((e) => ({
|
|
2070
2117
|
at: Date.parse(e.slice(e.indexOf(":") + 1)),
|
|
2071
2118
|
key: e
|
|
2072
|
-
})).filter(({ at: t }) => t >=
|
|
2119
|
+
})).filter(({ at: t }) => t >= sn(n, e.floor)).toSorted((e, t) => t.at - e.at).slice(0, 200).map(({ key: e }) => e);
|
|
2073
2120
|
return {
|
|
2074
2121
|
changeType: t,
|
|
2075
2122
|
since: n,
|
|
2076
|
-
...
|
|
2123
|
+
...cn(e.floor, n),
|
|
2077
2124
|
...i,
|
|
2078
2125
|
...a.length == 0 ? {} : { boundaryKeys: a }
|
|
2079
2126
|
};
|
|
2080
2127
|
}
|
|
2081
|
-
function
|
|
2128
|
+
function on(e, t, n) {
|
|
2082
2129
|
let r = e.changeType == "created" ? "createdTime" : "modifiedTime", i = [
|
|
2083
|
-
`'${
|
|
2130
|
+
`'${hn(e.folderId)}' in parents`,
|
|
2084
2131
|
"trashed = false",
|
|
2085
|
-
`${r} >= '${new Date(
|
|
2132
|
+
`${r} >= '${new Date(sn(t, n)).toISOString()}'`
|
|
2086
2133
|
];
|
|
2087
|
-
return e.itemTypes.has("folder") ? e.itemTypes.has("file") || i.push(`mimeType = '${
|
|
2134
|
+
return e.itemTypes.has("folder") ? e.itemTypes.has("file") || i.push(`mimeType = '${P}'`) : i.push(`mimeType != '${P}'`), e.mimeTypes.length > 0 && i.push(`(${e.mimeTypes.map((e) => `mimeType = '${hn(e)}'`).join(" or ")})`), e.namePrefix.length > 0 && i.push(`name contains '${hn(e.namePrefix)}'`), i.join(" and ");
|
|
2088
2135
|
}
|
|
2089
|
-
function
|
|
2136
|
+
function sn(e, t) {
|
|
2090
2137
|
let n = Date.parse(e) - 6e4, r = t == null ? NaN : Date.parse(t);
|
|
2091
2138
|
return Number.isNaN(r) ? n : Math.max(n, r);
|
|
2092
2139
|
}
|
|
2093
|
-
function
|
|
2140
|
+
function cn(e, t) {
|
|
2094
2141
|
return e == null || Number.isNaN(Date.parse(e)) || Date.parse(t) - 6e4 >= Date.parse(e) ? {} : { floor: e };
|
|
2095
2142
|
}
|
|
2096
|
-
function
|
|
2143
|
+
function ln(e, t) {
|
|
2097
2144
|
let n = t == "created" ? e.createdTime : e.modifiedTime;
|
|
2098
2145
|
return n == null || n.length == 0 || Number.isNaN(Date.parse(n)) ? void 0 : n;
|
|
2099
2146
|
}
|
|
2100
|
-
function
|
|
2101
|
-
let i = e.mimeType ==
|
|
2147
|
+
function un(e, t, n, r) {
|
|
2148
|
+
let i = e.mimeType == P ? "folder" : "file", a = e.lastModifyingUser;
|
|
2102
2149
|
return {
|
|
2103
2150
|
dedupeKey: `${t}:${n}`,
|
|
2104
2151
|
payload: {
|
|
@@ -2120,7 +2167,7 @@ function sn(e, t, n, r) {
|
|
|
2120
2167
|
}
|
|
2121
2168
|
};
|
|
2122
2169
|
}
|
|
2123
|
-
async function
|
|
2170
|
+
async function dn(e, t, r) {
|
|
2124
2171
|
try {
|
|
2125
2172
|
return await e.connector.execute({
|
|
2126
2173
|
endpoint: t,
|
|
@@ -2131,32 +2178,32 @@ async function cn(e, t, r) {
|
|
|
2131
2178
|
throw new n(`Google Drive proxy request to ${t} failed.`, { cause: e });
|
|
2132
2179
|
}
|
|
2133
2180
|
}
|
|
2134
|
-
function
|
|
2181
|
+
function fn(r, i) {
|
|
2135
2182
|
if (!(r.status >= 200 && r.status < 300)) {
|
|
2136
2183
|
if (r.status == 400 || r.status == 404) throw new e(`Google Drive ${i} rejected the configuration.`);
|
|
2137
2184
|
if (r.status == 401) throw new t(`Google Drive ${i} rejected the Connection.`);
|
|
2138
2185
|
if (r.status == 403) {
|
|
2139
|
-
let a =
|
|
2140
|
-
if (a.some((e) =>
|
|
2141
|
-
if (a.some((e) =>
|
|
2142
|
-
if (
|
|
2186
|
+
let a = pn(r.data);
|
|
2187
|
+
if (a.some((e) => Yt.has(e))) throw new n(`Google Drive ${i} was rate limited.`);
|
|
2188
|
+
if (a.some((e) => Xt.has(e))) throw new e(`Google Drive ${i} was rejected by an ACL.`);
|
|
2189
|
+
if (mn(r.data)) throw new t(`Google Drive ${i} needs additional scopes.`);
|
|
2143
2190
|
}
|
|
2144
2191
|
throw new n(`Google Drive ${i} failed with status ${r.status}.`);
|
|
2145
2192
|
}
|
|
2146
2193
|
}
|
|
2147
|
-
function
|
|
2194
|
+
function pn(e) {
|
|
2148
2195
|
let t = F(F(e)?.error);
|
|
2149
2196
|
return [...[t?.errors, t?.details].flatMap((e) => Array.isArray(e) ? e : []).map((e) => F(e)?.reason), t?.status].filter((e) => typeof e == "string");
|
|
2150
2197
|
}
|
|
2151
|
-
function
|
|
2152
|
-
if (
|
|
2198
|
+
function mn(e) {
|
|
2199
|
+
if (pn(e).includes("ACCESS_TOKEN_SCOPE_INSUFFICIENT")) return !0;
|
|
2153
2200
|
let t = F(F(e)?.error)?.message;
|
|
2154
2201
|
return typeof t == "string" && t.toLowerCase().includes("insufficient authentication scopes");
|
|
2155
2202
|
}
|
|
2156
|
-
function
|
|
2203
|
+
function hn(e) {
|
|
2157
2204
|
return e.replaceAll("\\", "\\\\").replaceAll("'", "\\'");
|
|
2158
2205
|
}
|
|
2159
|
-
function
|
|
2206
|
+
function gn(e, t) {
|
|
2160
2207
|
let n = Date.parse(e);
|
|
2161
2208
|
return Number.isNaN(n) ? !1 : t == null || Number.isNaN(Date.parse(t)) || n > Date.parse(t);
|
|
2162
2209
|
}
|
|
@@ -2165,14 +2212,14 @@ function F(e) {
|
|
|
2165
2212
|
}
|
|
2166
2213
|
//#endregion
|
|
2167
2214
|
//#region src/trigger/providers/google-sheets/on-row-added.ts
|
|
2168
|
-
var
|
|
2215
|
+
var _n = [
|
|
2169
2216
|
"permission_denied",
|
|
2170
2217
|
"accessnotconfigured",
|
|
2171
2218
|
"insufficientfilepermissions",
|
|
2172
2219
|
"appnotauthorizedtofile",
|
|
2173
2220
|
"the caller does not have permission",
|
|
2174
2221
|
"has not been used in project"
|
|
2175
|
-
],
|
|
2222
|
+
], vn = ["ratelimitexceeded", "dailylimitexceeded"], yn = {
|
|
2176
2223
|
snapshot: {
|
|
2177
2224
|
configSchema: {
|
|
2178
2225
|
additionalProperties: !1,
|
|
@@ -2266,19 +2313,19 @@ var mn = [
|
|
|
2266
2313
|
type: "poll"
|
|
2267
2314
|
},
|
|
2268
2315
|
async poll(e) {
|
|
2269
|
-
let t =
|
|
2316
|
+
let t = bn(e.config);
|
|
2270
2317
|
if (e.checkpoint === null) return {
|
|
2271
|
-
checkpoint: await
|
|
2318
|
+
checkpoint: await Cn(e, t, await Sn(e, t)),
|
|
2272
2319
|
events: []
|
|
2273
2320
|
};
|
|
2274
|
-
let n =
|
|
2321
|
+
let n = xn(e.checkpoint), r = await Sn(e, t);
|
|
2275
2322
|
if (n.spreadsheetId !== t.spreadsheetId || n.sheetId !== r.sheetId || n.lastRowNumber > r.rowCount) return {
|
|
2276
|
-
checkpoint: await
|
|
2323
|
+
checkpoint: await Cn(e, t, r),
|
|
2277
2324
|
events: []
|
|
2278
2325
|
};
|
|
2279
|
-
let i = await
|
|
2326
|
+
let i = await Tn(e, t, r), a = Math.min(Math.max(t.firstDataRow, n.lastRowNumber), r.rowCount), o = Math.min(a + t.maxRowsPerPoll, r.rowCount), s = await En(e, t, r, a, o, "row window fetch");
|
|
2280
2327
|
if (s.length == 0 && n.lastRowNumber >= t.firstDataRow) return {
|
|
2281
|
-
checkpoint: await
|
|
2328
|
+
checkpoint: await Cn(e, t, r),
|
|
2282
2329
|
events: []
|
|
2283
2330
|
};
|
|
2284
2331
|
let c = a + s.length - 1;
|
|
@@ -2290,11 +2337,11 @@ var mn = [
|
|
|
2290
2337
|
for (let [e, o] of s.entries()) {
|
|
2291
2338
|
let s = a + e;
|
|
2292
2339
|
if (!(s <= n.lastRowNumber)) {
|
|
2293
|
-
if (s == t.headerRow ||
|
|
2340
|
+
if (s == t.headerRow || On(o)) {
|
|
2294
2341
|
u += 1;
|
|
2295
2342
|
continue;
|
|
2296
2343
|
}
|
|
2297
|
-
l.push(await
|
|
2344
|
+
l.push(await kn(t, r, s, o, i));
|
|
2298
2345
|
}
|
|
2299
2346
|
}
|
|
2300
2347
|
let d = c == o && o < r.rowCount;
|
|
@@ -2310,7 +2357,7 @@ var mn = [
|
|
|
2310
2357
|
};
|
|
2311
2358
|
}
|
|
2312
2359
|
};
|
|
2313
|
-
function
|
|
2360
|
+
function bn(e) {
|
|
2314
2361
|
let t = (e.columnRange ?? "A:ZZZ").trim(), n = t.indexOf(":"), r = n < 0 ? t : t.slice(0, n), i = n < 0 ? t : t.slice(n + 1), a = e.spreadsheetId.trim();
|
|
2315
2362
|
return {
|
|
2316
2363
|
colEnd: i,
|
|
@@ -2324,7 +2371,7 @@ function _n(e) {
|
|
|
2324
2371
|
valueRender: e.valueRender ?? "UNFORMATTED_VALUE"
|
|
2325
2372
|
};
|
|
2326
2373
|
}
|
|
2327
|
-
function
|
|
2374
|
+
function xn(t) {
|
|
2328
2375
|
let n = I(t);
|
|
2329
2376
|
if (typeof n?.spreadsheetId != "string" || !Number.isInteger(n.sheetId) || !Number.isInteger(n.lastRowNumber)) throw new e("Google Sheets checkpoint is invalid; recreate the Trigger.");
|
|
2330
2377
|
return {
|
|
@@ -2333,10 +2380,10 @@ function vn(t) {
|
|
|
2333
2380
|
spreadsheetId: n.spreadsheetId
|
|
2334
2381
|
};
|
|
2335
2382
|
}
|
|
2336
|
-
async function
|
|
2337
|
-
let i = await
|
|
2383
|
+
async function Sn(t, r) {
|
|
2384
|
+
let i = await jn(t, `/spreadsheets/${encodeURIComponent(r.spreadsheetId)}`, { fields: "sheets.properties(sheetId,title,sheetType,gridProperties)" });
|
|
2338
2385
|
if (i.status == 404) throw new e("The Google Sheets spreadsheet was not found.");
|
|
2339
|
-
|
|
2386
|
+
Mn(i, "spreadsheet metadata fetch");
|
|
2340
2387
|
let a = I(i.data)?.sheets, o = (Array.isArray(a) ? a.map((e) => I(I(e)?.properties)) : []).filter((e) => e != null), s = (/^\d+$/.test(r.sheet) ? o.find(({ sheetId: e }) => e === Number(r.sheet)) : void 0) ?? o.find(({ title: e }) => e === r.sheet);
|
|
2341
2388
|
if (s == null) throw new e(`Google Sheets tab "${r.sheet}" does not exist.`);
|
|
2342
2389
|
if (s.sheetType != null && s.sheetType !== "GRID") throw new e("The Google Sheets tab is not a grid sheet.");
|
|
@@ -2348,45 +2395,45 @@ async function yn(t, r) {
|
|
|
2348
2395
|
title: s.title
|
|
2349
2396
|
};
|
|
2350
2397
|
}
|
|
2351
|
-
async function
|
|
2398
|
+
async function Cn(e, t, n) {
|
|
2352
2399
|
return {
|
|
2353
|
-
lastRowNumber: await
|
|
2400
|
+
lastRowNumber: await wn(e, t, n),
|
|
2354
2401
|
sheetId: n.sheetId,
|
|
2355
2402
|
spreadsheetId: t.spreadsheetId
|
|
2356
2403
|
};
|
|
2357
2404
|
}
|
|
2358
|
-
async function
|
|
2405
|
+
async function wn(e, t, n) {
|
|
2359
2406
|
if (n.rowCount < t.firstDataRow) return t.firstDataRow - 1;
|
|
2360
|
-
let r = await
|
|
2407
|
+
let r = await En(e, t, n, t.firstDataRow, n.rowCount, "full-range scan");
|
|
2361
2408
|
return r.length == 0 ? t.firstDataRow - 1 : t.firstDataRow + r.length - 1;
|
|
2362
2409
|
}
|
|
2363
|
-
async function
|
|
2364
|
-
let r = await
|
|
2410
|
+
async function Tn(e, t, n) {
|
|
2411
|
+
let r = await jn(e, An(t, n, t.headerRow, t.headerRow), {
|
|
2365
2412
|
majorDimension: "ROWS",
|
|
2366
2413
|
valueRenderOption: "FORMATTED_VALUE"
|
|
2367
2414
|
});
|
|
2368
|
-
return
|
|
2415
|
+
return Mn(r, "header row fetch"), Dn(r.data)[0] ?? [];
|
|
2369
2416
|
}
|
|
2370
|
-
async function
|
|
2371
|
-
let o = await
|
|
2417
|
+
async function En(e, t, n, r, i, a) {
|
|
2418
|
+
let o = await jn(e, An(t, n, r, i), {
|
|
2372
2419
|
dateTimeRenderOption: t.dateTimeRender,
|
|
2373
2420
|
majorDimension: "ROWS",
|
|
2374
2421
|
valueRenderOption: t.valueRender
|
|
2375
2422
|
});
|
|
2376
|
-
return
|
|
2423
|
+
return Mn(o, a), Dn(o.data);
|
|
2377
2424
|
}
|
|
2378
|
-
function
|
|
2425
|
+
function Dn(e) {
|
|
2379
2426
|
let t = I(e)?.values;
|
|
2380
2427
|
return Array.isArray(t) ? t : [];
|
|
2381
2428
|
}
|
|
2382
|
-
function
|
|
2429
|
+
function On(e) {
|
|
2383
2430
|
return e.every((e) => e === "" || e == null);
|
|
2384
2431
|
}
|
|
2385
|
-
async function
|
|
2386
|
-
let a = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(r))), o = [...new Uint8Array(a)].slice(0, 8).map((e) => e.toString(16).padStart(2, "0")).join(""), s = {}, c =
|
|
2432
|
+
async function kn(e, t, n, r, i) {
|
|
2433
|
+
let a = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(r))), o = [...new Uint8Array(a)].slice(0, 8).map((e) => e.toString(16).padStart(2, "0")).join(""), s = {}, c = Nn(e.colStart);
|
|
2387
2434
|
for (let [e, t] of r.entries()) {
|
|
2388
2435
|
let n = i[e];
|
|
2389
|
-
s[typeof n == "string" && n.length > 0 ? n :
|
|
2436
|
+
s[typeof n == "string" && n.length > 0 ? n : Pn(c + e)] = t;
|
|
2390
2437
|
}
|
|
2391
2438
|
return {
|
|
2392
2439
|
dedupeKey: `${t.sheetId}:${n}:${o}`,
|
|
@@ -2400,11 +2447,11 @@ async function En(e, t, n, r, i) {
|
|
|
2400
2447
|
}
|
|
2401
2448
|
};
|
|
2402
2449
|
}
|
|
2403
|
-
function
|
|
2450
|
+
function An(e, t, n, r) {
|
|
2404
2451
|
let i = encodeURIComponent(`'${t.title.replaceAll("'", "''")}'`);
|
|
2405
2452
|
return `/spreadsheets/${encodeURIComponent(e.spreadsheetId)}/values/${i}!${e.colStart}${n}:${e.colEnd}${r}`;
|
|
2406
2453
|
}
|
|
2407
|
-
async function
|
|
2454
|
+
async function jn(e, t, r) {
|
|
2408
2455
|
try {
|
|
2409
2456
|
return await e.connector.execute({
|
|
2410
2457
|
endpoint: t,
|
|
@@ -2415,22 +2462,22 @@ async function On(e, t, r) {
|
|
|
2415
2462
|
throw new n(`Google Sheets proxy request to ${t} failed.`, { cause: e });
|
|
2416
2463
|
}
|
|
2417
2464
|
}
|
|
2418
|
-
function
|
|
2465
|
+
function Mn(r, i) {
|
|
2419
2466
|
if (r.status >= 200 && r.status < 300) return;
|
|
2420
2467
|
if (r.status == 401) throw new t(`Google Sheets ${i} rejected the Connection.`);
|
|
2421
2468
|
let a = JSON.stringify(r.data ?? null).toLowerCase();
|
|
2422
2469
|
if (r.status == 403) {
|
|
2423
|
-
if (
|
|
2424
|
-
if (
|
|
2470
|
+
if (vn.some((e) => a.includes(e))) throw new n(`Google Sheets ${i} was rate limited.`);
|
|
2471
|
+
if (_n.some((e) => a.includes(e))) throw new t(`Google Sheets ${i} rejected the Connection.`);
|
|
2425
2472
|
}
|
|
2426
2473
|
throw r.status == 400 && a.includes("unable to parse range") ? new e("Google Sheets rejected the configured range.") : r.status == 413 ? new e("Google Sheets response is too large; narrow columnRange.") : new n(`Google Sheets ${i} failed with status ${r.status}.`);
|
|
2427
2474
|
}
|
|
2428
|
-
function
|
|
2475
|
+
function Nn(e) {
|
|
2429
2476
|
let t = 0;
|
|
2430
2477
|
for (let n of e.toUpperCase()) t = t * 26 + n.charCodeAt(0) - 64;
|
|
2431
2478
|
return t;
|
|
2432
2479
|
}
|
|
2433
|
-
function
|
|
2480
|
+
function Pn(e) {
|
|
2434
2481
|
let t = "";
|
|
2435
2482
|
for (let n = e; n > 0; n = Math.floor((n - 1) / 26)) t = String.fromCharCode(65 + (n - 1) % 26) + t;
|
|
2436
2483
|
return t;
|
|
@@ -2438,7 +2485,7 @@ function jn(e) {
|
|
|
2438
2485
|
function I(e) {
|
|
2439
2486
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
2440
2487
|
}
|
|
2441
|
-
var
|
|
2488
|
+
var Fn = {
|
|
2442
2489
|
snapshot: {
|
|
2443
2490
|
configSchema: {
|
|
2444
2491
|
additionalProperties: !1,
|
|
@@ -2527,13 +2574,13 @@ var Mn = {
|
|
|
2527
2574
|
type: "poll"
|
|
2528
2575
|
},
|
|
2529
2576
|
async poll(e) {
|
|
2530
|
-
let t =
|
|
2531
|
-
if (e.checkpoint === null) return
|
|
2532
|
-
let n =
|
|
2533
|
-
return n.target ===
|
|
2577
|
+
let t = In(e.config);
|
|
2578
|
+
if (e.checkpoint === null) return Ln(e, t);
|
|
2579
|
+
let n = zn(e.checkpoint);
|
|
2580
|
+
return n.target === Zn(t) ? Hn(e, t, Vn(n, Bn(t.events))) : Ln(e, t);
|
|
2534
2581
|
}
|
|
2535
2582
|
};
|
|
2536
|
-
function
|
|
2583
|
+
function In(e) {
|
|
2537
2584
|
return {
|
|
2538
2585
|
dataSourceId: e.dataSourceId ?? "",
|
|
2539
2586
|
databaseId: e.databaseId,
|
|
@@ -2542,9 +2589,9 @@ function Nn(e) {
|
|
|
2542
2589
|
maxItemsPerPoll: e.maxItemsPerPoll ?? 25
|
|
2543
2590
|
};
|
|
2544
2591
|
}
|
|
2545
|
-
async function
|
|
2546
|
-
let n = await
|
|
2547
|
-
return
|
|
2592
|
+
async function Ln(e, t) {
|
|
2593
|
+
let n = await Rn(e, t), r = Bn(t.events);
|
|
2594
|
+
return Xn(await Yn(e, {
|
|
2548
2595
|
body: {
|
|
2549
2596
|
page_size: 1,
|
|
2550
2597
|
sorts: [{
|
|
@@ -2559,30 +2606,30 @@ async function Pn(e, t) {
|
|
|
2559
2606
|
cursorField: r,
|
|
2560
2607
|
dataSourceId: n,
|
|
2561
2608
|
since: (/* @__PURE__ */ new Date(Math.ceil(e.now.getTime() / 6e4) * 6e4)).toISOString(),
|
|
2562
|
-
target:
|
|
2609
|
+
target: Zn(t)
|
|
2563
2610
|
},
|
|
2564
2611
|
events: []
|
|
2565
2612
|
};
|
|
2566
2613
|
}
|
|
2567
|
-
async function
|
|
2568
|
-
let r = await
|
|
2614
|
+
async function Rn(t, n) {
|
|
2615
|
+
let r = await Yn(t, {
|
|
2569
2616
|
endpoint: `/databases/${encodeURIComponent(n.databaseId)}`,
|
|
2570
2617
|
method: "GET"
|
|
2571
2618
|
});
|
|
2572
|
-
|
|
2619
|
+
Xn(r, "database resolve");
|
|
2573
2620
|
let i = L(r.data)?.data_sources, a = Array.isArray(i) ? i.flatMap((e) => {
|
|
2574
2621
|
let t = L(e)?.id;
|
|
2575
2622
|
return typeof t == "string" && t.length > 0 ? [t] : [];
|
|
2576
2623
|
}) : [];
|
|
2577
2624
|
if (n.dataSourceId.length > 0) {
|
|
2578
|
-
let t =
|
|
2625
|
+
let t = Qn(n.dataSourceId), r = a.find((e) => Qn(e) == t);
|
|
2579
2626
|
if (r == null) throw new e("The Notion data source does not belong to the configured database.");
|
|
2580
2627
|
return r;
|
|
2581
2628
|
}
|
|
2582
2629
|
if (a.length == 1) return a[0];
|
|
2583
2630
|
throw a.length == 0 ? new e("The Notion database has no data sources.") : new e("The Notion database has multiple data sources; configure dataSourceId.");
|
|
2584
2631
|
}
|
|
2585
|
-
function
|
|
2632
|
+
function zn(t) {
|
|
2586
2633
|
let n = L(t), r = n?.cursorField;
|
|
2587
2634
|
if (typeof n?.dataSourceId != "string" || n.dataSourceId.length == 0 || r !== "created_time" && r !== "last_edited_time" || typeof n.since != "string" || n.since.length == 0) throw new e("Notion checkpoint is invalid; recreate the Trigger.");
|
|
2588
2635
|
return {
|
|
@@ -2595,10 +2642,10 @@ function In(t) {
|
|
|
2595
2642
|
...n.sinceOnly === !0 ? { sinceOnly: !0 } : {}
|
|
2596
2643
|
};
|
|
2597
2644
|
}
|
|
2598
|
-
function
|
|
2645
|
+
function Bn(e) {
|
|
2599
2646
|
return e.length == 1 && e[0] == "page_added" ? "created_time" : "last_edited_time";
|
|
2600
2647
|
}
|
|
2601
|
-
function
|
|
2648
|
+
function Vn(e, t) {
|
|
2602
2649
|
return e.cursorField == t ? e : {
|
|
2603
2650
|
cursorField: t,
|
|
2604
2651
|
dataSourceId: e.dataSourceId,
|
|
@@ -2606,11 +2653,11 @@ function Rn(e, t) {
|
|
|
2606
2653
|
target: e.target
|
|
2607
2654
|
};
|
|
2608
2655
|
}
|
|
2609
|
-
async function
|
|
2656
|
+
async function Hn(e, t, n) {
|
|
2610
2657
|
let r = [], i = 0, a = 0, o = null, s = n.startCursor, c = null;
|
|
2611
2658
|
for (let l = 0; l < 5; l += 1) {
|
|
2612
|
-
let l = await
|
|
2613
|
-
body:
|
|
2659
|
+
let l = await Yn(e, {
|
|
2660
|
+
body: Gn(n, t.maxItemsPerPoll - a, s),
|
|
2614
2661
|
endpoint: `/data_sources/${encodeURIComponent(n.dataSourceId)}/query`,
|
|
2615
2662
|
method: "POST"
|
|
2616
2663
|
});
|
|
@@ -2618,14 +2665,14 @@ async function zn(e, t, n) {
|
|
|
2618
2665
|
c = "restarted";
|
|
2619
2666
|
break;
|
|
2620
2667
|
}
|
|
2621
|
-
|
|
2668
|
+
Xn(l, "data source query");
|
|
2622
2669
|
let u = L(l.data) ?? {};
|
|
2623
2670
|
for (let e of u.results ?? []) {
|
|
2624
2671
|
a += 1;
|
|
2625
2672
|
let s = n.cursorField == "created_time" ? e.created_time : e.last_edited_time;
|
|
2626
|
-
s != null && s.length > 0 && (o =
|
|
2627
|
-
let c =
|
|
2628
|
-
t.events.includes(c) ? r.push(
|
|
2673
|
+
s != null && s.length > 0 && (o = er(o, s));
|
|
2674
|
+
let c = Kn(e);
|
|
2675
|
+
t.events.includes(c) ? r.push(qn(e, c, t, n)) : i += 1;
|
|
2629
2676
|
}
|
|
2630
2677
|
if (u.request_status?.type == "incomplete") {
|
|
2631
2678
|
c = "truncated";
|
|
@@ -2651,36 +2698,36 @@ async function zn(e, t, n) {
|
|
|
2651
2698
|
...l,
|
|
2652
2699
|
since: n.since,
|
|
2653
2700
|
startCursor: c.nextCursor,
|
|
2654
|
-
...
|
|
2701
|
+
...Wn(n)
|
|
2655
2702
|
} : {
|
|
2656
2703
|
...l,
|
|
2657
|
-
...
|
|
2704
|
+
...Un(n, c, o, e.now)
|
|
2658
2705
|
},
|
|
2659
2706
|
events: r,
|
|
2660
2707
|
filtered: i,
|
|
2661
2708
|
...c == "complete" ? {} : { hasMore: !0 }
|
|
2662
2709
|
};
|
|
2663
2710
|
}
|
|
2664
|
-
function
|
|
2711
|
+
function Un(e, t, n, r) {
|
|
2665
2712
|
let i = {
|
|
2666
2713
|
since: e.since,
|
|
2667
|
-
...
|
|
2714
|
+
...Wn(e)
|
|
2668
2715
|
}, a = Date.parse(e.since) + 6e4 <= r.getTime() ? {
|
|
2669
2716
|
since: e.since,
|
|
2670
2717
|
sinceExclusive: !0
|
|
2671
2718
|
} : i;
|
|
2672
|
-
return n != null &&
|
|
2719
|
+
return n != null && tr(n, e.since) ? { since: n } : t == "restarted" ? i : t == "complete" ? e.sinceOnly === !0 || n != null ? a : i : n == null ? i : e.sinceOnly === !0 ? a : {
|
|
2673
2720
|
since: e.since,
|
|
2674
2721
|
sinceOnly: !0
|
|
2675
2722
|
};
|
|
2676
2723
|
}
|
|
2677
|
-
function
|
|
2724
|
+
function Wn(e) {
|
|
2678
2725
|
return {
|
|
2679
2726
|
...e.sinceExclusive === !0 ? { sinceExclusive: !0 } : {},
|
|
2680
2727
|
...e.sinceOnly === !0 ? { sinceOnly: !0 } : {}
|
|
2681
2728
|
};
|
|
2682
2729
|
}
|
|
2683
|
-
function
|
|
2730
|
+
function Gn(e, t, n) {
|
|
2684
2731
|
let r = e.cursorField;
|
|
2685
2732
|
return {
|
|
2686
2733
|
filter: e.sinceOnly === !0 ? { and: [{
|
|
@@ -2701,62 +2748,62 @@ function Hn(e, t, n) {
|
|
|
2701
2748
|
...n == null ? {} : { start_cursor: n }
|
|
2702
2749
|
};
|
|
2703
2750
|
}
|
|
2704
|
-
function
|
|
2705
|
-
return
|
|
2751
|
+
function Kn(e) {
|
|
2752
|
+
return nr(e.created_time) === nr(e.last_edited_time) ? "page_added" : "page_updated";
|
|
2706
2753
|
}
|
|
2707
|
-
function
|
|
2754
|
+
function qn(e, t, n, r) {
|
|
2708
2755
|
return {
|
|
2709
|
-
dedupeKey: t == "page_added" ? `added:${e.id}` : `updated:${e.id}:${
|
|
2756
|
+
dedupeKey: t == "page_added" ? `added:${e.id}` : `updated:${e.id}:${nr(e.last_edited_time) ?? e.last_edited_time ?? ""}`,
|
|
2710
2757
|
payload: {
|
|
2711
2758
|
createdBy: { id: e.created_by?.id ?? "" },
|
|
2712
2759
|
createdTime: e.created_time ?? "",
|
|
2713
2760
|
dataSourceId: r.dataSourceId,
|
|
2714
|
-
databaseId:
|
|
2761
|
+
databaseId: $n(n.databaseId),
|
|
2715
2762
|
event: t,
|
|
2716
2763
|
lastEditedBy: { id: e.last_edited_by?.id ?? "" },
|
|
2717
2764
|
lastEditedTime: e.last_edited_time ?? "",
|
|
2718
2765
|
pageId: e.id,
|
|
2719
2766
|
...n.includeProperties ? { properties: e.properties ?? {} } : {},
|
|
2720
|
-
title:
|
|
2767
|
+
title: Jn(e.properties ?? {}),
|
|
2721
2768
|
url: e.url ?? ""
|
|
2722
2769
|
}
|
|
2723
2770
|
};
|
|
2724
2771
|
}
|
|
2725
|
-
function
|
|
2772
|
+
function Jn(e) {
|
|
2726
2773
|
for (let t of Object.values(e)) {
|
|
2727
2774
|
let e = L(t);
|
|
2728
2775
|
if (!(e?.type !== "title" || !Array.isArray(e.title))) return e.title.map((e) => typeof L(e)?.plain_text == "string" ? L(e).plain_text : "").join("");
|
|
2729
2776
|
}
|
|
2730
2777
|
return "";
|
|
2731
2778
|
}
|
|
2732
|
-
async function
|
|
2779
|
+
async function Yn(e, t) {
|
|
2733
2780
|
try {
|
|
2734
2781
|
return await e.connector.execute(t, e.signal);
|
|
2735
2782
|
} catch (e) {
|
|
2736
2783
|
throw new n(`Notion proxy request to ${t.endpoint} failed.`, { cause: e });
|
|
2737
2784
|
}
|
|
2738
2785
|
}
|
|
2739
|
-
function
|
|
2786
|
+
function Xn(r, i) {
|
|
2740
2787
|
if (!(r.status >= 200 && r.status < 300)) throw r.status == 401 || r.status == 403 ? new t(`Notion ${i} rejected the Connection.`) : r.status == 404 ? new e("The Notion target was not found or is not shared with the Connection.") : r.status == 400 ? new e(`Notion ${i} rejected the configuration.`) : new n(`Notion ${i} failed with status ${r.status}.`);
|
|
2741
2788
|
}
|
|
2742
|
-
function
|
|
2789
|
+
function Zn(e) {
|
|
2743
2790
|
return `${e.databaseId}|${e.dataSourceId}`;
|
|
2744
2791
|
}
|
|
2745
|
-
function
|
|
2792
|
+
function Qn(e) {
|
|
2746
2793
|
return e.replaceAll("-", "").toLowerCase();
|
|
2747
2794
|
}
|
|
2748
|
-
function
|
|
2749
|
-
let t =
|
|
2795
|
+
function $n(e) {
|
|
2796
|
+
let t = Qn(e);
|
|
2750
2797
|
return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
|
|
2751
2798
|
}
|
|
2752
|
-
function
|
|
2799
|
+
function er(e, t) {
|
|
2753
2800
|
let n = Date.parse(t);
|
|
2754
2801
|
return Number.isNaN(n) || e != null && n < Date.parse(e) ? e : t;
|
|
2755
2802
|
}
|
|
2756
|
-
function
|
|
2803
|
+
function tr(e, t) {
|
|
2757
2804
|
return !Number.isNaN(Date.parse(e)) && !Number.isNaN(Date.parse(t)) && Date.parse(e) > Date.parse(t);
|
|
2758
2805
|
}
|
|
2759
|
-
function
|
|
2806
|
+
function nr(e) {
|
|
2760
2807
|
if (e == null || e.length == 0) return null;
|
|
2761
2808
|
let t = Date.parse(e);
|
|
2762
2809
|
return Number.isNaN(t) ? null : new Date(t).toISOString();
|
|
@@ -2764,7 +2811,7 @@ function $n(e) {
|
|
|
2764
2811
|
function L(e) {
|
|
2765
2812
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
2766
2813
|
}
|
|
2767
|
-
var
|
|
2814
|
+
var rr = {
|
|
2768
2815
|
snapshot: {
|
|
2769
2816
|
configSchema: {
|
|
2770
2817
|
additionalProperties: !1,
|
|
@@ -2871,14 +2918,14 @@ var er = {
|
|
|
2871
2918
|
type: "poll"
|
|
2872
2919
|
},
|
|
2873
2920
|
async poll(e) {
|
|
2874
|
-
let t =
|
|
2921
|
+
let t = ir(e.config);
|
|
2875
2922
|
if (e.checkpoint === null) return {
|
|
2876
|
-
checkpoint: await
|
|
2923
|
+
checkpoint: await ar(e, t),
|
|
2877
2924
|
events: []
|
|
2878
2925
|
};
|
|
2879
|
-
let n =
|
|
2926
|
+
let n = sr(e.checkpoint), { items: r, next: i } = await cr(e, n, t.maxItemsPerPoll), a = [], o = 0;
|
|
2880
2927
|
for (let [e, i] of r) {
|
|
2881
|
-
let r =
|
|
2928
|
+
let r = lr(e, i, t, new Date(n.lastPolledAt));
|
|
2882
2929
|
r != "structural" && (r == "filtered" ? o += 1 : a.push(r));
|
|
2883
2930
|
}
|
|
2884
2931
|
return {
|
|
@@ -2889,7 +2936,7 @@ var er = {
|
|
|
2889
2936
|
};
|
|
2890
2937
|
}
|
|
2891
2938
|
};
|
|
2892
|
-
function
|
|
2939
|
+
function ir(e) {
|
|
2893
2940
|
return {
|
|
2894
2941
|
events: e.events ?? ["created", "updated"],
|
|
2895
2942
|
itemId: (e.itemId ?? "").trim(),
|
|
@@ -2898,24 +2945,24 @@ function tr(e) {
|
|
|
2898
2945
|
parentFolderId: (e.parentFolderId ?? "").trim()
|
|
2899
2946
|
};
|
|
2900
2947
|
}
|
|
2901
|
-
async function
|
|
2902
|
-
let i = await
|
|
2948
|
+
async function ar(t, r) {
|
|
2949
|
+
let i = await fr(t, "/me/drive/root/delta", { token: "latest" });
|
|
2903
2950
|
if (i.status == 404) throw new e("OneDrive is not provisioned for this account.");
|
|
2904
|
-
|
|
2905
|
-
let a = R(i.data)?.["@odata.deltaLink"], o = a == null ? null :
|
|
2951
|
+
mr(i, "delta seeding");
|
|
2952
|
+
let a = R(i.data)?.["@odata.deltaLink"], o = a == null ? null : _r(a);
|
|
2906
2953
|
if (o == null) throw new n("OneDrive delta seeding response has no delta token.");
|
|
2907
|
-
return await
|
|
2954
|
+
return await or(t, "parentFolderId", r.parentFolderId), await or(t, "itemId", r.itemId), {
|
|
2908
2955
|
deltaToken: o,
|
|
2909
2956
|
lastPolledAt: t.now.toISOString()
|
|
2910
2957
|
};
|
|
2911
2958
|
}
|
|
2912
|
-
async function
|
|
2959
|
+
async function or(t, n, r) {
|
|
2913
2960
|
if (r.length == 0) return;
|
|
2914
|
-
let i = await
|
|
2961
|
+
let i = await fr(t, `/me/drive/items/${encodeURIComponent(r)}`, {});
|
|
2915
2962
|
if (i.status == 400 || i.status == 404) throw new e(`OneDrive ${n} does not identify an item in this drive.`);
|
|
2916
|
-
|
|
2963
|
+
mr(i, `${n} validation`);
|
|
2917
2964
|
}
|
|
2918
|
-
function
|
|
2965
|
+
function sr(t) {
|
|
2919
2966
|
let n = R(t);
|
|
2920
2967
|
if (typeof n?.deltaToken != "string" || n.deltaToken.length == 0 || typeof n.lastPolledAt != "string" || Number.isNaN(Date.parse(n.lastPolledAt))) throw new e("OneDrive checkpoint is invalid; recreate the Trigger.");
|
|
2921
2968
|
return {
|
|
@@ -2924,28 +2971,28 @@ function ir(t) {
|
|
|
2924
2971
|
...typeof n.pageToken == "string" && n.pageToken.length > 0 ? { pageToken: n.pageToken } : {}
|
|
2925
2972
|
};
|
|
2926
2973
|
}
|
|
2927
|
-
async function
|
|
2974
|
+
async function cr(e, t, r) {
|
|
2928
2975
|
let i = /* @__PURE__ */ new Map(), a = t.pageToken ?? t.deltaToken;
|
|
2929
2976
|
for (let t = 0; t < 5; t += 1) {
|
|
2930
|
-
let t = await
|
|
2977
|
+
let t = await fr(e, "/me/drive/root/delta", {
|
|
2931
2978
|
$top: r,
|
|
2932
2979
|
token: a
|
|
2933
2980
|
});
|
|
2934
|
-
|
|
2981
|
+
pr(t);
|
|
2935
2982
|
let o = R(t.data) ?? {};
|
|
2936
2983
|
for (let e of o.value ?? []) e.id != null && e.id.length > 0 && i.set(e.id, e);
|
|
2937
2984
|
if (o["@odata.deltaLink"]) return {
|
|
2938
2985
|
items: i,
|
|
2939
2986
|
next: {
|
|
2940
2987
|
checkpoint: {
|
|
2941
|
-
deltaToken:
|
|
2988
|
+
deltaToken: gr(o["@odata.deltaLink"]),
|
|
2942
2989
|
lastPolledAt: e.now.toISOString()
|
|
2943
2990
|
},
|
|
2944
2991
|
hasMore: !1
|
|
2945
2992
|
}
|
|
2946
2993
|
};
|
|
2947
2994
|
if (!o["@odata.nextLink"]) throw new n("OneDrive delta response has no continuation link.");
|
|
2948
|
-
a =
|
|
2995
|
+
a = gr(o["@odata.nextLink"]);
|
|
2949
2996
|
}
|
|
2950
2997
|
return {
|
|
2951
2998
|
items: i,
|
|
@@ -2959,17 +3006,17 @@ async function ar(e, t, r) {
|
|
|
2959
3006
|
}
|
|
2960
3007
|
};
|
|
2961
3008
|
}
|
|
2962
|
-
function
|
|
3009
|
+
function lr(e, t, n, r) {
|
|
2963
3010
|
if (t.root != null) return "structural";
|
|
2964
|
-
let i =
|
|
3011
|
+
let i = ur(t);
|
|
2965
3012
|
if (i == null) return "structural";
|
|
2966
|
-
let a = t.deleted == null ?
|
|
2967
|
-
return !n.events.includes(a) || !n.itemTypes.includes(i) || n.parentFolderId.length > 0 && t.parentReference?.id !== n.parentFolderId || n.itemId.length > 0 && e !== n.itemId ? "filtered" :
|
|
3013
|
+
let a = t.deleted == null ? vr(t.createdDateTime, r) ? "created" : "updated" : "deleted";
|
|
3014
|
+
return !n.events.includes(a) || !n.itemTypes.includes(i) || n.parentFolderId.length > 0 && t.parentReference?.id !== n.parentFolderId || n.itemId.length > 0 && e !== n.itemId ? "filtered" : dr(e, t, a, i);
|
|
2968
3015
|
}
|
|
2969
|
-
function
|
|
3016
|
+
function ur(e) {
|
|
2970
3017
|
return e.file == null ? e.folder == null ? e.deleted == null ? null : "file" : "folder" : "file";
|
|
2971
3018
|
}
|
|
2972
|
-
function
|
|
3019
|
+
function dr(e, t, n, r) {
|
|
2973
3020
|
return {
|
|
2974
3021
|
dedupeKey: t.deleted == null ? `${e}:${t.eTag ?? t.lastModifiedDateTime}` : `${e}:deleted`,
|
|
2975
3022
|
payload: {
|
|
@@ -2988,7 +3035,7 @@ function cr(e, t, n, r) {
|
|
|
2988
3035
|
}
|
|
2989
3036
|
};
|
|
2990
3037
|
}
|
|
2991
|
-
async function
|
|
3038
|
+
async function fr(e, t, r) {
|
|
2992
3039
|
try {
|
|
2993
3040
|
return await e.connector.execute({
|
|
2994
3041
|
endpoint: t,
|
|
@@ -2999,16 +3046,16 @@ async function lr(e, t, r) {
|
|
|
2999
3046
|
throw new n(`OneDrive proxy request to ${t} failed.`, { cause: e });
|
|
3000
3047
|
}
|
|
3001
3048
|
}
|
|
3002
|
-
function
|
|
3003
|
-
if (t.status == 410 &&
|
|
3049
|
+
function pr(t) {
|
|
3050
|
+
if (t.status == 410 && hr(t.data)) throw new e("OneDrive delta token expired; recreate the Trigger.");
|
|
3004
3051
|
if (t.status == 404) throw new e("OneDrive is not provisioned for this account.");
|
|
3005
3052
|
if (t.status == 400) throw new e("OneDrive rejected the delta token; recreate the Trigger.");
|
|
3006
|
-
|
|
3053
|
+
mr(t, "delta list");
|
|
3007
3054
|
}
|
|
3008
|
-
function
|
|
3055
|
+
function mr(e, r) {
|
|
3009
3056
|
if (!(e.status >= 200 && e.status < 300)) throw e.status == 401 || e.status == 403 ? new t(`OneDrive ${r} rejected the Connection.`) : new n(`OneDrive ${r} failed with status ${e.status}.`);
|
|
3010
3057
|
}
|
|
3011
|
-
function
|
|
3058
|
+
function hr(e) {
|
|
3012
3059
|
let t = R(e)?.error;
|
|
3013
3060
|
for (; t != null;) {
|
|
3014
3061
|
let e = R(t);
|
|
@@ -3018,12 +3065,12 @@ function fr(e) {
|
|
|
3018
3065
|
}
|
|
3019
3066
|
return !1;
|
|
3020
3067
|
}
|
|
3021
|
-
function
|
|
3022
|
-
let t =
|
|
3068
|
+
function gr(e) {
|
|
3069
|
+
let t = _r(e);
|
|
3023
3070
|
if (t == null) throw new n("OneDrive delta link has no token.");
|
|
3024
3071
|
return t;
|
|
3025
3072
|
}
|
|
3026
|
-
function
|
|
3073
|
+
function _r(e) {
|
|
3027
3074
|
let t = /[?&]token=([^&#]+)/.exec(e)?.[1] ?? /\(token='([^']+)'\)/.exec(e)?.[1];
|
|
3028
3075
|
if (t == null) return null;
|
|
3029
3076
|
try {
|
|
@@ -3032,7 +3079,7 @@ function mr(e) {
|
|
|
3032
3079
|
return t;
|
|
3033
3080
|
}
|
|
3034
3081
|
}
|
|
3035
|
-
function
|
|
3082
|
+
function vr(e, t) {
|
|
3036
3083
|
if (e == null || e.length == 0) return !1;
|
|
3037
3084
|
let n = new Date(e);
|
|
3038
3085
|
return !Number.isNaN(n.getTime()) && n >= t;
|
|
@@ -3042,14 +3089,14 @@ function R(e) {
|
|
|
3042
3089
|
}
|
|
3043
3090
|
//#endregion
|
|
3044
3091
|
//#region src/trigger/providers/outlook/on-message-received.ts
|
|
3045
|
-
var
|
|
3092
|
+
var yr = "inbox", br = 25, xr = 100, Sr = "1970-01-01T00:00:00Z", Cr = "id,internetMessageId,conversationId,subject,bodyPreview,from,toRecipients,receivedDateTime,hasAttachments,isRead,isDraft,importance,categories,parentFolderId,webLink", wr = {
|
|
3046
3093
|
snapshot: {
|
|
3047
3094
|
configSchema: {
|
|
3048
3095
|
additionalProperties: !1,
|
|
3049
3096
|
description: "Configuration for outlook.on_message_received. Every configured matching field must match.",
|
|
3050
3097
|
properties: {
|
|
3051
3098
|
folder: {
|
|
3052
|
-
default:
|
|
3099
|
+
default: yr,
|
|
3053
3100
|
description: "A well-known mail folder name, folder ID, or an empty string for the whole mailbox.",
|
|
3054
3101
|
pattern: "^[A-Za-z0-9_=-]*$",
|
|
3055
3102
|
type: "string"
|
|
@@ -3059,7 +3106,7 @@ var gr = "inbox", _r = 25, vr = 100, yr = "1970-01-01T00:00:00Z", br = "id,inter
|
|
|
3059
3106
|
type: "boolean"
|
|
3060
3107
|
},
|
|
3061
3108
|
maxMessagesPerPoll: {
|
|
3062
|
-
default:
|
|
3109
|
+
default: br,
|
|
3063
3110
|
maximum: 100,
|
|
3064
3111
|
minimum: 1,
|
|
3065
3112
|
type: "integer"
|
|
@@ -3155,19 +3202,19 @@ var gr = "inbox", _r = 25, vr = 100, yr = "1970-01-01T00:00:00Z", br = "id,inter
|
|
|
3155
3202
|
type: "poll"
|
|
3156
3203
|
},
|
|
3157
3204
|
async poll(t) {
|
|
3158
|
-
let n =
|
|
3205
|
+
let n = Tr(t.config);
|
|
3159
3206
|
if (t.checkpoint === null) return {
|
|
3160
|
-
checkpoint: await
|
|
3207
|
+
checkpoint: await Er(t, n),
|
|
3161
3208
|
events: []
|
|
3162
3209
|
};
|
|
3163
|
-
let r =
|
|
3164
|
-
$filter:
|
|
3210
|
+
let r = Dr(t.checkpoint), i = await Mr(t, Or(n.folder), {
|
|
3211
|
+
$filter: kr(n, r.lastReceivedDateTime),
|
|
3165
3212
|
$orderby: "receivedDateTime asc",
|
|
3166
|
-
$select:
|
|
3213
|
+
$select: Cr,
|
|
3167
3214
|
$top: n.maxMessagesPerPoll
|
|
3168
3215
|
});
|
|
3169
|
-
|
|
3170
|
-
let a =
|
|
3216
|
+
Nr(i, "message list");
|
|
3217
|
+
let a = Fr(i.data);
|
|
3171
3218
|
if (a.length == 0) return {
|
|
3172
3219
|
checkpoint: r,
|
|
3173
3220
|
events: []
|
|
@@ -3179,54 +3226,54 @@ var gr = "inbox", _r = 25, vr = 100, yr = "1970-01-01T00:00:00Z", br = "id,inter
|
|
|
3179
3226
|
}
|
|
3180
3227
|
let l = s > o, u = new Set(r.boundaryMessageIds), d = a.length >= n.maxMessagesPerPoll;
|
|
3181
3228
|
if (d && !l && a.every((e) => typeof e.id == "string" && u.has(e.id))) throw new e("Outlook cursor is stuck on a full timestamp boundary; increase maxMessagesPerPoll and resume the Trigger.");
|
|
3182
|
-
let f = new Set(l ? [] : r.boundaryMessageIds), p = [],
|
|
3229
|
+
let f = new Set(l ? [] : r.boundaryMessageIds), p = [], ee = 0;
|
|
3183
3230
|
for (let e of a) if (e.id != null && e.id.length != 0 && (z(e.receivedDateTime) == s && f.add(e.id), !u.has(e.id))) {
|
|
3184
|
-
if (!
|
|
3185
|
-
|
|
3231
|
+
if (!Ar(e, n)) {
|
|
3232
|
+
ee += 1;
|
|
3186
3233
|
continue;
|
|
3187
3234
|
}
|
|
3188
|
-
p.push(
|
|
3235
|
+
p.push(jr(e, e.id));
|
|
3189
3236
|
}
|
|
3190
|
-
let
|
|
3237
|
+
let te = d && (l || p.length > 0);
|
|
3191
3238
|
return {
|
|
3192
3239
|
checkpoint: {
|
|
3193
3240
|
boundaryMessageIds: [...f],
|
|
3194
3241
|
lastReceivedDateTime: c
|
|
3195
3242
|
},
|
|
3196
3243
|
events: p,
|
|
3197
|
-
filtered:
|
|
3198
|
-
...
|
|
3244
|
+
filtered: ee,
|
|
3245
|
+
...te ? { hasMore: !0 } : {}
|
|
3199
3246
|
};
|
|
3200
3247
|
}
|
|
3201
3248
|
};
|
|
3202
|
-
function
|
|
3249
|
+
function Tr(e) {
|
|
3203
3250
|
return {
|
|
3204
|
-
folder: e.folder ??
|
|
3251
|
+
folder: e.folder ?? yr,
|
|
3205
3252
|
includeDrafts: e.includeDrafts ?? !1,
|
|
3206
|
-
maxMessagesPerPoll: e.maxMessagesPerPoll ??
|
|
3253
|
+
maxMessagesPerPoll: e.maxMessagesPerPoll ?? br,
|
|
3207
3254
|
readStatus: e.readStatus ?? "All",
|
|
3208
3255
|
senderAddress: (e.senderAddress ?? "").trim(),
|
|
3209
3256
|
subjectContains: (e.subjectContains ?? "").trim(),
|
|
3210
3257
|
withAttachmentsOnly: e.withAttachmentsOnly ?? !1
|
|
3211
3258
|
};
|
|
3212
3259
|
}
|
|
3213
|
-
async function
|
|
3214
|
-
let n = await
|
|
3260
|
+
async function Er(e, t) {
|
|
3261
|
+
let n = await Mr(e, Or(t.folder), {
|
|
3215
3262
|
$orderby: "receivedDateTime desc",
|
|
3216
3263
|
$select: "id,receivedDateTime",
|
|
3217
|
-
$top:
|
|
3264
|
+
$top: xr
|
|
3218
3265
|
});
|
|
3219
|
-
|
|
3220
|
-
$filter:
|
|
3266
|
+
Nr(n, "seed marker fetch"), Nr(await Mr(e, Or(t.folder), {
|
|
3267
|
+
$filter: kr(t, Sr),
|
|
3221
3268
|
$orderby: "receivedDateTime desc",
|
|
3222
3269
|
$top: 1
|
|
3223
3270
|
}), "seed filter shape check");
|
|
3224
|
-
let r =
|
|
3271
|
+
let r = Ir(Fr(n.data));
|
|
3225
3272
|
if (r == null) return {
|
|
3226
3273
|
boundaryMessageIds: [],
|
|
3227
3274
|
lastReceivedDateTime: e.now.toISOString()
|
|
3228
3275
|
};
|
|
3229
|
-
let i =
|
|
3276
|
+
let i = Fr(n.data).filter((e) => z(e.receivedDateTime) == r.ms);
|
|
3230
3277
|
return i.length >= t.maxMessagesPerPoll ? {
|
|
3231
3278
|
boundaryMessageIds: [],
|
|
3232
3279
|
lastReceivedDateTime: new Date(r.ms + 1e3).toISOString()
|
|
@@ -3235,7 +3282,7 @@ async function Cr(e, t) {
|
|
|
3235
3282
|
lastReceivedDateTime: r.iso
|
|
3236
3283
|
};
|
|
3237
3284
|
}
|
|
3238
|
-
function
|
|
3285
|
+
function Dr(t) {
|
|
3239
3286
|
let n = B(t), r = n?.lastReceivedDateTime;
|
|
3240
3287
|
if (typeof r != "string" || z(r) == null) throw new e("Outlook checkpoint is invalid; recreate the Trigger.");
|
|
3241
3288
|
let i = n?.boundaryMessageIds;
|
|
@@ -3244,17 +3291,17 @@ function wr(t) {
|
|
|
3244
3291
|
lastReceivedDateTime: r
|
|
3245
3292
|
};
|
|
3246
3293
|
}
|
|
3247
|
-
function
|
|
3294
|
+
function Or(e) {
|
|
3248
3295
|
return e.length == 0 ? "/me/messages" : `/me/mailFolders/${encodeURIComponent(e)}/messages`;
|
|
3249
3296
|
}
|
|
3250
|
-
function
|
|
3297
|
+
function kr(e, t) {
|
|
3251
3298
|
let n = [`receivedDateTime ge ${t}`];
|
|
3252
3299
|
return e.readStatus == "Unread" && n.push("isRead eq false"), e.readStatus == "Read" && n.push("isRead eq true"), e.withAttachmentsOnly && n.push("hasAttachments eq true"), e.senderAddress.length > 0 && n.push(`from/emailAddress/address eq '${e.senderAddress.replaceAll("'", "''")}'`), n.join(" and ");
|
|
3253
3300
|
}
|
|
3254
|
-
function
|
|
3301
|
+
function Ar(e, t) {
|
|
3255
3302
|
return e.isDraft === !0 && !t.includeDrafts ? !1 : t.subjectContains.length == 0 || (e.subject ?? "").toLowerCase().includes(t.subjectContains.toLowerCase());
|
|
3256
3303
|
}
|
|
3257
|
-
function
|
|
3304
|
+
function jr(e, t) {
|
|
3258
3305
|
return {
|
|
3259
3306
|
dedupeKey: t,
|
|
3260
3307
|
payload: {
|
|
@@ -3277,7 +3324,7 @@ function Or(e, t) {
|
|
|
3277
3324
|
}
|
|
3278
3325
|
};
|
|
3279
3326
|
}
|
|
3280
|
-
async function
|
|
3327
|
+
async function Mr(e, t, r) {
|
|
3281
3328
|
try {
|
|
3282
3329
|
return await e.connector.execute({
|
|
3283
3330
|
endpoint: t,
|
|
@@ -3289,12 +3336,12 @@ async function kr(e, t, r) {
|
|
|
3289
3336
|
throw new n(`Outlook proxy request to ${t} failed.`, { cause: e });
|
|
3290
3337
|
}
|
|
3291
3338
|
}
|
|
3292
|
-
function
|
|
3339
|
+
function Nr(r, i) {
|
|
3293
3340
|
if (r.status >= 200 && r.status < 300) return;
|
|
3294
|
-
let a =
|
|
3341
|
+
let a = Pr(r.data);
|
|
3295
3342
|
throw r.status == 401 ? new t(`Outlook ${i} rejected the Connection.`) : r.status == 403 && a.has("mailboxnotenabledforrestapi") ? new e("The Outlook mailbox is not reachable through the Graph mail APIs.") : r.status == 403 && (a.has("accessdenied") || a.has("erroraccessdenied")) ? new t(`Outlook ${i} rejected the Connection.`) : r.status == 404 && (a.has("erroritemnotfound") || a.has("itemnotfound")) ? new e("The configured Outlook folder does not exist.") : r.status == 400 && (a.has("errorinvalididmalformed") || a.has("inefficientfilter")) ? new e("Outlook rejected the configured folder or filters.") : new n(`Outlook ${i} failed with status ${r.status}.`);
|
|
3296
3343
|
}
|
|
3297
|
-
function
|
|
3344
|
+
function Pr(e) {
|
|
3298
3345
|
let t = /* @__PURE__ */ new Set(), n = B(e)?.error;
|
|
3299
3346
|
for (let e = 0; e < 4; e += 1) {
|
|
3300
3347
|
let e = B(n);
|
|
@@ -3303,11 +3350,11 @@ function jr(e) {
|
|
|
3303
3350
|
}
|
|
3304
3351
|
return t;
|
|
3305
3352
|
}
|
|
3306
|
-
function
|
|
3353
|
+
function Fr(e) {
|
|
3307
3354
|
let t = B(e)?.value;
|
|
3308
3355
|
return Array.isArray(t) ? t : [];
|
|
3309
3356
|
}
|
|
3310
|
-
function
|
|
3357
|
+
function Ir(e) {
|
|
3311
3358
|
let t = null;
|
|
3312
3359
|
for (let n of e) {
|
|
3313
3360
|
let e = z(n.receivedDateTime);
|
|
@@ -3326,7 +3373,7 @@ function z(e) {
|
|
|
3326
3373
|
function B(e) {
|
|
3327
3374
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
3328
3375
|
}
|
|
3329
|
-
var
|
|
3376
|
+
var Lr = {
|
|
3330
3377
|
initialState: {
|
|
3331
3378
|
checkpoint: null,
|
|
3332
3379
|
subscription: {}
|
|
@@ -3389,7 +3436,7 @@ var Pr = {
|
|
|
3389
3436
|
type: "integration"
|
|
3390
3437
|
},
|
|
3391
3438
|
receive(e) {
|
|
3392
|
-
if (!
|
|
3439
|
+
if (!me(e.query("open_flow_callback"), e.callbackSecret)) return {
|
|
3393
3440
|
body: "",
|
|
3394
3441
|
contentType: "text/plain",
|
|
3395
3442
|
outcome: "respond",
|
|
@@ -3400,7 +3447,7 @@ var Pr = {
|
|
|
3400
3447
|
outcome: "ignored",
|
|
3401
3448
|
reason: "Shopify topic header is missing."
|
|
3402
3449
|
};
|
|
3403
|
-
if (!
|
|
3450
|
+
if (!Rr(e.config).includes(t)) return {
|
|
3404
3451
|
outcome: "ignored",
|
|
3405
3452
|
reason: "Shopify topic is not subscribed."
|
|
3406
3453
|
};
|
|
@@ -3420,39 +3467,39 @@ var Pr = {
|
|
|
3420
3467
|
};
|
|
3421
3468
|
},
|
|
3422
3469
|
async reconcile(e) {
|
|
3423
|
-
let t =
|
|
3470
|
+
let t = Kr(e.state), n = await Br(e);
|
|
3424
3471
|
if (n == null) {
|
|
3425
3472
|
if (!e.active) return { outcome: "ready" };
|
|
3426
3473
|
throw new i("The Shopify store or webhook resource is unavailable.");
|
|
3427
3474
|
}
|
|
3428
3475
|
if (!e.active) {
|
|
3429
|
-
for (let t of n.values()) await
|
|
3430
|
-
return await t.saveSubscription({},
|
|
3476
|
+
for (let t of n.values()) await Hr(e, t);
|
|
3477
|
+
return await t.saveSubscription({}, qr(e.now)), { outcome: "ready" };
|
|
3431
3478
|
}
|
|
3432
|
-
let r =
|
|
3479
|
+
let r = Rr(e.config), a = [], o = [];
|
|
3433
3480
|
try {
|
|
3434
3481
|
for (let t of r) {
|
|
3435
3482
|
let r = n.get(t);
|
|
3436
3483
|
if (r != null) a.push(r);
|
|
3437
3484
|
else {
|
|
3438
|
-
let n = await
|
|
3485
|
+
let n = await zr(e, t);
|
|
3439
3486
|
a.push(n.id), n.created && o.push(n.id);
|
|
3440
3487
|
}
|
|
3441
3488
|
}
|
|
3442
3489
|
} catch (t) {
|
|
3443
|
-
throw await Promise.allSettled(o.map((t) =>
|
|
3490
|
+
throw await Promise.allSettled(o.map((t) => Hr(e, t))), t;
|
|
3444
3491
|
}
|
|
3445
|
-
for (let [t, i] of n) r.includes(t) || await
|
|
3446
|
-
return await t.saveSubscription({ webhookIds: a },
|
|
3492
|
+
for (let [t, i] of n) r.includes(t) || await Hr(e, i);
|
|
3493
|
+
return await t.saveSubscription({ webhookIds: a }, qr(e.now)), { outcome: "ready" };
|
|
3447
3494
|
}
|
|
3448
3495
|
};
|
|
3449
|
-
function
|
|
3496
|
+
function Rr(e) {
|
|
3450
3497
|
return [...new Set(e.topics)];
|
|
3451
3498
|
}
|
|
3452
|
-
async function
|
|
3453
|
-
let n = await
|
|
3499
|
+
async function zr(e, t) {
|
|
3500
|
+
let n = await Ur(e, "subscription create", {
|
|
3454
3501
|
body: { webhook: {
|
|
3455
|
-
address:
|
|
3502
|
+
address: Vr(e),
|
|
3456
3503
|
format: "json",
|
|
3457
3504
|
topic: t
|
|
3458
3505
|
} },
|
|
@@ -3460,22 +3507,22 @@ async function Ir(e, t) {
|
|
|
3460
3507
|
method: "POST"
|
|
3461
3508
|
});
|
|
3462
3509
|
if (n.status == 422) {
|
|
3463
|
-
let n = (await
|
|
3510
|
+
let n = (await Br(e))?.get(t);
|
|
3464
3511
|
if (n != null) return {
|
|
3465
3512
|
created: !1,
|
|
3466
3513
|
id: n
|
|
3467
3514
|
};
|
|
3468
3515
|
}
|
|
3469
|
-
|
|
3470
|
-
let r =
|
|
3516
|
+
Wr(n, "subscription create");
|
|
3517
|
+
let r = Gr(V(V(n.data)?.webhook)?.id);
|
|
3471
3518
|
if (r == null) throw new a("Shopify subscription response is missing its ID.");
|
|
3472
3519
|
return {
|
|
3473
3520
|
created: !0,
|
|
3474
3521
|
id: r
|
|
3475
3522
|
};
|
|
3476
3523
|
}
|
|
3477
|
-
async function
|
|
3478
|
-
let t =
|
|
3524
|
+
async function Br(e) {
|
|
3525
|
+
let t = Vr(e), n = await Ur(e, "subscription list", {
|
|
3479
3526
|
endpoint: "/webhooks.json",
|
|
3480
3527
|
method: "GET",
|
|
3481
3528
|
query: {
|
|
@@ -3484,34 +3531,34 @@ async function Lr(e) {
|
|
|
3484
3531
|
}
|
|
3485
3532
|
});
|
|
3486
3533
|
if (n.status == 404) return null;
|
|
3487
|
-
|
|
3534
|
+
Wr(n, "subscription list");
|
|
3488
3535
|
let r = V(n.data)?.webhooks, i = /* @__PURE__ */ new Map();
|
|
3489
3536
|
if (!Array.isArray(r)) return i;
|
|
3490
3537
|
for (let e of r) {
|
|
3491
|
-
let n = V(e), r =
|
|
3538
|
+
let n = V(e), r = Gr(n?.id);
|
|
3492
3539
|
n?.address === t && typeof n.topic == "string" && r != null && i.set(n.topic, r);
|
|
3493
3540
|
}
|
|
3494
3541
|
return i;
|
|
3495
3542
|
}
|
|
3496
|
-
function
|
|
3543
|
+
function Vr(e) {
|
|
3497
3544
|
let t = new URL(e.endpointUrl);
|
|
3498
3545
|
return t.searchParams.set("open_flow_callback", e.callbackSecret), t.href;
|
|
3499
3546
|
}
|
|
3500
|
-
async function
|
|
3501
|
-
let n = await
|
|
3547
|
+
async function Hr(e, t) {
|
|
3548
|
+
let n = await Ur(e, "subscription delete", {
|
|
3502
3549
|
endpoint: `/webhooks/${encodeURIComponent(t)}.json`,
|
|
3503
3550
|
method: "DELETE"
|
|
3504
3551
|
});
|
|
3505
|
-
n.status != 404 &&
|
|
3552
|
+
n.status != 404 && Wr(n, "subscription delete");
|
|
3506
3553
|
}
|
|
3507
|
-
async function
|
|
3554
|
+
async function Ur(e, t, n) {
|
|
3508
3555
|
try {
|
|
3509
3556
|
return await e.connector.execute(n, e.signal);
|
|
3510
3557
|
} catch (e) {
|
|
3511
3558
|
throw e instanceof r ? e : new a(`Shopify ${t} request failed.`, { cause: e });
|
|
3512
3559
|
}
|
|
3513
3560
|
}
|
|
3514
|
-
function
|
|
3561
|
+
function Wr(e, t) {
|
|
3515
3562
|
if (!(e.status >= 200 && e.status < 300)) throw e.status == 401 || e.status == 403 ? new r(`Shopify ${t} rejected the Connection.`) : [
|
|
3516
3563
|
402,
|
|
3517
3564
|
404,
|
|
@@ -3520,14 +3567,14 @@ function Vr(e, t) {
|
|
|
3520
3567
|
501
|
|
3521
3568
|
].includes(e.status) ? new i(`Shopify ${t} rejected the subscription.`) : new a(`Shopify ${t} failed with status ${e.status}.`);
|
|
3522
3569
|
}
|
|
3523
|
-
function
|
|
3570
|
+
function Gr(e) {
|
|
3524
3571
|
return typeof e == "string" ? e.trim().length == 0 ? null : e : typeof e == "number" && Number.isFinite(e) ? String(e) : null;
|
|
3525
3572
|
}
|
|
3526
|
-
function
|
|
3573
|
+
function Kr(e) {
|
|
3527
3574
|
if (e == null) throw new i("Shopify Integration state is missing.");
|
|
3528
3575
|
return e;
|
|
3529
3576
|
}
|
|
3530
|
-
function
|
|
3577
|
+
function qr(e) {
|
|
3531
3578
|
return new Date(e.getTime() + 2592e6);
|
|
3532
3579
|
}
|
|
3533
3580
|
function V(e) {
|
|
@@ -3535,19 +3582,19 @@ function V(e) {
|
|
|
3535
3582
|
}
|
|
3536
3583
|
//#endregion
|
|
3537
3584
|
//#region src/trigger/providers/slack/on-message-posted.ts
|
|
3538
|
-
var
|
|
3585
|
+
var Jr = 15, Yr = 6e4, Xr = /* @__PURE__ */ new Set([
|
|
3539
3586
|
"file_share",
|
|
3540
3587
|
"thread_broadcast",
|
|
3541
3588
|
"me_message",
|
|
3542
3589
|
"bot_message"
|
|
3543
|
-
]),
|
|
3590
|
+
]), Zr = /* @__PURE__ */ new Set([
|
|
3544
3591
|
"invalid_auth",
|
|
3545
3592
|
"not_authed",
|
|
3546
3593
|
"token_revoked",
|
|
3547
3594
|
"token_expired",
|
|
3548
3595
|
"account_inactive",
|
|
3549
3596
|
"two_factor_setup_required"
|
|
3550
|
-
]),
|
|
3597
|
+
]), Qr = /* @__PURE__ */ new Set([
|
|
3551
3598
|
"channel_not_found",
|
|
3552
3599
|
"not_in_channel",
|
|
3553
3600
|
"missing_scope",
|
|
@@ -3563,7 +3610,7 @@ var Gr = 15, Kr = 6e4, qr = /* @__PURE__ */ new Set([
|
|
|
3563
3610
|
"method_deprecated",
|
|
3564
3611
|
"deprecated_endpoint",
|
|
3565
3612
|
"accesslimited"
|
|
3566
|
-
]),
|
|
3613
|
+
]), $r = {
|
|
3567
3614
|
snapshot: {
|
|
3568
3615
|
configSchema: {
|
|
3569
3616
|
additionalProperties: !1,
|
|
@@ -3603,7 +3650,7 @@ var Gr = 15, Kr = 6e4, qr = /* @__PURE__ */ new Set([
|
|
|
3603
3650
|
type: "boolean"
|
|
3604
3651
|
},
|
|
3605
3652
|
maxMessagesPerPoll: {
|
|
3606
|
-
default:
|
|
3653
|
+
default: Jr,
|
|
3607
3654
|
description: "Maximum number of messages processed per poll.",
|
|
3608
3655
|
maximum: 100,
|
|
3609
3656
|
minimum: 1,
|
|
@@ -3677,47 +3724,47 @@ var Gr = 15, Kr = 6e4, qr = /* @__PURE__ */ new Set([
|
|
|
3677
3724
|
type: "poll"
|
|
3678
3725
|
},
|
|
3679
3726
|
async poll(e) {
|
|
3680
|
-
let t =
|
|
3727
|
+
let t = ei(e.config);
|
|
3681
3728
|
if (e.checkpoint === null) return {
|
|
3682
|
-
checkpoint: { lastTs: await
|
|
3729
|
+
checkpoint: { lastTs: await ti(e, t.channelId) },
|
|
3683
3730
|
events: []
|
|
3684
3731
|
};
|
|
3685
|
-
let n =
|
|
3732
|
+
let n = ni(e.checkpoint), r = await ri(e, t, n), i = oi(r), a = [], o = 0;
|
|
3686
3733
|
for (let e of i.toReversed()) {
|
|
3687
|
-
if (!
|
|
3734
|
+
if (!ci(e.message, t)) {
|
|
3688
3735
|
o += 1;
|
|
3689
3736
|
continue;
|
|
3690
3737
|
}
|
|
3691
|
-
a.push(
|
|
3738
|
+
a.push(li(e, t.channelId));
|
|
3692
3739
|
}
|
|
3693
3740
|
return {
|
|
3694
|
-
checkpoint:
|
|
3741
|
+
checkpoint: si(n, r, i),
|
|
3695
3742
|
events: a,
|
|
3696
3743
|
filtered: o
|
|
3697
3744
|
};
|
|
3698
3745
|
}
|
|
3699
3746
|
};
|
|
3700
|
-
function
|
|
3747
|
+
function ei(e) {
|
|
3701
3748
|
return {
|
|
3702
3749
|
channelId: e.channelId,
|
|
3703
3750
|
fromUserIds: e.fromUserIds ?? [],
|
|
3704
3751
|
ignoreUserIds: e.ignoreUserIds ?? [],
|
|
3705
3752
|
includeBotMessages: e.includeBotMessages ?? !1,
|
|
3706
3753
|
includeSystemMessages: e.includeSystemMessages ?? !1,
|
|
3707
|
-
maxMessagesPerPoll: e.maxMessagesPerPoll ??
|
|
3754
|
+
maxMessagesPerPoll: e.maxMessagesPerPoll ?? Jr,
|
|
3708
3755
|
textContains: e.textContains ?? ""
|
|
3709
3756
|
};
|
|
3710
3757
|
}
|
|
3711
|
-
async function
|
|
3712
|
-
let n = await
|
|
3758
|
+
async function ti(e, t) {
|
|
3759
|
+
let n = await ii(e, {
|
|
3713
3760
|
channel: t,
|
|
3714
3761
|
limit: 1
|
|
3715
3762
|
});
|
|
3716
|
-
|
|
3763
|
+
ai(n, "baseline history fetch");
|
|
3717
3764
|
let r = n.data.messages?.[0]?.ts;
|
|
3718
|
-
return r != null &&
|
|
3765
|
+
return r != null && ui(r) ? r : `${Math.floor((e.now.getTime() - Yr) / 1e3)}.000000`;
|
|
3719
3766
|
}
|
|
3720
|
-
function
|
|
3767
|
+
function ni(t) {
|
|
3721
3768
|
let n = t;
|
|
3722
3769
|
if (typeof n.lastTs != "string" || n.lastTs.length == 0) throw new e("Slack checkpoint lastTs is missing.");
|
|
3723
3770
|
let r = n.drainLatest, i = n.pendingHighTs;
|
|
@@ -3729,17 +3776,17 @@ function $r(t) {
|
|
|
3729
3776
|
pendingHighTs: i
|
|
3730
3777
|
};
|
|
3731
3778
|
}
|
|
3732
|
-
async function
|
|
3733
|
-
let r = await
|
|
3779
|
+
async function ri(e, t, n) {
|
|
3780
|
+
let r = await ii(e, {
|
|
3734
3781
|
channel: t.channelId,
|
|
3735
3782
|
inclusive: "false",
|
|
3736
3783
|
latest: n.drainLatest,
|
|
3737
3784
|
limit: t.maxMessagesPerPoll,
|
|
3738
3785
|
oldest: n.lastTs
|
|
3739
3786
|
});
|
|
3740
|
-
return
|
|
3787
|
+
return ai(r, "history list"), r.data;
|
|
3741
3788
|
}
|
|
3742
|
-
async function
|
|
3789
|
+
async function ii(e, t) {
|
|
3743
3790
|
try {
|
|
3744
3791
|
return await e.connector.execute({
|
|
3745
3792
|
endpoint: "/conversations.history",
|
|
@@ -3750,19 +3797,19 @@ async function ti(e, t) {
|
|
|
3750
3797
|
throw new n("Slack proxy request failed.", { cause: e });
|
|
3751
3798
|
}
|
|
3752
3799
|
}
|
|
3753
|
-
function
|
|
3800
|
+
function ai(r, i) {
|
|
3754
3801
|
let a = r.data;
|
|
3755
3802
|
if (r.status >= 200 && r.status < 300 && a.ok === !0) return;
|
|
3756
3803
|
let o = typeof a.error == "string" ? a.error : "";
|
|
3757
|
-
throw
|
|
3804
|
+
throw Zr.has(o) ? new t(`Slack ${i} rejected with ${o}.`) : Qr.has(o) ? new e(`Slack ${i} rejected with ${o}.`) : new n(`Slack ${i} failed with ${o || `status ${r.status}`}.`);
|
|
3758
3805
|
}
|
|
3759
|
-
function
|
|
3760
|
-
return (e.messages ?? []).flatMap((e) => e.ts != null &&
|
|
3806
|
+
function oi(e) {
|
|
3807
|
+
return (e.messages ?? []).flatMap((e) => e.ts != null && ui(e.ts) ? [{
|
|
3761
3808
|
message: e,
|
|
3762
3809
|
ts: e.ts
|
|
3763
3810
|
}] : []);
|
|
3764
3811
|
}
|
|
3765
|
-
function
|
|
3812
|
+
function si(e, t, r) {
|
|
3766
3813
|
let i = r[0]?.ts, a = r.at(-1)?.ts;
|
|
3767
3814
|
if (t.has_more === !0) {
|
|
3768
3815
|
if (i == null || a == null) throw new n("Slack history reports has_more without a usable timestamp.");
|
|
@@ -3774,10 +3821,10 @@ function ii(e, t, r) {
|
|
|
3774
3821
|
}
|
|
3775
3822
|
return e.pendingHighTs == null ? { lastTs: i ?? e.lastTs } : { lastTs: e.pendingHighTs };
|
|
3776
3823
|
}
|
|
3777
|
-
function
|
|
3778
|
-
return !t.includeBotMessages && (e.bot_id != null || e.subtype == "bot_message") || !t.includeSystemMessages && e.subtype != null && !
|
|
3824
|
+
function ci(e, t) {
|
|
3825
|
+
return !t.includeBotMessages && (e.bot_id != null || e.subtype == "bot_message") || !t.includeSystemMessages && e.subtype != null && !Xr.has(e.subtype) || t.fromUserIds.length > 0 && (e.user == null || !t.fromUserIds.includes(e.user)) || e.user != null && t.ignoreUserIds.includes(e.user) ? !1 : t.textContains.length == 0 || (e.text ?? "").toLowerCase().includes(t.textContains.toLowerCase());
|
|
3779
3826
|
}
|
|
3780
|
-
function
|
|
3827
|
+
function li(e, t) {
|
|
3781
3828
|
return {
|
|
3782
3829
|
dedupeKey: `${t}:${e.ts}`,
|
|
3783
3830
|
payload: {
|
|
@@ -3796,12 +3843,12 @@ function oi(e, t) {
|
|
|
3796
3843
|
}
|
|
3797
3844
|
};
|
|
3798
3845
|
}
|
|
3799
|
-
function
|
|
3846
|
+
function ui(e) {
|
|
3800
3847
|
return /^\d+(?:\.\d+)?$/.test(e) && !Number.isNaN(new Date(Math.round(Number(e) * 1e3)).getTime());
|
|
3801
3848
|
}
|
|
3802
3849
|
//#endregion
|
|
3803
3850
|
//#region src/trigger/providers/stripe/on-event.ts
|
|
3804
|
-
var
|
|
3851
|
+
var di = 300, H = "/v1/webhook_endpoints", fi = { "Content-Type": "application/x-www-form-urlencoded" }, pi = {
|
|
3805
3852
|
initialState: {
|
|
3806
3853
|
checkpoint: null,
|
|
3807
3854
|
subscription: {}
|
|
@@ -3869,8 +3916,8 @@ var ci = 300, H = "/v1/webhook_endpoints", li = { "Content-Type": "application/x
|
|
|
3869
3916
|
type: "integration"
|
|
3870
3917
|
},
|
|
3871
3918
|
async receive(e) {
|
|
3872
|
-
let t =
|
|
3873
|
-
if (t == null || !await
|
|
3919
|
+
let t = xi(e.state);
|
|
3920
|
+
if (t == null || !await Si(e.header("stripe-signature"), t, e.rawBody, e.now)) return {
|
|
3874
3921
|
body: "",
|
|
3875
3922
|
contentType: "text/plain",
|
|
3876
3923
|
outcome: "respond",
|
|
@@ -3885,7 +3932,7 @@ var ci = 300, H = "/v1/webhook_endpoints", li = { "Content-Type": "application/x
|
|
|
3885
3932
|
outcome: "ignored",
|
|
3886
3933
|
reason: "Stripe event identity is missing."
|
|
3887
3934
|
};
|
|
3888
|
-
let a =
|
|
3935
|
+
let a = mi(e.config);
|
|
3889
3936
|
return !a.events.includes("*") && !a.events.includes(r) ? {
|
|
3890
3937
|
outcome: "ignored",
|
|
3891
3938
|
reason: "Stripe event is not subscribed."
|
|
@@ -3901,18 +3948,18 @@ var ci = 300, H = "/v1/webhook_endpoints", li = { "Content-Type": "application/x
|
|
|
3901
3948
|
};
|
|
3902
3949
|
},
|
|
3903
3950
|
async reconcile(e) {
|
|
3904
|
-
let t =
|
|
3951
|
+
let t = yi(e.state), n = mi(e.config), r = bi(t), i = xi(t);
|
|
3905
3952
|
if (!e.active) {
|
|
3906
|
-
if (r ??= await
|
|
3953
|
+
if (r ??= await _i(e), r != null) {
|
|
3907
3954
|
let t = await U(e, "endpoint delete", {
|
|
3908
3955
|
endpoint: `${H}/${r}`,
|
|
3909
3956
|
method: "DELETE"
|
|
3910
3957
|
});
|
|
3911
3958
|
t.status != 404 && W(t, "endpoint delete");
|
|
3912
3959
|
}
|
|
3913
|
-
return await t.saveSubscription({},
|
|
3960
|
+
return await t.saveSubscription({}, Ci(e.now)), { outcome: "ready" };
|
|
3914
3961
|
}
|
|
3915
|
-
if (r ??= await
|
|
3962
|
+
if (r ??= await _i(e), r != null && i == null) {
|
|
3916
3963
|
let t = await U(e, "endpoint delete", {
|
|
3917
3964
|
endpoint: `${H}/${r}`,
|
|
3918
3965
|
method: "DELETE"
|
|
@@ -3921,55 +3968,55 @@ var ci = 300, H = "/v1/webhook_endpoints", li = { "Content-Type": "application/x
|
|
|
3921
3968
|
}
|
|
3922
3969
|
if (r == null) {
|
|
3923
3970
|
let t = await U(e, "endpoint create", {
|
|
3924
|
-
body:
|
|
3971
|
+
body: hi(e.endpointUrl, n),
|
|
3925
3972
|
endpoint: H,
|
|
3926
3973
|
headers: {
|
|
3927
|
-
...
|
|
3974
|
+
...fi,
|
|
3928
3975
|
"Idempotency-Key": e.idempotencyKey
|
|
3929
3976
|
},
|
|
3930
3977
|
method: "POST"
|
|
3931
3978
|
});
|
|
3932
3979
|
W(t, "endpoint create");
|
|
3933
|
-
let a =
|
|
3980
|
+
let a = vi(t.data);
|
|
3934
3981
|
r = a.id, i = a.secret;
|
|
3935
3982
|
}
|
|
3936
3983
|
let a = await U(e, "endpoint update", {
|
|
3937
|
-
body:
|
|
3984
|
+
body: gi([
|
|
3938
3985
|
...n.events.map((e, t) => [`enabled_events[${t}]`, e]),
|
|
3939
3986
|
["disabled", "false"],
|
|
3940
3987
|
["description", "Managed by Open Flow."]
|
|
3941
3988
|
]),
|
|
3942
3989
|
endpoint: `${H}/${r}`,
|
|
3943
|
-
headers:
|
|
3990
|
+
headers: fi,
|
|
3944
3991
|
method: "POST"
|
|
3945
3992
|
});
|
|
3946
3993
|
return a.status == 404 ? (await t.saveSubscription({}, e.now), { outcome: "pending" }) : (W(a, "endpoint update"), await t.saveSubscription({
|
|
3947
3994
|
endpointId: r,
|
|
3948
3995
|
signingSecret: i
|
|
3949
|
-
},
|
|
3996
|
+
}, Ci(e.now)), { outcome: "ready" });
|
|
3950
3997
|
}
|
|
3951
3998
|
};
|
|
3952
|
-
function
|
|
3999
|
+
function mi(e) {
|
|
3953
4000
|
return {
|
|
3954
4001
|
apiVersion: e.apiVersion ?? "",
|
|
3955
4002
|
events: [...new Set(e.events)],
|
|
3956
4003
|
includeConnectedAccounts: e.includeConnectedAccounts ?? !1
|
|
3957
4004
|
};
|
|
3958
4005
|
}
|
|
3959
|
-
function
|
|
4006
|
+
function hi(e, t) {
|
|
3960
4007
|
let n = [
|
|
3961
4008
|
["url", e],
|
|
3962
4009
|
...t.events.map((e, t) => [`enabled_events[${t}]`, e]),
|
|
3963
4010
|
["description", "Managed by Open Flow."]
|
|
3964
4011
|
];
|
|
3965
|
-
return t.includeConnectedAccounts && n.push(["connect", "true"]), t.apiVersion.length > 0 && n.push(["api_version", t.apiVersion]),
|
|
4012
|
+
return t.includeConnectedAccounts && n.push(["connect", "true"]), t.apiVersion.length > 0 && n.push(["api_version", t.apiVersion]), gi(n);
|
|
3966
4013
|
}
|
|
3967
|
-
function
|
|
4014
|
+
function gi(e) {
|
|
3968
4015
|
let t = new URLSearchParams();
|
|
3969
4016
|
for (let [n, r] of e) t.append(n, r);
|
|
3970
4017
|
return t.toString();
|
|
3971
4018
|
}
|
|
3972
|
-
async function
|
|
4019
|
+
async function _i(e) {
|
|
3973
4020
|
let t;
|
|
3974
4021
|
for (let n = 0; n < 10; n += 1) {
|
|
3975
4022
|
let n = await U(e, "endpoint list", {
|
|
@@ -4009,7 +4056,7 @@ function W(e, t) {
|
|
|
4009
4056
|
throw new a(`Stripe ${t} failed with status ${e.status}.`);
|
|
4010
4057
|
}
|
|
4011
4058
|
}
|
|
4012
|
-
function
|
|
4059
|
+
function vi(e) {
|
|
4013
4060
|
let t = G(e);
|
|
4014
4061
|
if (typeof t?.id != "string" || typeof t.secret != "string" || t.secret.length == 0) throw new a("Stripe endpoint response is missing its ID or signing secret.");
|
|
4015
4062
|
return {
|
|
@@ -4017,28 +4064,28 @@ function hi(e) {
|
|
|
4017
4064
|
secret: t.secret
|
|
4018
4065
|
};
|
|
4019
4066
|
}
|
|
4020
|
-
function
|
|
4067
|
+
function yi(e) {
|
|
4021
4068
|
if (e == null) throw new i("Stripe Integration state is missing.");
|
|
4022
4069
|
return e;
|
|
4023
4070
|
}
|
|
4024
|
-
function
|
|
4071
|
+
function bi(e) {
|
|
4025
4072
|
let t = e.subscription.endpointId;
|
|
4026
4073
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
4027
4074
|
}
|
|
4028
|
-
function
|
|
4075
|
+
function xi(e) {
|
|
4029
4076
|
let t = e?.subscription.signingSecret;
|
|
4030
4077
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
4031
4078
|
}
|
|
4032
|
-
async function
|
|
4079
|
+
async function Si(e, t, n, r) {
|
|
4033
4080
|
if (e == null) return !1;
|
|
4034
4081
|
let i = e.split(",").map((e) => e.trim().split("=", 2)), a = i.find(([e]) => e == "t")?.[1];
|
|
4035
4082
|
if (a == null || !/^\d+$/.test(a)) return !1;
|
|
4036
4083
|
let o = Number(a);
|
|
4037
|
-
if (!Number.isSafeInteger(o) || Math.abs(Math.floor(r.getTime() / 1e3) - o) >
|
|
4038
|
-
let s = i.filter(([e, t]) => e == "v1" && t != null).map(([, e]) => e), c = [
|
|
4039
|
-
return (await Promise.all(s.map((e) =>
|
|
4084
|
+
if (!Number.isSafeInteger(o) || Math.abs(Math.floor(r.getTime() / 1e3) - o) > di) return !1;
|
|
4085
|
+
let s = i.filter(([e, t]) => e == "v1" && t != null).map(([, e]) => e), c = [pe(`${a}.`), n];
|
|
4086
|
+
return (await Promise.all(s.map((e) => ge(t, c, e)))).some(Boolean);
|
|
4040
4087
|
}
|
|
4041
|
-
function
|
|
4088
|
+
function Ci(e) {
|
|
4042
4089
|
return new Date(e.getTime() + 2592e6);
|
|
4043
4090
|
}
|
|
4044
4091
|
function G(e) {
|
|
@@ -4046,11 +4093,11 @@ function G(e) {
|
|
|
4046
4093
|
}
|
|
4047
4094
|
//#endregion
|
|
4048
4095
|
//#region src/trigger/providers/telegram/on-update.ts
|
|
4049
|
-
var
|
|
4096
|
+
var wi = /* @__PURE__ */ new Set([
|
|
4050
4097
|
"chat_member",
|
|
4051
4098
|
"message_reaction",
|
|
4052
4099
|
"message_reaction_count"
|
|
4053
|
-
]),
|
|
4100
|
+
]), Ti = /* @__PURE__ */ "*.message.edited_message.channel_post.edited_channel_post.business_connection.business_message.edited_business_message.deleted_business_messages.guest_message.message_reaction.message_reaction_count.inline_query.chosen_inline_result.callback_query.shipping_query.pre_checkout_query.purchased_paid_media.poll.poll_answer.my_chat_member.chat_member.chat_join_request.chat_boost.removed_chat_boost.managed_bot.subscription".split("."), Ei = Ti.filter((e) => e != "*" && !wi.has(e)), Di = {
|
|
4054
4101
|
snapshot: {
|
|
4055
4102
|
configSchema: {
|
|
4056
4103
|
additionalProperties: !1,
|
|
@@ -4074,7 +4121,7 @@ var xi = /* @__PURE__ */ new Set([
|
|
|
4074
4121
|
},
|
|
4075
4122
|
updates: {
|
|
4076
4123
|
description: "Telegram update types that trigger a Run. Use * for the Telegram default set.",
|
|
4077
|
-
items: { enum:
|
|
4124
|
+
items: { enum: Ti },
|
|
4078
4125
|
minItems: 1,
|
|
4079
4126
|
type: "array",
|
|
4080
4127
|
uniqueItems: !0
|
|
@@ -4128,7 +4175,7 @@ var xi = /* @__PURE__ */ new Set([
|
|
|
4128
4175
|
type: "integration"
|
|
4129
4176
|
},
|
|
4130
4177
|
receive(e) {
|
|
4131
|
-
if (!
|
|
4178
|
+
if (!Ai(e.header("x-telegram-bot-api-secret-token"), e.callbackSecret)) return {
|
|
4132
4179
|
body: "",
|
|
4133
4180
|
contentType: "text/plain",
|
|
4134
4181
|
outcome: "respond",
|
|
@@ -4143,21 +4190,21 @@ var xi = /* @__PURE__ */ new Set([
|
|
|
4143
4190
|
outcome: "ignored",
|
|
4144
4191
|
reason: "Telegram update body is missing."
|
|
4145
4192
|
};
|
|
4146
|
-
let n =
|
|
4147
|
-
if (!(
|
|
4193
|
+
let n = Oi(e.config);
|
|
4194
|
+
if (!(ki(n) ?? Ei).includes(t)) return {
|
|
4148
4195
|
outcome: "ignored",
|
|
4149
4196
|
reason: "Telegram update type is not subscribed."
|
|
4150
4197
|
};
|
|
4151
4198
|
let r = e.payload[t];
|
|
4152
4199
|
if (n.chatIds.length > 0) {
|
|
4153
|
-
let e =
|
|
4200
|
+
let e = ji(r);
|
|
4154
4201
|
if (e == null || !n.chatIds.includes(e)) return {
|
|
4155
4202
|
outcome: "ignored",
|
|
4156
4203
|
reason: "Telegram chat does not match."
|
|
4157
4204
|
};
|
|
4158
4205
|
}
|
|
4159
4206
|
if (n.userIds.length > 0) {
|
|
4160
|
-
let e =
|
|
4207
|
+
let e = Mi(r);
|
|
4161
4208
|
if (e == null || !n.userIds.includes(e)) return {
|
|
4162
4209
|
outcome: "ignored",
|
|
4163
4210
|
reason: "Telegram user does not match."
|
|
@@ -4175,19 +4222,19 @@ var xi = /* @__PURE__ */ new Set([
|
|
|
4175
4222
|
};
|
|
4176
4223
|
},
|
|
4177
4224
|
async reconcile(e) {
|
|
4178
|
-
let t = await
|
|
4179
|
-
if (!e.active) return t == e.endpointUrl && await
|
|
4180
|
-
if (t != "" && t != e.endpointUrl) throw new i(`The Telegram bot already sends updates to ${
|
|
4181
|
-
let n =
|
|
4182
|
-
return await
|
|
4183
|
-
allowed_updates:
|
|
4225
|
+
let t = await Ni(e);
|
|
4226
|
+
if (!e.active) return t == e.endpointUrl && await Pi(e), { outcome: "ready" };
|
|
4227
|
+
if (t != "" && t != e.endpointUrl) throw new i(`The Telegram bot already sends updates to ${Ii(t)}.`);
|
|
4228
|
+
let n = Oi(e.config);
|
|
4229
|
+
return await Fi(e, "setWebhook", {
|
|
4230
|
+
allowed_updates: ki(n) ?? [],
|
|
4184
4231
|
drop_pending_updates: t == "" && n.dropPendingUpdates,
|
|
4185
4232
|
secret_token: e.callbackSecret,
|
|
4186
4233
|
url: e.endpointUrl
|
|
4187
4234
|
}), { outcome: "ready" };
|
|
4188
4235
|
}
|
|
4189
4236
|
};
|
|
4190
|
-
function
|
|
4237
|
+
function Oi(e) {
|
|
4191
4238
|
return {
|
|
4192
4239
|
chatIds: e.chatIds ?? [],
|
|
4193
4240
|
dropPendingUpdates: e.dropPendingUpdates ?? !0,
|
|
@@ -4195,12 +4242,12 @@ function Ti(e) {
|
|
|
4195
4242
|
userIds: e.userIds ?? []
|
|
4196
4243
|
};
|
|
4197
4244
|
}
|
|
4198
|
-
function
|
|
4245
|
+
function ki(e) {
|
|
4199
4246
|
if (!e.updates.includes("*")) return e.updates;
|
|
4200
4247
|
let t = e.updates.filter((e) => e != "*");
|
|
4201
|
-
return t.length == 0 ? null : [.../* @__PURE__ */ new Set([...
|
|
4248
|
+
return t.length == 0 ? null : [.../* @__PURE__ */ new Set([...Ei, ...t])];
|
|
4202
4249
|
}
|
|
4203
|
-
function
|
|
4250
|
+
function Ai(e, t) {
|
|
4204
4251
|
if (e == null || e.length != t.length) return !1;
|
|
4205
4252
|
let n = 0;
|
|
4206
4253
|
for (let r = 0; r < t.length; r += 1) n |= e.charCodeAt(r) ^ t.charCodeAt(r);
|
|
@@ -4212,21 +4259,21 @@ function K(e) {
|
|
|
4212
4259
|
function q(e) {
|
|
4213
4260
|
if (K(e)) return typeof e.id == "string" || typeof e.id == "number" ? String(e.id) : void 0;
|
|
4214
4261
|
}
|
|
4215
|
-
function
|
|
4262
|
+
function ji(e) {
|
|
4216
4263
|
if (K(e)) return q(e.chat) ?? (K(e.message) ? q(e.message.chat) : void 0);
|
|
4217
4264
|
}
|
|
4218
|
-
function
|
|
4265
|
+
function Mi(e) {
|
|
4219
4266
|
if (K(e)) return q(e.from) ?? q(e.user);
|
|
4220
4267
|
}
|
|
4221
|
-
async function
|
|
4222
|
-
let t = await
|
|
4268
|
+
async function Ni(e) {
|
|
4269
|
+
let t = await Fi(e, "getWebhookInfo"), n = K(t.result) ? t.result.url : void 0;
|
|
4223
4270
|
if (typeof n != "string") throw new a("Telegram getWebhookInfo response is missing result.url.");
|
|
4224
4271
|
return n;
|
|
4225
4272
|
}
|
|
4226
|
-
async function
|
|
4227
|
-
await
|
|
4273
|
+
async function Pi(e) {
|
|
4274
|
+
await Fi(e, "deleteWebhook", { drop_pending_updates: !1 });
|
|
4228
4275
|
}
|
|
4229
|
-
async function
|
|
4276
|
+
async function Fi(e, t, n) {
|
|
4230
4277
|
let o;
|
|
4231
4278
|
try {
|
|
4232
4279
|
o = await e.connector.execute({
|
|
@@ -4242,14 +4289,14 @@ async function Mi(e, t, n) {
|
|
|
4242
4289
|
let c = typeof s.description == "string" ? s.description : `HTTP ${o.status}`;
|
|
4243
4290
|
throw o.status == 401 || o.status == 403 ? new r(`Telegram ${t} rejected the Connection.`) : o.status >= 400 && o.status < 500 && o.status != 429 ? new i(`Telegram ${t} rejected the subscription: ${c}`) : new a(`Telegram ${t} failed: ${c}`);
|
|
4244
4291
|
}
|
|
4245
|
-
function
|
|
4292
|
+
function Ii(e) {
|
|
4246
4293
|
try {
|
|
4247
4294
|
return new URL(e).host;
|
|
4248
4295
|
} catch {
|
|
4249
4296
|
return "an invalid URL";
|
|
4250
4297
|
}
|
|
4251
4298
|
}
|
|
4252
|
-
var
|
|
4299
|
+
var Li = {
|
|
4253
4300
|
initialState: {
|
|
4254
4301
|
checkpoint: null,
|
|
4255
4302
|
subscription: {}
|
|
@@ -4337,7 +4384,7 @@ var Pi = {
|
|
|
4337
4384
|
type: "integration"
|
|
4338
4385
|
},
|
|
4339
4386
|
async receive(e) {
|
|
4340
|
-
if (!await
|
|
4387
|
+
if (!await he(e.callbackSecret, [e.rawBody], e.header("x-wc-webhook-signature"))) return {
|
|
4341
4388
|
body: "",
|
|
4342
4389
|
contentType: "text/plain",
|
|
4343
4390
|
outcome: "respond",
|
|
@@ -4348,7 +4395,7 @@ var Pi = {
|
|
|
4348
4395
|
outcome: "ignored",
|
|
4349
4396
|
reason: "WooCommerce topic header is missing."
|
|
4350
4397
|
};
|
|
4351
|
-
if (!
|
|
4398
|
+
if (!Ri(e.config).events.includes(t)) return {
|
|
4352
4399
|
outcome: "ignored",
|
|
4353
4400
|
reason: "WooCommerce topic is not subscribed."
|
|
4354
4401
|
};
|
|
@@ -4368,30 +4415,30 @@ var Pi = {
|
|
|
4368
4415
|
};
|
|
4369
4416
|
},
|
|
4370
4417
|
async reconcile(e) {
|
|
4371
|
-
let t =
|
|
4418
|
+
let t = qi(e.state), n = Ri(e.config), r = await Vi(e);
|
|
4372
4419
|
if (!e.active) {
|
|
4373
|
-
for (let t of r) await
|
|
4374
|
-
return await t.saveSubscription({},
|
|
4420
|
+
for (let t of r) await Hi(e, t.id);
|
|
4421
|
+
return await t.saveSubscription({}, Ji(e.now)), { outcome: "ready" };
|
|
4375
4422
|
}
|
|
4376
4423
|
let i = /* @__PURE__ */ new Map();
|
|
4377
4424
|
for (let e of r) n.events.includes(e.topic) && !i.has(e.topic) && i.set(e.topic, e.id);
|
|
4378
4425
|
let a = new Set(i.values());
|
|
4379
|
-
for (let t of r) a.has(t.id) || await
|
|
4426
|
+
for (let t of r) a.has(t.id) || await Hi(e, t.id);
|
|
4380
4427
|
let o = [];
|
|
4381
4428
|
for (let t of n.events) {
|
|
4382
4429
|
let r = i.get(t);
|
|
4383
|
-
o.push(r == null ? await
|
|
4430
|
+
o.push(r == null ? await zi(e, n, t) : await Bi(e, r, t));
|
|
4384
4431
|
}
|
|
4385
|
-
return await t.saveSubscription({ webhookIds: o },
|
|
4432
|
+
return await t.saveSubscription({ webhookIds: o }, Ji(e.now)), { outcome: "ready" };
|
|
4386
4433
|
}
|
|
4387
4434
|
};
|
|
4388
|
-
function
|
|
4435
|
+
function Ri(e) {
|
|
4389
4436
|
return {
|
|
4390
4437
|
events: [...new Set(e.events)],
|
|
4391
4438
|
webhookName: e.webhookName ?? "OOMOL Trigger"
|
|
4392
4439
|
};
|
|
4393
4440
|
}
|
|
4394
|
-
async function
|
|
4441
|
+
async function zi(e, t, n) {
|
|
4395
4442
|
let r = await J(e, `webhook create (${n})`, {
|
|
4396
4443
|
body: {
|
|
4397
4444
|
delivery_url: e.endpointUrl,
|
|
@@ -4402,9 +4449,9 @@ async function Ii(e, t, n) {
|
|
|
4402
4449
|
endpoint: "/webhooks",
|
|
4403
4450
|
method: "POST"
|
|
4404
4451
|
});
|
|
4405
|
-
return Y(r, `webhook create (${n})`),
|
|
4452
|
+
return Y(r, `webhook create (${n})`), Gi(r.data);
|
|
4406
4453
|
}
|
|
4407
|
-
async function
|
|
4454
|
+
async function Bi(e, t, n) {
|
|
4408
4455
|
let r = await J(e, `webhook update (${n})`, {
|
|
4409
4456
|
body: {
|
|
4410
4457
|
delivery_url: e.endpointUrl,
|
|
@@ -4415,9 +4462,9 @@ async function Li(e, t, n) {
|
|
|
4415
4462
|
endpoint: `/webhooks/${t}`,
|
|
4416
4463
|
method: "PUT"
|
|
4417
4464
|
});
|
|
4418
|
-
return
|
|
4465
|
+
return Ui(r) ? zi(e, Ri(e.config), n) : (Y(r, `webhook update (${n})`), t);
|
|
4419
4466
|
}
|
|
4420
|
-
async function
|
|
4467
|
+
async function Vi(e) {
|
|
4421
4468
|
let t = [];
|
|
4422
4469
|
for (let n = 1; n <= 10; n += 1) {
|
|
4423
4470
|
let r = await J(e, "webhook list", {
|
|
@@ -4433,9 +4480,9 @@ async function Ri(e) {
|
|
|
4433
4480
|
Y(r, "webhook list");
|
|
4434
4481
|
let i = Array.isArray(r.data) ? r.data : [];
|
|
4435
4482
|
for (let n of i) {
|
|
4436
|
-
let r =
|
|
4483
|
+
let r = Yi(n);
|
|
4437
4484
|
if (r?.delivery_url !== e.endpointUrl || typeof r.topic != "string") continue;
|
|
4438
|
-
let i =
|
|
4485
|
+
let i = Ki(r.id);
|
|
4439
4486
|
i != null && t.push({
|
|
4440
4487
|
id: i,
|
|
4441
4488
|
topic: r.topic
|
|
@@ -4445,7 +4492,7 @@ async function Ri(e) {
|
|
|
4445
4492
|
}
|
|
4446
4493
|
throw new a("WooCommerce webhook list did not finish within ten pages.");
|
|
4447
4494
|
}
|
|
4448
|
-
async function
|
|
4495
|
+
async function Hi(e, t) {
|
|
4449
4496
|
let n = await J(e, "webhook delete", {
|
|
4450
4497
|
endpoint: `/webhooks/${t}`,
|
|
4451
4498
|
method: "DELETE",
|
|
@@ -4462,37 +4509,37 @@ async function J(e, t, n) {
|
|
|
4462
4509
|
}
|
|
4463
4510
|
function Y(e, t) {
|
|
4464
4511
|
if (e.status >= 200 && e.status < 300) return;
|
|
4465
|
-
let n =
|
|
4512
|
+
let n = Wi(e.data);
|
|
4466
4513
|
throw e.status == 401 || e.status == 403 ? new r(`WooCommerce ${t} rejected the Connection.`) : e.status == 404 || e.status == 400 && (n.endsWith("_invalid_topic") || n.endsWith("_invalid_delivery_url")) || e.status == 501 && n == "woocommerce_rest_trash_not_supported" ? new i(`WooCommerce ${t} rejected the subscription.`) : new a(`WooCommerce ${t} failed with status ${e.status}.`);
|
|
4467
4514
|
}
|
|
4468
|
-
function
|
|
4469
|
-
return e.status == 400 &&
|
|
4515
|
+
function Ui(e) {
|
|
4516
|
+
return e.status == 400 && Wi(e.data) == "woocommerce_rest_webhook_invalid_id";
|
|
4470
4517
|
}
|
|
4471
|
-
function
|
|
4472
|
-
let t =
|
|
4518
|
+
function Wi(e) {
|
|
4519
|
+
let t = Yi(e)?.code;
|
|
4473
4520
|
return typeof t == "string" ? t : "";
|
|
4474
4521
|
}
|
|
4475
|
-
function
|
|
4476
|
-
let t =
|
|
4522
|
+
function Gi(e) {
|
|
4523
|
+
let t = Ki(Yi(e)?.id);
|
|
4477
4524
|
if (t == null) throw new a("WooCommerce webhook response is missing its ID.");
|
|
4478
4525
|
return t;
|
|
4479
4526
|
}
|
|
4480
|
-
function
|
|
4527
|
+
function Ki(e) {
|
|
4481
4528
|
return typeof e == "string" && e.length > 0 ? e : typeof e == "number" && Number.isFinite(e) ? String(e) : null;
|
|
4482
4529
|
}
|
|
4483
|
-
function
|
|
4530
|
+
function qi(e) {
|
|
4484
4531
|
if (e == null) throw new i("WooCommerce Integration state is missing.");
|
|
4485
4532
|
return e;
|
|
4486
4533
|
}
|
|
4487
|
-
function
|
|
4534
|
+
function Ji(e) {
|
|
4488
4535
|
return new Date(e.getTime() + 2592e6);
|
|
4489
4536
|
}
|
|
4490
|
-
function
|
|
4537
|
+
function Yi(e) {
|
|
4491
4538
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
4492
4539
|
}
|
|
4493
4540
|
//#endregion
|
|
4494
4541
|
//#region src/trigger/providers/zendesk/on-event.ts
|
|
4495
|
-
var
|
|
4542
|
+
var Xi = 3e5, Zi = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_changed,zen:event-type:ticket.attachment_linked_to_comment,zen:event-type:ticket.attachment_redacted_from_comment,zen:event-type:ticket.brand_changed,zen:event-type:ticket.comment_added,zen:event-type:ticket.comment_made_private,zen:event-type:ticket.comment_redacted,zen:event-type:ticket.created,zen:event-type:ticket.csat_received,zen:event-type:ticket.csat_requested,zen:event-type:ticket.custom_field_changed,zen:event-type:ticket.custom_status_changed,zen:event-type:ticket.description_changed,zen:event-type:ticket.email_ccs_changed,zen:event-type:ticket.external_id_changed,zen:event-type:ticket.followers_changed,zen:event-type:ticket.form_changed,zen:event-type:ticket.group_assignment_changed,zen:event-type:ticket.marked_as_spam,zen:event-type:ticket.merged,zen:event-type:ticket.next_sla_breach_changed,zen:event-type:ticket.ola_policy_changed,zen:event-type:ticket.organization_changed,zen:event-type:ticket.permanently_deleted,zen:event-type:ticket.priority_changed,zen:event-type:ticket.problem_link_changed,zen:event-type:ticket.requester_changed,zen:event-type:ticket.schedule_changed,zen:event-type:ticket.sla_policy_changed,zen:event-type:ticket.soft_deleted,zen:event-type:ticket.status_changed,zen:event-type:ticket.subject_changed,zen:event-type:ticket.submitter_changed,zen:event-type:ticket.tags_changed,zen:event-type:ticket.task_due_at_changed,zen:event-type:ticket.type_changed,zen:event-type:ticket.undeleted,zen:event-type:organization.created,zen:event-type:organization.custom_field_changed,zen:event-type:organization.deleted,zen:event-type:organization.external_id_changed,zen:event-type:organization.name_changed,zen:event-type:organization.tags_changed,zen:event-type:user.active_changed,zen:event-type:user.alias_changed,zen:event-type:user.created,zen:event-type:user.custom_field_changed,zen:event-type:user.custom_role_changed,zen:event-type:user.default_group_changed,zen:event-type:user.deleted,zen:event-type:user.details_changed,zen:event-type:user.external_id_changed,zen:event-type:user.group_membership_created,zen:event-type:user.group_membership_deleted,zen:event-type:user.identity_changed,zen:event-type:user.identity_created,zen:event-type:user.identity_deleted,zen:event-type:user.last_login_changed,zen:event-type:user.merged,zen:event-type:user.name_changed,zen:event-type:user.notes_changed,zen:event-type:user.only_private_comments_changed,zen:event-type:user.organization_membership_created,zen:event-type:user.organization_membership_deleted,zen:event-type:user.password_changed,zen:event-type:user.photo_changed,zen:event-type:user.role_changed,zen:event-type:user.suspended_changed,zen:event-type:user.tags_changed,zen:event-type:user.time_zone_changed".split(","), X = "/api/v2/webhooks", Qi = {
|
|
4496
4543
|
initialState: {
|
|
4497
4544
|
checkpoint: null,
|
|
4498
4545
|
subscription: {}
|
|
@@ -4502,7 +4549,7 @@ var qi = 3e5, Ji = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_chang
|
|
|
4502
4549
|
additionalProperties: !1,
|
|
4503
4550
|
properties: { events: {
|
|
4504
4551
|
items: {
|
|
4505
|
-
enum:
|
|
4552
|
+
enum: Zi,
|
|
4506
4553
|
type: "string"
|
|
4507
4554
|
},
|
|
4508
4555
|
minItems: 1,
|
|
@@ -4547,8 +4594,8 @@ var qi = 3e5, Ji = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_chang
|
|
|
4547
4594
|
type: "integration"
|
|
4548
4595
|
},
|
|
4549
4596
|
async receive(e) {
|
|
4550
|
-
let t =
|
|
4551
|
-
if (t == null || n == null || !Number.isFinite(r) || Math.abs(e.now.getTime() - r) >
|
|
4597
|
+
let t = oa(e.state), n = e.header("x-zendesk-webhook-signature-timestamp"), r = n == null ? NaN : Date.parse(n);
|
|
4598
|
+
if (t == null || n == null || !Number.isFinite(r) || Math.abs(e.now.getTime() - r) > Xi || !await he(t, [pe(n), e.rawBody], e.header("x-zendesk-webhook-signature"))) return {
|
|
4552
4599
|
body: "",
|
|
4553
4600
|
contentType: "text/plain",
|
|
4554
4601
|
outcome: "respond",
|
|
@@ -4580,54 +4627,54 @@ var qi = 3e5, Ji = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_chang
|
|
|
4580
4627
|
};
|
|
4581
4628
|
},
|
|
4582
4629
|
async reconcile(e) {
|
|
4583
|
-
let t =
|
|
4630
|
+
let t = ia(e.state), n = await ea(e), r = aa(t);
|
|
4584
4631
|
if (!e.active) {
|
|
4585
|
-
for (let t of r == null ? n : [.../* @__PURE__ */ new Set([r, ...n])]) await
|
|
4586
|
-
return await t.saveSubscription({},
|
|
4632
|
+
for (let t of r == null ? n : [.../* @__PURE__ */ new Set([r, ...n])]) await ta(e, t);
|
|
4633
|
+
return await t.saveSubscription({}, ca(e.now)), { outcome: "ready" };
|
|
4587
4634
|
}
|
|
4588
4635
|
let i = r ?? n[0];
|
|
4589
4636
|
if (i == null) {
|
|
4590
4637
|
let t = await Z(e, "webhook create", {
|
|
4591
|
-
body:
|
|
4638
|
+
body: $i(e),
|
|
4592
4639
|
endpoint: X,
|
|
4593
4640
|
method: "POST"
|
|
4594
4641
|
});
|
|
4595
|
-
Q(t, "webhook create"), i =
|
|
4642
|
+
Q(t, "webhook create"), i = ra($(t.data)?.webhook);
|
|
4596
4643
|
} else {
|
|
4597
4644
|
let n = await Z(e, "webhook update", {
|
|
4598
|
-
body:
|
|
4645
|
+
body: $i(e),
|
|
4599
4646
|
endpoint: `${X}/${i}`,
|
|
4600
4647
|
method: "PUT"
|
|
4601
4648
|
});
|
|
4602
4649
|
if (n.status == 404) return await t.saveSubscription({}, e.now), { outcome: "pending" };
|
|
4603
4650
|
Q(n, "webhook update");
|
|
4604
4651
|
}
|
|
4605
|
-
for (let t of n.filter((e) => e != i)) await
|
|
4652
|
+
for (let t of n.filter((e) => e != i)) await ta(e, t);
|
|
4606
4653
|
return await t.saveSubscription({
|
|
4607
|
-
signingSecret: await
|
|
4654
|
+
signingSecret: await sa(e, i),
|
|
4608
4655
|
webhookId: i
|
|
4609
|
-
},
|
|
4656
|
+
}, ca(e.now)), { outcome: "ready" };
|
|
4610
4657
|
}
|
|
4611
4658
|
};
|
|
4612
|
-
function
|
|
4659
|
+
function $i(e) {
|
|
4613
4660
|
return { webhook: {
|
|
4614
4661
|
description: "Managed by Open Flow. Do not edit.",
|
|
4615
4662
|
endpoint: e.endpointUrl,
|
|
4616
4663
|
http_method: "POST",
|
|
4617
|
-
name:
|
|
4664
|
+
name: na(e.endpointUrl),
|
|
4618
4665
|
request_format: "json",
|
|
4619
4666
|
status: "active",
|
|
4620
4667
|
subscriptions: [...new Set(e.config.events)]
|
|
4621
4668
|
} };
|
|
4622
4669
|
}
|
|
4623
|
-
async function
|
|
4670
|
+
async function ea(e) {
|
|
4624
4671
|
let t = [], n;
|
|
4625
4672
|
for (let r = 0; r < 10; r += 1) {
|
|
4626
4673
|
let r = await Z(e, "webhook list", {
|
|
4627
4674
|
endpoint: X,
|
|
4628
4675
|
method: "GET",
|
|
4629
4676
|
query: {
|
|
4630
|
-
"filter[name_contains]":
|
|
4677
|
+
"filter[name_contains]": na(e.endpointUrl),
|
|
4631
4678
|
"page[size]": "100",
|
|
4632
4679
|
...n == null ? {} : { "page[after]": n }
|
|
4633
4680
|
}
|
|
@@ -4644,7 +4691,7 @@ async function Zi(e) {
|
|
|
4644
4691
|
}
|
|
4645
4692
|
return t;
|
|
4646
4693
|
}
|
|
4647
|
-
async function
|
|
4694
|
+
async function ta(e, t) {
|
|
4648
4695
|
let n = await Z(e, "webhook delete", {
|
|
4649
4696
|
endpoint: `${X}/${t}`,
|
|
4650
4697
|
method: "DELETE"
|
|
@@ -4665,27 +4712,27 @@ function Q(e, t) {
|
|
|
4665
4712
|
422
|
|
4666
4713
|
].includes(e.status) ? new i(`Zendesk ${t} rejected the subscription.`) : new a(`Zendesk ${t} failed with status ${e.status}.`);
|
|
4667
4714
|
}
|
|
4668
|
-
function
|
|
4715
|
+
function na(e) {
|
|
4669
4716
|
return `open-flow-${e.slice(e.lastIndexOf("/") + 1)}`;
|
|
4670
4717
|
}
|
|
4671
|
-
function
|
|
4718
|
+
function ra(e) {
|
|
4672
4719
|
let t = $(e)?.id;
|
|
4673
4720
|
if (typeof t != "string") throw new a("Zendesk webhook response is missing its ID.");
|
|
4674
4721
|
return t;
|
|
4675
4722
|
}
|
|
4676
|
-
function
|
|
4723
|
+
function ia(e) {
|
|
4677
4724
|
if (e == null) throw new i("Zendesk Integration state is missing.");
|
|
4678
4725
|
return e;
|
|
4679
4726
|
}
|
|
4680
|
-
function
|
|
4727
|
+
function aa(e) {
|
|
4681
4728
|
let t = e.subscription.webhookId;
|
|
4682
4729
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
4683
4730
|
}
|
|
4684
|
-
function
|
|
4731
|
+
function oa(e) {
|
|
4685
4732
|
let t = e?.subscription.signingSecret;
|
|
4686
4733
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
4687
4734
|
}
|
|
4688
|
-
async function
|
|
4735
|
+
async function sa(e, t) {
|
|
4689
4736
|
let n = await Z(e, "webhook signing secret", {
|
|
4690
4737
|
endpoint: `${X}/${t}/signing_secret`,
|
|
4691
4738
|
method: "GET"
|
|
@@ -4695,7 +4742,7 @@ async function ia(e, t) {
|
|
|
4695
4742
|
if (typeof r != "string" || r.length == 0) throw new a("Zendesk webhook signing secret response is invalid.");
|
|
4696
4743
|
return r;
|
|
4697
4744
|
}
|
|
4698
|
-
function
|
|
4745
|
+
function ca(e) {
|
|
4699
4746
|
return new Date(e.getTime() + 2592e6);
|
|
4700
4747
|
}
|
|
4701
4748
|
function $(e) {
|
|
@@ -4703,24 +4750,25 @@ function $(e) {
|
|
|
4703
4750
|
}
|
|
4704
4751
|
//#endregion
|
|
4705
4752
|
//#region src/trigger/providers/definitions.ts
|
|
4706
|
-
var
|
|
4753
|
+
var la = [
|
|
4707
4754
|
s,
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4755
|
+
We,
|
|
4756
|
+
xe,
|
|
4757
|
+
Me,
|
|
4758
|
+
it,
|
|
4759
|
+
Ot,
|
|
4760
|
+
qt,
|
|
4761
|
+
Zt,
|
|
4762
|
+
yn,
|
|
4763
|
+
Fn,
|
|
4764
|
+
rr,
|
|
4765
|
+
wr,
|
|
4766
|
+
Lr,
|
|
4767
|
+
$r,
|
|
4768
|
+
pi,
|
|
4769
|
+
Di,
|
|
4770
|
+
Li,
|
|
4771
|
+
Qi
|
|
4772
|
+
], ua = la.filter((e) => e.snapshot.type == "poll"), da = la.filter((e) => e.snapshot.type == "integration");
|
|
4725
4773
|
//#endregion
|
|
4726
|
-
export {
|
|
4774
|
+
export { da as integrationDefinitions, ua as pollDefinitions, la as triggerDefinitions };
|