@oomol-lab/open-flow 0.1.0-beta.40 → 0.1.0-beta.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/dist/browser/{createResourceDialog-BOrW62JW.js → createResourceDialog-DmJk4LsF.js} +28 -29
- package/dist/browser/dist-BhV15xlT.js +300 -0
- package/dist/browser/flow-authoring-node.d.ts +4 -1
- package/dist/browser/flow-authoring.js +7 -10
- package/dist/browser/flow-change.d.ts +3 -15
- package/dist/browser/flow-change.js +1 -2
- package/dist/browser/{editorComponent-0skblWYk.js → flowChanges-Rb1Nz-ph.js} +34187 -15646
- package/dist/browser/{flowRunInputEditorStore-Bgb5vSeS.js → flowRunInputEditorStore-rVbwoTfN.js} +1 -1
- package/dist/browser/{flowWorkspace-DJzQVVtZ.js → flowWorkspace-B04ZIbVq.js} +38861 -39243
- package/dist/browser/licenses.md +16 -0
- package/dist/browser/{markdownContent-D2oHGWc6.js → markdownContent-DP6aYNZN.js} +17 -17
- package/dist/browser/markdownContent-DPkwZqaL.js +44588 -0
- package/dist/browser/preview.css +2 -0
- package/dist/browser/preview.css.d.ts +1 -0
- package/dist/browser/preview.d.ts +15 -0
- package/dist/browser/preview.js +88010 -0
- package/dist/browser/theme.css +7 -1
- package/dist/browser/{typeScriptSession-v9Pb3G6d.js → typeScriptSession-By_yez_b.js} +1 -1
- package/dist/browser/ui.css +1 -1
- package/dist/browser/ui.js +3903 -1421
- package/dist/browser/workbench-contract.d.ts +21 -12
- package/dist/browser/workbench.css +1 -1
- package/dist/browser/workbench.d.ts +3 -1
- package/dist/browser/workbench.js +1174 -1848
- package/dist/browser/workbenchSelect-Bq6KHpKx.js +16033 -0
- package/dist/common/control-api-conformance.js +2606 -2540
- package/dist/common/control-api.d.ts +18 -10
- package/dist/common/control-api.js +2428 -2381
- package/dist/common/control-requests.js +4 -8
- package/dist/common/flow-encoding.js +1 -2
- package/dist/common/flow-graph.d.ts +1 -1
- package/dist/common/flow-promptTemplate.d.ts +4 -0
- package/dist/common/flow-schema.d.ts +1 -0
- package/dist/common/flow-semantics.d.ts +2 -1
- package/dist/common/flow-semantics.js +2780 -2770
- package/dist/common/integration-trigger.js +724 -721
- package/dist/common/mcp.js +789 -739
- package/dist/common/poll-trigger.js +40 -37
- package/dist/common/provider-triggers.js +611 -608
- package/dist/common/providerIconSprite.d.ts +25 -0
- package/dist/common/runtime-contract.js +2 -1
- package/dist/common/scheduler.d.ts +2 -0
- package/dist/common/scheduler.js +1585 -1549
- package/dist/common/webhook-trigger.js +1 -2
- package/dist/index.d.ts +19 -0
- package/package.json +9 -1
- package/dist/browser/flowChanges-3o9Vs_1I.js +0 -10137
- package/dist/browser/inputValues-DkDT6u0o.js +0 -43
- package/dist/browser/lite-BA96NG4M.js +0 -8549
- package/dist/browser/workbenchSelect-B5zXyaaX.js +0 -6423
|
@@ -5369,8 +5369,7 @@ var Dl = A(M([j({
|
|
|
5369
5369
|
kind: P("agent"),
|
|
5370
5370
|
code: Rc().optional(),
|
|
5371
5371
|
model: F,
|
|
5372
|
-
prompt:
|
|
5373
|
-
system: F,
|
|
5372
|
+
prompt: F,
|
|
5374
5373
|
maxRounds: Pc(),
|
|
5375
5374
|
tools: A(j({
|
|
5376
5375
|
id: F,
|
|
@@ -9676,32 +9675,36 @@ function ch(e) {
|
|
|
9676
9675
|
}
|
|
9677
9676
|
var lh = /* @__PURE__ */ new WeakMap();
|
|
9678
9677
|
function uh(e, t) {
|
|
9679
|
-
|
|
9678
|
+
return dh(e, t).length == 0;
|
|
9679
|
+
}
|
|
9680
|
+
function dh(e, t) {
|
|
9681
|
+
if (typeof t == "boolean") return t ? [] : ["The schema does not allow any value."];
|
|
9680
9682
|
let n = ch(t);
|
|
9681
|
-
if (n == null || n.properties != null && ch(n.properties) == null) return
|
|
9683
|
+
if (n == null || n.properties != null && ch(n.properties) == null) return ["Invalid output schema."];
|
|
9682
9684
|
try {
|
|
9683
9685
|
let t = lh.get(n);
|
|
9684
9686
|
if (t == null) {
|
|
9685
9687
|
let e = typeof n.$schema == "string" ? n.$schema : "", r = e.includes("draft-04") ? "4" : e.includes("draft-07") ? "7" : e.includes("2020-12") ? "2020-12" : "2019-09";
|
|
9686
9688
|
t = new Zd(structuredClone(n), r), lh.set(n, t);
|
|
9687
9689
|
}
|
|
9688
|
-
|
|
9690
|
+
let r = t.validate(e);
|
|
9691
|
+
return r.valid ? [] : r.errors.map((e) => `${e.instanceLocation || "/"}: ${e.error}`);
|
|
9689
9692
|
} catch {
|
|
9690
|
-
return
|
|
9693
|
+
return ["Output schema validation failed."];
|
|
9691
9694
|
}
|
|
9692
9695
|
}
|
|
9693
9696
|
//#endregion
|
|
9694
9697
|
//#region src/trigger/common/config.ts
|
|
9695
|
-
function
|
|
9698
|
+
function fh(e, t) {
|
|
9696
9699
|
return We(t[e.handle], e.value);
|
|
9697
9700
|
}
|
|
9698
|
-
function
|
|
9701
|
+
function ph(e, t) {
|
|
9699
9702
|
let n = e.filter((e) => "handle" in e), r = new Set(n.map((e) => e.handle));
|
|
9700
9703
|
if (r.size !== n.length) throw TypeError("Trigger config has duplicate input handles.");
|
|
9701
9704
|
let i = Object.keys(t).find((e) => !r.has(e));
|
|
9702
9705
|
if (i != null) throw TypeError(`Unknown Trigger config input "${i}".`);
|
|
9703
9706
|
let a = Object.fromEntries(n.map((e) => {
|
|
9704
|
-
let n =
|
|
9707
|
+
let n = fh(e, t) ?? null;
|
|
9705
9708
|
if (!(n === null && e.nullable) && !uh(n, e.jsonSchema)) throw TypeError(`Trigger config input "${e.handle}" does not match its declared schema.`);
|
|
9706
9709
|
return [e.handle, n];
|
|
9707
9710
|
}));
|
|
@@ -9710,7 +9713,7 @@ function fh(e, t) {
|
|
|
9710
9713
|
}
|
|
9711
9714
|
//#endregion
|
|
9712
9715
|
//#region src/trigger/providers/google-drive/changes.ts
|
|
9713
|
-
var
|
|
9716
|
+
var mh = 6012e5, hh = 36e5, gh = 6e4, _h = 6e4, vh = 2, yh = 100, bh = new TextEncoder(), xh = "nextPageToken,newStartPageToken,changes(fileId,kind,changeType,removed,time,driveId,file(id,name,mimeType,webViewLink,createdTime,modifiedTime,size,driveId,parents,shared,starred,trashed))", Sh = {
|
|
9714
9717
|
configInputs: [
|
|
9715
9718
|
{
|
|
9716
9719
|
handle: "driveId",
|
|
@@ -9751,7 +9754,7 @@ var ph = 6012e5, mh = 36e5, hh = 6e4, gh = 6e4, _h = 2, vh = 100, yh = new TextE
|
|
|
9751
9754
|
type: "integer"
|
|
9752
9755
|
},
|
|
9753
9756
|
nullable: !1,
|
|
9754
|
-
value:
|
|
9757
|
+
value: yh,
|
|
9755
9758
|
description: "Maximum changes included in one Flow Run."
|
|
9756
9759
|
},
|
|
9757
9760
|
{
|
|
@@ -9827,16 +9830,16 @@ var ph = 6012e5, mh = 36e5, hh = 6e4, gh = 6e4, _h = 2, vh = 100, yh = new TextE
|
|
|
9827
9830
|
}],
|
|
9828
9831
|
provider: "googledrive",
|
|
9829
9832
|
type: "integration"
|
|
9830
|
-
},
|
|
9833
|
+
}, Ch = {
|
|
9831
9834
|
initialState: {
|
|
9832
9835
|
checkpoint: null,
|
|
9833
9836
|
subscription: { channels: [] }
|
|
9834
9837
|
},
|
|
9835
|
-
snapshot:
|
|
9838
|
+
snapshot: Sh,
|
|
9836
9839
|
async receive(e) {
|
|
9837
|
-
let t = await
|
|
9840
|
+
let t = await Gh(e);
|
|
9838
9841
|
if (t.outcome != "wake") return t;
|
|
9839
|
-
let n =
|
|
9842
|
+
let n = wh(e.state), r = e.header("x-goog-resource-state");
|
|
9840
9843
|
if (!e.admit) return e.current ? {
|
|
9841
9844
|
body: "",
|
|
9842
9845
|
contentType: "text/plain",
|
|
@@ -9850,12 +9853,12 @@ var ph = 6012e5, mh = 36e5, hh = 6e4, gh = 6e4, _h = 2, vh = 100, yh = new TextE
|
|
|
9850
9853
|
outcome: "ignored",
|
|
9851
9854
|
reason: "The Team cannot admit Trigger events."
|
|
9852
9855
|
};
|
|
9853
|
-
let i = await
|
|
9856
|
+
let i = await Mh(e, n.checkpoint), a = {
|
|
9854
9857
|
changedTypes: (e.header("x-goog-changed") ?? "").split(",").map((e) => e.trim()).filter((e) => e.length > 0),
|
|
9855
9858
|
messageNumber: e.header("x-goog-message-number") ?? null,
|
|
9856
9859
|
resourceState: r,
|
|
9857
9860
|
resourceUri: e.header("x-goog-resource-uri") ?? null
|
|
9858
|
-
}, o = i.changes.map((e) =>
|
|
9861
|
+
}, o = i.changes.map((e) => Rh(e, a)), s = {
|
|
9859
9862
|
checkpoint: i.checkpoint,
|
|
9860
9863
|
continue: i.hasMore,
|
|
9861
9864
|
dedupeKey: i.dedupeKey
|
|
@@ -9871,14 +9874,14 @@ var ph = 6012e5, mh = 36e5, hh = 6e4, gh = 6e4, _h = 2, vh = 100, yh = new TextE
|
|
|
9871
9874
|
};
|
|
9872
9875
|
},
|
|
9873
9876
|
async reconcile(e) {
|
|
9874
|
-
let t =
|
|
9875
|
-
if (i.length != n.length && (n = i, await $(t, n, e.now)), !e.active) return await
|
|
9877
|
+
let t = wh(e.state), n = Dh(t), r = e.now.getTime(), i = n.filter((e) => Date.parse(e.expiration) > r);
|
|
9878
|
+
if (i.length != n.length && (n = i, await $(t, n, e.now)), !e.active) return await kh(e, n);
|
|
9876
9879
|
let a = n.filter((e) => e.state == "creating" && e.resourceId != null).toSorted((e, t) => Date.parse(t.createdAt) - Date.parse(e.createdAt))[0];
|
|
9877
9880
|
a != null && (n = n.map((e) => ({
|
|
9878
9881
|
...e,
|
|
9879
9882
|
state: e.id == a.id ? "active" : "retiring"
|
|
9880
9883
|
})), await $(t, n, e.now));
|
|
9881
|
-
let o = n.find((e) => e.state == "active"), s = n.filter((e) => e.state == "creating").filter((e) => Date.parse(e.createdAt) +
|
|
9884
|
+
let o = n.find((e) => e.state == "active"), s = n.filter((e) => e.state == "creating").filter((e) => Date.parse(e.createdAt) + gh <= r);
|
|
9882
9885
|
if (s.length > 0) {
|
|
9883
9886
|
let r = new Set(s.map((e) => e.id));
|
|
9884
9887
|
n = n.map((e) => r.has(e.id) ? {
|
|
@@ -9888,21 +9891,21 @@ var ph = 6012e5, mh = 36e5, hh = 6e4, gh = 6e4, _h = 2, vh = 100, yh = new TextE
|
|
|
9888
9891
|
}
|
|
9889
9892
|
if (o = n.find((e) => e.state == "active"), o != null) {
|
|
9890
9893
|
try {
|
|
9891
|
-
n = await
|
|
9894
|
+
n = await Ah(e, n);
|
|
9892
9895
|
} catch {
|
|
9893
9896
|
return { outcome: "ready" };
|
|
9894
9897
|
}
|
|
9895
|
-
if (o = n.find((e) => e.state == "active"), o != null && Date.parse(o.expiration) -
|
|
9898
|
+
if (o = n.find((e) => e.state == "active"), o != null && Date.parse(o.expiration) - hh > r) return await $(t, n, zh(n, e.now)), { outcome: "ready" };
|
|
9896
9899
|
}
|
|
9897
|
-
return n.some((e) => e.state == "creating") || n.filter((e) => e.resourceId == null).length >=
|
|
9900
|
+
return n.some((e) => e.state == "creating") || n.filter((e) => e.resourceId == null).length >= vh ? (await $(t, n, zh(n, e.now)), { outcome: o == null ? "pending" : "ready" }) : await Oh(e, n);
|
|
9898
9901
|
}
|
|
9899
9902
|
};
|
|
9900
|
-
function
|
|
9903
|
+
function wh(e) {
|
|
9901
9904
|
if (e == null) throw new t("Google Drive Integration state is missing.");
|
|
9902
9905
|
return e;
|
|
9903
9906
|
}
|
|
9904
|
-
function
|
|
9905
|
-
let t =
|
|
9907
|
+
function Th(e) {
|
|
9908
|
+
let t = ph(Sh.configInputs, Ge(e));
|
|
9906
9909
|
return {
|
|
9907
9910
|
...typeof t.driveId == "string" ? { driveId: t.driveId } : {},
|
|
9908
9911
|
includeCorpusRemovals: t.includeCorpusRemovals,
|
|
@@ -9912,12 +9915,12 @@ function wh(e) {
|
|
|
9912
9915
|
restrictToMyDrive: t.restrictToMyDrive
|
|
9913
9916
|
};
|
|
9914
9917
|
}
|
|
9915
|
-
function
|
|
9916
|
-
let n =
|
|
9918
|
+
function Eh(e) {
|
|
9919
|
+
let n = Wh(e) ? Uh(e.pageToken) : void 0;
|
|
9917
9920
|
if (n == null) throw new t("Google Drive checkpoint pageToken is missing.");
|
|
9918
9921
|
return n;
|
|
9919
9922
|
}
|
|
9920
|
-
function
|
|
9923
|
+
function Dh(e) {
|
|
9921
9924
|
let n = e.subscription.channels;
|
|
9922
9925
|
if (!Array.isArray(n)) throw new t("Google Drive channel state is invalid.");
|
|
9923
9926
|
let r = n.map((e) => {
|
|
@@ -9940,24 +9943,24 @@ function Eh(e) {
|
|
|
9940
9943
|
if (new Set(r.map((e) => e.id)).size != r.length) throw new t("Google Drive channel IDs are duplicated.");
|
|
9941
9944
|
return r;
|
|
9942
9945
|
}
|
|
9943
|
-
async function
|
|
9944
|
-
let a =
|
|
9945
|
-
a.checkpoint === null ? (s = await
|
|
9946
|
+
async function Oh(r, i) {
|
|
9947
|
+
let a = wh(r.state), o = Th(r.config), s;
|
|
9948
|
+
a.checkpoint === null ? (s = await jh(r), await a.saveCheckpoint({ pageToken: s })) : s = Eh(a.checkpoint);
|
|
9946
9949
|
let c = {
|
|
9947
9950
|
createdAt: r.now.toISOString(),
|
|
9948
|
-
expiration: new Date(r.now.getTime() +
|
|
9951
|
+
expiration: new Date(r.now.getTime() + mh).toISOString(),
|
|
9949
9952
|
id: crypto.randomUUID(),
|
|
9950
9953
|
state: "creating"
|
|
9951
9954
|
};
|
|
9952
|
-
i = [...i, c], await $(a, i, new Date(r.now.getTime() +
|
|
9955
|
+
i = [...i, c], await $(a, i, new Date(r.now.getTime() + gh));
|
|
9953
9956
|
let l;
|
|
9954
9957
|
try {
|
|
9955
|
-
l = await
|
|
9958
|
+
l = await Ph(r, {
|
|
9956
9959
|
body: {
|
|
9957
9960
|
address: r.endpointUrl,
|
|
9958
9961
|
expiration: String(Date.parse(c.expiration)),
|
|
9959
9962
|
id: c.id,
|
|
9960
|
-
token: await
|
|
9963
|
+
token: await Bh(r.callbackSecret, c.id),
|
|
9961
9964
|
type: "web_hook"
|
|
9962
9965
|
},
|
|
9963
9966
|
endpoint: "/changes/watch",
|
|
@@ -9973,9 +9976,9 @@ async function Dh(r, i) {
|
|
|
9973
9976
|
} catch (n) {
|
|
9974
9977
|
throw (n instanceof e || n instanceof t) && await $(a, i.filter((e) => e.id != c.id), r.now), n;
|
|
9975
9978
|
}
|
|
9976
|
-
let u =
|
|
9979
|
+
let u = Uh(l.resourceId);
|
|
9977
9980
|
if (u == null) throw new n("Google Drive changes.watch response is missing resourceId.");
|
|
9978
|
-
let d =
|
|
9981
|
+
let d = Hh(l.expiration) ?? c.expiration;
|
|
9979
9982
|
i = i.map((e) => e.id == c.id ? {
|
|
9980
9983
|
...e,
|
|
9981
9984
|
expiration: d,
|
|
@@ -9984,52 +9987,52 @@ async function Dh(r, i) {
|
|
|
9984
9987
|
} : e.state == "active" ? {
|
|
9985
9988
|
...e,
|
|
9986
9989
|
state: "retiring"
|
|
9987
|
-
} : e), await $(a, i,
|
|
9990
|
+
} : e), await $(a, i, zh(i, r.now));
|
|
9988
9991
|
try {
|
|
9989
|
-
i = await
|
|
9992
|
+
i = await Ah(r, i);
|
|
9990
9993
|
} catch {
|
|
9991
9994
|
return { outcome: "ready" };
|
|
9992
9995
|
}
|
|
9993
|
-
return await $(a, i,
|
|
9996
|
+
return await $(a, i, zh(i, r.now)), { outcome: "ready" };
|
|
9994
9997
|
}
|
|
9995
|
-
async function
|
|
9996
|
-
let n =
|
|
9998
|
+
async function kh(e, t) {
|
|
9999
|
+
let n = wh(e.state);
|
|
9997
10000
|
return t.some((e) => e.state == "active" || e.state == "creating") && (t = t.map((e) => ({
|
|
9998
10001
|
...e,
|
|
9999
10002
|
state: "retiring"
|
|
10000
|
-
})), await $(n, t, e.now)), t = await
|
|
10003
|
+
})), await $(n, t, e.now)), t = await Ah(e, t), t.length == 0 ? { outcome: "ready" } : (await $(n, t, zh(t, e.now)), { outcome: "pending" });
|
|
10001
10004
|
}
|
|
10002
|
-
async function
|
|
10003
|
-
let n =
|
|
10005
|
+
async function Ah(e, t) {
|
|
10006
|
+
let n = wh(e.state);
|
|
10004
10007
|
for (let r of t) {
|
|
10005
10008
|
if (r.state != "retiring" && r.state != "stopping" || r.resourceId == null) continue;
|
|
10006
10009
|
let i = t.map((e) => e.id == r.id ? {
|
|
10007
10010
|
...e,
|
|
10008
10011
|
state: "stopping"
|
|
10009
10012
|
} : e);
|
|
10010
|
-
await $(n, i, new Date(e.now.getTime() +
|
|
10013
|
+
await $(n, i, new Date(e.now.getTime() + _h)), await Nh(e, r), t = i.filter((e) => e.id != r.id), await $(n, t, e.now);
|
|
10011
10014
|
}
|
|
10012
10015
|
return t;
|
|
10013
10016
|
}
|
|
10014
|
-
async function
|
|
10015
|
-
let t =
|
|
10017
|
+
async function jh(e) {
|
|
10018
|
+
let t = Th(e.config), r = await Ph(e, {
|
|
10016
10019
|
endpoint: "/changes/startPageToken",
|
|
10017
10020
|
method: "GET",
|
|
10018
10021
|
query: {
|
|
10019
10022
|
...t.driveId == null ? {} : { driveId: t.driveId },
|
|
10020
10023
|
supportsAllDrives: !0
|
|
10021
10024
|
}
|
|
10022
|
-
}, "changes.getStartPageToken"), i =
|
|
10025
|
+
}, "changes.getStartPageToken"), i = Wh(r) ? Uh(r.startPageToken) : void 0;
|
|
10023
10026
|
if (i == null) throw new n("Google Drive startPageToken response is invalid.");
|
|
10024
10027
|
return i;
|
|
10025
10028
|
}
|
|
10026
|
-
async function
|
|
10027
|
-
let r =
|
|
10029
|
+
async function Mh(e, t) {
|
|
10030
|
+
let r = Th(e.config), i = Eh(t), a = await Ph(e, {
|
|
10028
10031
|
endpoint: "/changes",
|
|
10029
10032
|
method: "GET",
|
|
10030
10033
|
query: {
|
|
10031
10034
|
...r.driveId == null ? {} : { driveId: r.driveId },
|
|
10032
|
-
fields:
|
|
10035
|
+
fields: xh,
|
|
10033
10036
|
includeCorpusRemovals: r.includeCorpusRemovals,
|
|
10034
10037
|
includeItemsFromAllDrives: r.driveId != null || r.includeItemsFromAllDrives,
|
|
10035
10038
|
includeRemoved: r.includeCorpusRemovals || r.includeRemoved,
|
|
@@ -10039,10 +10042,10 @@ async function jh(e, t) {
|
|
|
10039
10042
|
supportsAllDrives: !0
|
|
10040
10043
|
}
|
|
10041
10044
|
}, "changes.list");
|
|
10042
|
-
for (let e of ["nextPageToken", "newStartPageToken"]) if (a[e] !== void 0 &&
|
|
10043
|
-
let o =
|
|
10045
|
+
for (let e of ["nextPageToken", "newStartPageToken"]) if (a[e] !== void 0 && Uh(a[e]) == null) throw new n(`Google Drive changes response contains an invalid ${e}.`);
|
|
10046
|
+
let o = Uh(a.nextPageToken), s = o ?? Uh(a.newStartPageToken);
|
|
10044
10047
|
if (s == null) throw new n("Google Drive changes response is missing its next checkpoint.");
|
|
10045
|
-
if (a.changes != null && (!Array.isArray(a.changes) || !a.changes.every(
|
|
10048
|
+
if (a.changes != null && (!Array.isArray(a.changes) || !a.changes.every(Wh))) throw new n("Google Drive changes response contains invalid changes.");
|
|
10046
10049
|
if (o === i) throw new n("Google Drive changes continuation did not advance.");
|
|
10047
10050
|
return {
|
|
10048
10051
|
changes: a.changes ?? [],
|
|
@@ -10051,8 +10054,8 @@ async function jh(e, t) {
|
|
|
10051
10054
|
hasMore: o != null
|
|
10052
10055
|
};
|
|
10053
10056
|
}
|
|
10054
|
-
async function
|
|
10055
|
-
let n = await
|
|
10057
|
+
async function Nh(e, t) {
|
|
10058
|
+
let n = await Fh(e, {
|
|
10056
10059
|
body: {
|
|
10057
10060
|
id: t.id,
|
|
10058
10061
|
resourceId: t.resourceId
|
|
@@ -10060,31 +10063,31 @@ async function Mh(e, t) {
|
|
|
10060
10063
|
endpoint: "/channels/stop",
|
|
10061
10064
|
method: "POST"
|
|
10062
10065
|
});
|
|
10063
|
-
n.status >= 200 && n.status < 300 || n.status == 404 ||
|
|
10066
|
+
n.status >= 200 && n.status < 300 || n.status == 404 || Ih(n, "channels.stop");
|
|
10064
10067
|
}
|
|
10065
|
-
async function
|
|
10066
|
-
let r = await
|
|
10067
|
-
if (r.status >= 200 && r.status < 300 &&
|
|
10068
|
-
|
|
10068
|
+
async function Ph(e, t, n) {
|
|
10069
|
+
let r = await Fh(e, t);
|
|
10070
|
+
if (r.status >= 200 && r.status < 300 && Wh(r.data)) return r.data;
|
|
10071
|
+
Ih(r, n);
|
|
10069
10072
|
}
|
|
10070
|
-
async function
|
|
10073
|
+
async function Fh(t, r) {
|
|
10071
10074
|
try {
|
|
10072
10075
|
return await t.connector.execute(r, t.signal);
|
|
10073
10076
|
} catch (t) {
|
|
10074
10077
|
throw t instanceof e ? t : new n("Google Drive proxy request failed.", { cause: t });
|
|
10075
10078
|
}
|
|
10076
10079
|
}
|
|
10077
|
-
function
|
|
10078
|
-
let a =
|
|
10080
|
+
function Ih(r, i) {
|
|
10081
|
+
let a = Lh(r.data);
|
|
10079
10082
|
throw r.status == 401 || r.status == 403 && !a.toLowerCase().includes("ratelimit") ? new e(`Google Drive ${i} requires Connection reauthorization.`) : r.status == 408 || r.status == 429 || r.status >= 500 ? new n(`Google Drive ${i} is temporarily unavailable.`) : new t(`Google Drive ${i} rejected the subscription${a == "" ? "." : ` with ${a}.`}`);
|
|
10080
10083
|
}
|
|
10081
|
-
function
|
|
10082
|
-
if (!
|
|
10084
|
+
function Lh(e) {
|
|
10085
|
+
if (!Wh(e) || !Wh(e.error)) return "";
|
|
10083
10086
|
let t = e.error.errors;
|
|
10084
|
-
return Array.isArray(t) &&
|
|
10087
|
+
return Array.isArray(t) && Wh(t[0]) && typeof t[0].reason == "string" ? t[0].reason : typeof e.error.status == "string" ? e.error.status : "";
|
|
10085
10088
|
}
|
|
10086
|
-
function
|
|
10087
|
-
let n =
|
|
10089
|
+
function Rh(e, t) {
|
|
10090
|
+
let n = Uh(e.driveId), r = Uh(e.fileId), i = Uh(e.time), a = Uh(e.changeType), o = e.removed === !0;
|
|
10088
10091
|
return {
|
|
10089
10092
|
changeId: [
|
|
10090
10093
|
n ?? "my-drive",
|
|
@@ -10095,7 +10098,7 @@ function Lh(e, t) {
|
|
|
10095
10098
|
].join(":"),
|
|
10096
10099
|
changeType: a ?? null,
|
|
10097
10100
|
driveId: n ?? null,
|
|
10098
|
-
file:
|
|
10101
|
+
file: Wh(e.file) ? e.file : null,
|
|
10099
10102
|
fileId: r ?? null,
|
|
10100
10103
|
notification: t,
|
|
10101
10104
|
removed: o,
|
|
@@ -10105,43 +10108,43 @@ function Lh(e, t) {
|
|
|
10105
10108
|
async function $(e, t, n) {
|
|
10106
10109
|
await e.saveSubscription({ channels: t }, n);
|
|
10107
10110
|
}
|
|
10108
|
-
function
|
|
10109
|
-
let n = e.map((e) => e.state == "active" ? Date.parse(e.expiration) -
|
|
10111
|
+
function zh(e, t) {
|
|
10112
|
+
let n = e.map((e) => e.state == "active" ? Date.parse(e.expiration) - hh : e.state == "creating" ? Date.parse(e.createdAt) + gh : e.resourceId == null ? Date.parse(e.expiration) : t.getTime() + _h), r = n.length == 0 ? t.getTime() + _h : Math.min(...n);
|
|
10110
10113
|
return new Date(Math.max(t.getTime(), r));
|
|
10111
10114
|
}
|
|
10112
|
-
async function
|
|
10113
|
-
let n = await crypto.subtle.importKey("raw",
|
|
10115
|
+
async function Bh(e, t) {
|
|
10116
|
+
let n = await crypto.subtle.importKey("raw", bh.encode(e), {
|
|
10114
10117
|
hash: "SHA-256",
|
|
10115
10118
|
name: "HMAC"
|
|
10116
|
-
}, !1, ["sign"]), r = new Uint8Array(await crypto.subtle.sign("HMAC", n,
|
|
10119
|
+
}, !1, ["sign"]), r = new Uint8Array(await crypto.subtle.sign("HMAC", n, bh.encode(`google-drive-channel/v1/${t}`)));
|
|
10117
10120
|
return btoa(String.fromCharCode(...r)).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
10118
10121
|
}
|
|
10119
|
-
function
|
|
10122
|
+
function Vh(e, t) {
|
|
10120
10123
|
if (e.length != t.length) return !1;
|
|
10121
10124
|
let n = 0;
|
|
10122
10125
|
for (let r = 0; r < t.length; r += 1) n |= e.charCodeAt(r) ^ t.charCodeAt(r);
|
|
10123
10126
|
return n == 0;
|
|
10124
10127
|
}
|
|
10125
|
-
function
|
|
10128
|
+
function Hh(e) {
|
|
10126
10129
|
let t = typeof e == "string" || typeof e == "number" ? Number(e) : NaN;
|
|
10127
10130
|
return Number.isFinite(t) && t > 0 ? new Date(t).toISOString() : void 0;
|
|
10128
10131
|
}
|
|
10129
|
-
function
|
|
10132
|
+
function Uh(e) {
|
|
10130
10133
|
return typeof e == "string" && e.length > 0 ? e : void 0;
|
|
10131
10134
|
}
|
|
10132
|
-
function
|
|
10135
|
+
function Wh(e) {
|
|
10133
10136
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
10134
10137
|
}
|
|
10135
|
-
async function
|
|
10136
|
-
let t =
|
|
10138
|
+
async function Gh(e) {
|
|
10139
|
+
let t = wh(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");
|
|
10137
10140
|
if (n == null || r == null || i == null || a == null) return {
|
|
10138
10141
|
body: "",
|
|
10139
10142
|
contentType: "text/plain",
|
|
10140
10143
|
outcome: "respond",
|
|
10141
10144
|
status: 404
|
|
10142
10145
|
};
|
|
10143
|
-
let o =
|
|
10144
|
-
return s == null || !
|
|
10146
|
+
let o = Dh(t), s = o.find((t) => t.id == n && Date.parse(t.expiration) > e.now.getTime());
|
|
10147
|
+
return s == null || !Vh(a, await Bh(e.callbackSecret, n)) || s.resourceId != null && s.resourceId != r ? {
|
|
10145
10148
|
body: "",
|
|
10146
10149
|
contentType: "text/plain",
|
|
10147
10150
|
outcome: "respond",
|
|
@@ -10154,14 +10157,14 @@ async function Wh(e) {
|
|
|
10154
10157
|
reason: "Google Drive notification state is not actionable."
|
|
10155
10158
|
} : { outcome: "wake" });
|
|
10156
10159
|
}
|
|
10157
|
-
var
|
|
10158
|
-
initialState:
|
|
10159
|
-
reconcile:
|
|
10160
|
-
receive:
|
|
10160
|
+
var Kh = {
|
|
10161
|
+
initialState: Ch.initialState,
|
|
10162
|
+
reconcile: Ch.reconcile,
|
|
10163
|
+
receive: Gh,
|
|
10161
10164
|
listener: {
|
|
10162
10165
|
intervalMs: 3e5,
|
|
10163
10166
|
async read(e) {
|
|
10164
|
-
let t = await
|
|
10167
|
+
let t = await Mh(e, e.checkpoint);
|
|
10165
10168
|
return {
|
|
10166
10169
|
checkpoint: t.checkpoint,
|
|
10167
10170
|
dedupeKey: t.dedupeKey,
|
|
@@ -10171,8 +10174,8 @@ var Gh = {
|
|
|
10171
10174
|
}
|
|
10172
10175
|
},
|
|
10173
10176
|
snapshot: {
|
|
10174
|
-
...
|
|
10175
|
-
configInputs:
|
|
10177
|
+
...Sh,
|
|
10178
|
+
configInputs: Sh.configInputs,
|
|
10176
10179
|
key: "googledrive.watch_changes",
|
|
10177
10180
|
name: "watch_changes",
|
|
10178
10181
|
displayName: "Watch Changes",
|
|
@@ -10186,12 +10189,12 @@ var Gh = {
|
|
|
10186
10189
|
nullable: !1
|
|
10187
10190
|
}]
|
|
10188
10191
|
}
|
|
10189
|
-
},
|
|
10192
|
+
}, qh = "application/vnd.google-apps.folder", Jh = "nextPageToken,incompleteSearch,files(id,name,mimeType,createdTime,modifiedTime,parents,trashed,webViewLink,driveId,size,version,lastModifyingUser(displayName,emailAddress))", Yh = /* @__PURE__ */ new Set([
|
|
10190
10193
|
"rateLimitExceeded",
|
|
10191
10194
|
"userRateLimitExceeded",
|
|
10192
10195
|
"dailyLimitExceeded",
|
|
10193
10196
|
"sharingRateLimitExceeded"
|
|
10194
|
-
]),
|
|
10197
|
+
]), Xh = /* @__PURE__ */ new Set(["insufficientFilePermissions", "appNotAuthorizedToFile"]), Zh = {
|
|
10195
10198
|
buildOutputs: o,
|
|
10196
10199
|
snapshot: {
|
|
10197
10200
|
configInputs: [
|
|
@@ -10324,16 +10327,16 @@ var Gh = {
|
|
|
10324
10327
|
type: "poll"
|
|
10325
10328
|
},
|
|
10326
10329
|
async poll(e) {
|
|
10327
|
-
let t =
|
|
10328
|
-
if (e.checkpoint === null) return
|
|
10329
|
-
let n =
|
|
10330
|
-
return n.changeType === t.changeType ?
|
|
10331
|
-
checkpoint:
|
|
10330
|
+
let t = Qh(e.config);
|
|
10331
|
+
if (e.checkpoint === null) return eg(e, t);
|
|
10332
|
+
let n = $h(e.checkpoint);
|
|
10333
|
+
return n.changeType === t.changeType ? ng(e, t, n) : {
|
|
10334
|
+
checkpoint: tg(e.now, t.changeType),
|
|
10332
10335
|
events: []
|
|
10333
10336
|
};
|
|
10334
10337
|
}
|
|
10335
10338
|
};
|
|
10336
|
-
function
|
|
10339
|
+
function Qh(e) {
|
|
10337
10340
|
return {
|
|
10338
10341
|
changeType: e.changeType,
|
|
10339
10342
|
driveId: e.driveId,
|
|
@@ -10344,8 +10347,8 @@ function Zh(e) {
|
|
|
10344
10347
|
namePrefix: e.namePrefix
|
|
10345
10348
|
};
|
|
10346
10349
|
}
|
|
10347
|
-
function
|
|
10348
|
-
let t =
|
|
10350
|
+
function $h(e) {
|
|
10351
|
+
let t = gg(e);
|
|
10349
10352
|
if (typeof t?.since != "string" || Number.isNaN(Date.parse(t.since))) throw new r("Google Drive checkpoint is invalid; recreate the Trigger.");
|
|
10350
10353
|
let n = t.boundaryKeys;
|
|
10351
10354
|
return {
|
|
@@ -10358,23 +10361,23 @@ function Qh(e) {
|
|
|
10358
10361
|
...Array.isArray(n) ? { boundaryKeys: n.filter((e) => typeof e == "string") } : {}
|
|
10359
10362
|
};
|
|
10360
10363
|
}
|
|
10361
|
-
async function
|
|
10362
|
-
let n = await
|
|
10364
|
+
async function eg(e, t) {
|
|
10365
|
+
let n = await ug(e, `/drive/v3/files/${encodeURIComponent(t.folderId)}`, {
|
|
10363
10366
|
fields: "id,name,mimeType,driveId,trashed",
|
|
10364
10367
|
supportsAllDrives: "true"
|
|
10365
10368
|
});
|
|
10366
|
-
|
|
10367
|
-
let i =
|
|
10369
|
+
dg(n, "folder probe");
|
|
10370
|
+
let i = gg(n.data);
|
|
10368
10371
|
if (i == null) throw new a("Google Drive folder probe returned no payload.");
|
|
10369
|
-
if (i.mimeType !==
|
|
10372
|
+
if (i.mimeType !== qh) throw new r("Google Drive folderId does not point to a folder.");
|
|
10370
10373
|
if (i.trashed === !0) throw new r("The Google Drive folder is in the trash.");
|
|
10371
10374
|
if (t.driveId.length > 0 && (i.driveId ?? "") !== t.driveId) throw new r("The configured Google Drive shared drive does not contain this folder.");
|
|
10372
10375
|
return {
|
|
10373
|
-
checkpoint:
|
|
10376
|
+
checkpoint: tg(e.now, t.changeType),
|
|
10374
10377
|
events: []
|
|
10375
10378
|
};
|
|
10376
10379
|
}
|
|
10377
|
-
function
|
|
10380
|
+
function tg(e, t) {
|
|
10378
10381
|
let n = e.toISOString();
|
|
10379
10382
|
return {
|
|
10380
10383
|
changeType: t,
|
|
@@ -10382,11 +10385,11 @@ function eg(e, t) {
|
|
|
10382
10385
|
since: n
|
|
10383
10386
|
};
|
|
10384
10387
|
}
|
|
10385
|
-
async function
|
|
10386
|
-
let r =
|
|
10388
|
+
async function ng(e, t, n) {
|
|
10389
|
+
let r = ag(t, n.since, n.floor), i = `${t.driveId}|${r}`, a = n.pageQuery == i ? n.pageToken : void 0, o = await ug(e, "/drive/v3/files", {
|
|
10387
10390
|
corpora: t.driveId.length == 0 ? "allDrives" : "drive",
|
|
10388
10391
|
driveId: t.driveId.length == 0 ? void 0 : t.driveId,
|
|
10389
|
-
fields:
|
|
10392
|
+
fields: Jh,
|
|
10390
10393
|
includeItemsFromAllDrives: "true",
|
|
10391
10394
|
pageSize: t.maxFilesPerPoll,
|
|
10392
10395
|
pageToken: a,
|
|
@@ -10394,74 +10397,74 @@ async function tg(e, t, n) {
|
|
|
10394
10397
|
spaces: "drive",
|
|
10395
10398
|
supportsAllDrives: "true"
|
|
10396
10399
|
});
|
|
10397
|
-
|
|
10398
|
-
let s =
|
|
10400
|
+
dg(o, "files list");
|
|
10401
|
+
let s = gg(o.data) ?? {}, c = new Set(n.boundaryKeys ?? []), l = [], u = [], d = a == null ? void 0 : n.maxSeen;
|
|
10399
10402
|
for (let e of s.files ?? []) {
|
|
10400
10403
|
if (e.id == null || e.id.length == 0) continue;
|
|
10401
|
-
let n =
|
|
10404
|
+
let n = cg(e, t.changeType);
|
|
10402
10405
|
if (n == null) continue;
|
|
10403
|
-
let r =
|
|
10404
|
-
u.push(r.dedupeKey),
|
|
10406
|
+
let r = lg(e, e.id, n, t.changeType);
|
|
10407
|
+
u.push(r.dedupeKey), hg(n, d) && (d = n), c.has(r.dedupeKey) || l.push(r);
|
|
10405
10408
|
}
|
|
10406
10409
|
if (s.incompleteSearch === !0) {
|
|
10407
|
-
let e = a == null ? {} :
|
|
10410
|
+
let e = a == null ? {} : rg(a, i, d);
|
|
10408
10411
|
return {
|
|
10409
|
-
checkpoint:
|
|
10412
|
+
checkpoint: ig(n, t.changeType, n.since, u, e),
|
|
10410
10413
|
events: l
|
|
10411
10414
|
};
|
|
10412
10415
|
}
|
|
10413
10416
|
if (s.nextPageToken) return {
|
|
10414
|
-
checkpoint:
|
|
10417
|
+
checkpoint: ig(n, t.changeType, n.since, u, rg(s.nextPageToken, i, d)),
|
|
10415
10418
|
events: l,
|
|
10416
10419
|
hasMore: !0
|
|
10417
10420
|
};
|
|
10418
10421
|
let f = d ?? n.since;
|
|
10419
10422
|
return {
|
|
10420
|
-
checkpoint:
|
|
10423
|
+
checkpoint: ig(n, t.changeType, f, u),
|
|
10421
10424
|
events: l
|
|
10422
10425
|
};
|
|
10423
10426
|
}
|
|
10424
|
-
function
|
|
10427
|
+
function rg(e, t, n) {
|
|
10425
10428
|
return {
|
|
10426
10429
|
pageQuery: t,
|
|
10427
10430
|
pageToken: e,
|
|
10428
10431
|
...n == null ? {} : { maxSeen: n }
|
|
10429
10432
|
};
|
|
10430
10433
|
}
|
|
10431
|
-
function
|
|
10434
|
+
function ig(e, t, n, r, i = {}) {
|
|
10432
10435
|
let a = [.../* @__PURE__ */ new Set([...e.boundaryKeys ?? [], ...r])].map((e) => ({
|
|
10433
10436
|
at: Date.parse(e.slice(e.indexOf(":") + 1)),
|
|
10434
10437
|
key: e
|
|
10435
|
-
})).filter(({ at: t }) => t >=
|
|
10438
|
+
})).filter(({ at: t }) => t >= og(n, e.floor)).toSorted((e, t) => t.at - e.at).slice(0, 200).map(({ key: e }) => e);
|
|
10436
10439
|
return {
|
|
10437
10440
|
changeType: t,
|
|
10438
10441
|
since: n,
|
|
10439
|
-
...
|
|
10442
|
+
...sg(e.floor, n),
|
|
10440
10443
|
...i,
|
|
10441
10444
|
...a.length == 0 ? {} : { boundaryKeys: a }
|
|
10442
10445
|
};
|
|
10443
10446
|
}
|
|
10444
|
-
function
|
|
10447
|
+
function ag(e, t, n) {
|
|
10445
10448
|
let r = e.changeType == "created" ? "createdTime" : "modifiedTime", i = [
|
|
10446
|
-
`'${
|
|
10449
|
+
`'${mg(e.folderId)}' in parents`,
|
|
10447
10450
|
"trashed = false",
|
|
10448
|
-
`${r} >= '${new Date(
|
|
10451
|
+
`${r} >= '${new Date(og(t, n)).toISOString()}'`
|
|
10449
10452
|
];
|
|
10450
|
-
return e.itemTypes.has("folder") ? e.itemTypes.has("file") || i.push(`mimeType = '${
|
|
10453
|
+
return e.itemTypes.has("folder") ? e.itemTypes.has("file") || i.push(`mimeType = '${qh}'`) : i.push(`mimeType != '${qh}'`), e.mimeTypes.length > 0 && i.push(`(${e.mimeTypes.map((e) => `mimeType = '${mg(e)}'`).join(" or ")})`), e.namePrefix.length > 0 && i.push(`name contains '${mg(e.namePrefix)}'`), i.join(" and ");
|
|
10451
10454
|
}
|
|
10452
|
-
function
|
|
10455
|
+
function og(e, t) {
|
|
10453
10456
|
let n = Date.parse(e) - 6e4, r = t == null ? NaN : Date.parse(t);
|
|
10454
10457
|
return Number.isNaN(r) ? n : Math.max(n, r);
|
|
10455
10458
|
}
|
|
10456
|
-
function
|
|
10459
|
+
function sg(e, t) {
|
|
10457
10460
|
return e == null || Number.isNaN(Date.parse(e)) || Date.parse(t) - 6e4 >= Date.parse(e) ? {} : { floor: e };
|
|
10458
10461
|
}
|
|
10459
|
-
function
|
|
10462
|
+
function cg(e, t) {
|
|
10460
10463
|
let n = t == "created" ? e.createdTime : e.modifiedTime;
|
|
10461
10464
|
return n == null || n.length == 0 || Number.isNaN(Date.parse(n)) ? void 0 : n;
|
|
10462
10465
|
}
|
|
10463
|
-
function
|
|
10464
|
-
let i = e.mimeType ==
|
|
10466
|
+
function lg(e, t, n, r) {
|
|
10467
|
+
let i = e.mimeType == qh ? "folder" : "file", a = e.lastModifyingUser;
|
|
10465
10468
|
return {
|
|
10466
10469
|
dedupeKey: `${t}:${n}`,
|
|
10467
10470
|
payload: {
|
|
@@ -10483,7 +10486,7 @@ function cg(e, t, n, r) {
|
|
|
10483
10486
|
}
|
|
10484
10487
|
};
|
|
10485
10488
|
}
|
|
10486
|
-
async function
|
|
10489
|
+
async function ug(e, t, n) {
|
|
10487
10490
|
try {
|
|
10488
10491
|
return await e.connector.execute({
|
|
10489
10492
|
endpoint: t,
|
|
@@ -10494,48 +10497,48 @@ async function lg(e, t, n) {
|
|
|
10494
10497
|
throw new a(`Google Drive proxy request to ${t} failed.`, { cause: e });
|
|
10495
10498
|
}
|
|
10496
10499
|
}
|
|
10497
|
-
function
|
|
10500
|
+
function dg(e, t) {
|
|
10498
10501
|
if (!(e.status >= 200 && e.status < 300)) {
|
|
10499
10502
|
if (e.status == 400 || e.status == 404) throw new r(`Google Drive ${t} rejected the configuration.`);
|
|
10500
10503
|
if (e.status == 401) throw new i(`Google Drive ${t} rejected the Connection.`);
|
|
10501
10504
|
if (e.status == 403) {
|
|
10502
|
-
let n =
|
|
10503
|
-
if (n.some((e) =>
|
|
10504
|
-
if (n.some((e) =>
|
|
10505
|
-
if (
|
|
10505
|
+
let n = fg(e.data);
|
|
10506
|
+
if (n.some((e) => Yh.has(e))) throw new a(`Google Drive ${t} was rate limited.`);
|
|
10507
|
+
if (n.some((e) => Xh.has(e))) throw new r(`Google Drive ${t} was rejected by an ACL.`);
|
|
10508
|
+
if (pg(e.data)) throw new i(`Google Drive ${t} needs additional scopes.`);
|
|
10506
10509
|
}
|
|
10507
10510
|
throw new a(`Google Drive ${t} failed with status ${e.status}.`);
|
|
10508
10511
|
}
|
|
10509
10512
|
}
|
|
10510
|
-
function dg(e) {
|
|
10511
|
-
let t = hg(hg(e)?.error);
|
|
10512
|
-
return [...[t?.errors, t?.details].flatMap((e) => Array.isArray(e) ? e : []).map((e) => hg(e)?.reason), t?.status].filter((e) => typeof e == "string");
|
|
10513
|
-
}
|
|
10514
10513
|
function fg(e) {
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
return typeof t == "string" && t.toLowerCase().includes("insufficient authentication scopes");
|
|
10514
|
+
let t = gg(gg(e)?.error);
|
|
10515
|
+
return [...[t?.errors, t?.details].flatMap((e) => Array.isArray(e) ? e : []).map((e) => gg(e)?.reason), t?.status].filter((e) => typeof e == "string");
|
|
10518
10516
|
}
|
|
10519
10517
|
function pg(e) {
|
|
10518
|
+
if (fg(e).includes("ACCESS_TOKEN_SCOPE_INSUFFICIENT")) return !0;
|
|
10519
|
+
let t = gg(gg(e)?.error)?.message;
|
|
10520
|
+
return typeof t == "string" && t.toLowerCase().includes("insufficient authentication scopes");
|
|
10521
|
+
}
|
|
10522
|
+
function mg(e) {
|
|
10520
10523
|
return e.replaceAll("\\", "\\\\").replaceAll("'", "\\'");
|
|
10521
10524
|
}
|
|
10522
|
-
function
|
|
10525
|
+
function hg(e, t) {
|
|
10523
10526
|
let n = Date.parse(e);
|
|
10524
10527
|
return Number.isNaN(n) ? !1 : t == null || Number.isNaN(Date.parse(t)) || n > Date.parse(t);
|
|
10525
10528
|
}
|
|
10526
|
-
function
|
|
10529
|
+
function gg(e) {
|
|
10527
10530
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
10528
10531
|
}
|
|
10529
10532
|
//#endregion
|
|
10530
10533
|
//#region src/trigger/providers/google-sheets/on-row-added.ts
|
|
10531
|
-
var
|
|
10534
|
+
var _g = [
|
|
10532
10535
|
"permission_denied",
|
|
10533
10536
|
"accessnotconfigured",
|
|
10534
10537
|
"insufficientfilepermissions",
|
|
10535
10538
|
"appnotauthorizedtofile",
|
|
10536
10539
|
"the caller does not have permission",
|
|
10537
10540
|
"has not been used in project"
|
|
10538
|
-
],
|
|
10541
|
+
], vg = ["ratelimitexceeded", "dailylimitexceeded"], yg = {
|
|
10539
10542
|
buildOutputs: o,
|
|
10540
10543
|
snapshot: {
|
|
10541
10544
|
configInputs: [
|
|
@@ -10654,19 +10657,19 @@ var gg = [
|
|
|
10654
10657
|
type: "poll"
|
|
10655
10658
|
},
|
|
10656
10659
|
async poll(e) {
|
|
10657
|
-
let t =
|
|
10660
|
+
let t = bg(e.config);
|
|
10658
10661
|
if (e.checkpoint === null) return {
|
|
10659
|
-
checkpoint: await
|
|
10662
|
+
checkpoint: await Cg(e, t, await Sg(e, t)),
|
|
10660
10663
|
events: []
|
|
10661
10664
|
};
|
|
10662
|
-
let n =
|
|
10665
|
+
let n = xg(e.checkpoint), r = await Sg(e, t);
|
|
10663
10666
|
if (n.spreadsheetId !== t.spreadsheetId || n.sheetId !== r.sheetId || n.lastRowNumber > r.rowCount) return {
|
|
10664
|
-
checkpoint: await
|
|
10667
|
+
checkpoint: await Cg(e, t, r),
|
|
10665
10668
|
events: []
|
|
10666
10669
|
};
|
|
10667
|
-
let i = await
|
|
10670
|
+
let i = await Tg(e, t, r), a = Math.min(Math.max(t.firstDataRow, n.lastRowNumber), r.rowCount), o = Math.min(a + t.maxRowsPerPoll, r.rowCount), s = await Eg(e, t, r, a, o, "row window fetch");
|
|
10668
10671
|
if (s.length == 0 && n.lastRowNumber >= t.firstDataRow) return {
|
|
10669
|
-
checkpoint: await
|
|
10672
|
+
checkpoint: await Cg(e, t, r),
|
|
10670
10673
|
events: []
|
|
10671
10674
|
};
|
|
10672
10675
|
let c = a + s.length - 1;
|
|
@@ -10678,11 +10681,11 @@ var gg = [
|
|
|
10678
10681
|
for (let [e, o] of s.entries()) {
|
|
10679
10682
|
let s = a + e;
|
|
10680
10683
|
if (!(s <= n.lastRowNumber)) {
|
|
10681
|
-
if (s == t.headerRow ||
|
|
10684
|
+
if (s == t.headerRow || Og(o)) {
|
|
10682
10685
|
u += 1;
|
|
10683
10686
|
continue;
|
|
10684
10687
|
}
|
|
10685
|
-
l.push(await
|
|
10688
|
+
l.push(await kg(t, r, s, o, i));
|
|
10686
10689
|
}
|
|
10687
10690
|
}
|
|
10688
10691
|
let d = c == o && o < r.rowCount;
|
|
@@ -10698,7 +10701,7 @@ var gg = [
|
|
|
10698
10701
|
};
|
|
10699
10702
|
}
|
|
10700
10703
|
};
|
|
10701
|
-
function
|
|
10704
|
+
function bg(e) {
|
|
10702
10705
|
let t = e.columnRange.trim(), n = t.indexOf(":"), r = n < 0 ? t : t.slice(0, n), i = n < 0 ? t : t.slice(n + 1), a = e.spreadsheetId.trim();
|
|
10703
10706
|
return {
|
|
10704
10707
|
colEnd: i,
|
|
@@ -10712,8 +10715,8 @@ function yg(e) {
|
|
|
10712
10715
|
valueRender: e.valueRender
|
|
10713
10716
|
};
|
|
10714
10717
|
}
|
|
10715
|
-
function
|
|
10716
|
-
let t =
|
|
10718
|
+
function xg(e) {
|
|
10719
|
+
let t = Fg(e);
|
|
10717
10720
|
if (typeof t?.spreadsheetId != "string" || !Number.isInteger(t.sheetId) || !Number.isInteger(t.lastRowNumber)) throw new r("Google Sheets checkpoint is invalid; recreate the Trigger.");
|
|
10718
10721
|
return {
|
|
10719
10722
|
lastRowNumber: t.lastRowNumber,
|
|
@@ -10721,11 +10724,11 @@ function bg(e) {
|
|
|
10721
10724
|
spreadsheetId: t.spreadsheetId
|
|
10722
10725
|
};
|
|
10723
10726
|
}
|
|
10724
|
-
async function
|
|
10725
|
-
let n = await
|
|
10727
|
+
async function Sg(e, t) {
|
|
10728
|
+
let n = await jg(e, `/spreadsheets/${encodeURIComponent(t.spreadsheetId)}`, { fields: "sheets.properties(sheetId,title,sheetType,gridProperties)" });
|
|
10726
10729
|
if (n.status == 404) throw new r("The Google Sheets spreadsheet was not found.");
|
|
10727
|
-
|
|
10728
|
-
let i =
|
|
10730
|
+
Mg(n, "spreadsheet metadata fetch");
|
|
10731
|
+
let i = Fg(n.data)?.sheets, o = (Array.isArray(i) ? i.map((e) => Fg(Fg(e)?.properties)) : []).filter((e) => e != null), s = (/^\d+$/.test(t.sheet) ? o.find(({ sheetId: e }) => e === Number(t.sheet)) : void 0) ?? o.find(({ title: e }) => e === t.sheet);
|
|
10729
10732
|
if (s == null) throw new r(`Google Sheets tab "${t.sheet}" does not exist.`);
|
|
10730
10733
|
if (s.sheetType != null && s.sheetType !== "GRID") throw new r("The Google Sheets tab is not a grid sheet.");
|
|
10731
10734
|
let c = s.gridProperties?.rowCount;
|
|
@@ -10736,45 +10739,45 @@ async function xg(e, t) {
|
|
|
10736
10739
|
title: s.title
|
|
10737
10740
|
};
|
|
10738
10741
|
}
|
|
10739
|
-
async function
|
|
10742
|
+
async function Cg(e, t, n) {
|
|
10740
10743
|
return {
|
|
10741
|
-
lastRowNumber: await
|
|
10744
|
+
lastRowNumber: await wg(e, t, n),
|
|
10742
10745
|
sheetId: n.sheetId,
|
|
10743
10746
|
spreadsheetId: t.spreadsheetId
|
|
10744
10747
|
};
|
|
10745
10748
|
}
|
|
10746
|
-
async function
|
|
10749
|
+
async function wg(e, t, n) {
|
|
10747
10750
|
if (n.rowCount < t.firstDataRow) return t.firstDataRow - 1;
|
|
10748
|
-
let r = await
|
|
10751
|
+
let r = await Eg(e, t, n, t.firstDataRow, n.rowCount, "full-range scan");
|
|
10749
10752
|
return r.length == 0 ? t.firstDataRow - 1 : t.firstDataRow + r.length - 1;
|
|
10750
10753
|
}
|
|
10751
|
-
async function
|
|
10752
|
-
let r = await
|
|
10754
|
+
async function Tg(e, t, n) {
|
|
10755
|
+
let r = await jg(e, Ag(t, n, t.headerRow, t.headerRow), {
|
|
10753
10756
|
majorDimension: "ROWS",
|
|
10754
10757
|
valueRenderOption: "FORMATTED_VALUE"
|
|
10755
10758
|
});
|
|
10756
|
-
return
|
|
10759
|
+
return Mg(r, "header row fetch"), Dg(r.data)[0] ?? [];
|
|
10757
10760
|
}
|
|
10758
|
-
async function
|
|
10759
|
-
let o = await
|
|
10761
|
+
async function Eg(e, t, n, r, i, a) {
|
|
10762
|
+
let o = await jg(e, Ag(t, n, r, i), {
|
|
10760
10763
|
dateTimeRenderOption: t.dateTimeRender,
|
|
10761
10764
|
majorDimension: "ROWS",
|
|
10762
10765
|
valueRenderOption: t.valueRender
|
|
10763
10766
|
});
|
|
10764
|
-
return
|
|
10767
|
+
return Mg(o, a), Dg(o.data);
|
|
10765
10768
|
}
|
|
10766
|
-
function
|
|
10767
|
-
let t =
|
|
10769
|
+
function Dg(e) {
|
|
10770
|
+
let t = Fg(e)?.values;
|
|
10768
10771
|
return Array.isArray(t) ? t : [];
|
|
10769
10772
|
}
|
|
10770
|
-
function
|
|
10773
|
+
function Og(e) {
|
|
10771
10774
|
return e.every((e) => e === "" || e == null);
|
|
10772
10775
|
}
|
|
10773
|
-
async function
|
|
10774
|
-
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 =
|
|
10776
|
+
async function kg(e, t, n, r, i) {
|
|
10777
|
+
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 = Ng(e.colStart);
|
|
10775
10778
|
for (let [e, t] of r.entries()) {
|
|
10776
10779
|
let n = i[e];
|
|
10777
|
-
s[typeof n == "string" && n.length > 0 ? n :
|
|
10780
|
+
s[typeof n == "string" && n.length > 0 ? n : Pg(c + e)] = t;
|
|
10778
10781
|
}
|
|
10779
10782
|
return {
|
|
10780
10783
|
dedupeKey: `${t.sheetId}:${n}:${o}`,
|
|
@@ -10788,11 +10791,11 @@ async function Og(e, t, n, r, i) {
|
|
|
10788
10791
|
}
|
|
10789
10792
|
};
|
|
10790
10793
|
}
|
|
10791
|
-
function
|
|
10794
|
+
function Ag(e, t, n, r) {
|
|
10792
10795
|
let i = encodeURIComponent(`'${t.title.replaceAll("'", "''")}'`);
|
|
10793
10796
|
return `/spreadsheets/${encodeURIComponent(e.spreadsheetId)}/values/${i}!${e.colStart}${n}:${e.colEnd}${r}`;
|
|
10794
10797
|
}
|
|
10795
|
-
async function
|
|
10798
|
+
async function jg(e, t, n) {
|
|
10796
10799
|
try {
|
|
10797
10800
|
return await e.connector.execute({
|
|
10798
10801
|
endpoint: t,
|
|
@@ -10803,32 +10806,32 @@ async function Ag(e, t, n) {
|
|
|
10803
10806
|
throw new a(`Google Sheets proxy request to ${t} failed.`, { cause: e });
|
|
10804
10807
|
}
|
|
10805
10808
|
}
|
|
10806
|
-
function
|
|
10809
|
+
function Mg(e, t) {
|
|
10807
10810
|
if (e.status >= 200 && e.status < 300) return;
|
|
10808
10811
|
if (e.status == 401) throw new i(`Google Sheets ${t} rejected the Connection.`);
|
|
10809
10812
|
let n = JSON.stringify(e.data ?? null).toLowerCase();
|
|
10810
10813
|
if (e.status == 403) {
|
|
10811
|
-
if (
|
|
10812
|
-
if (
|
|
10814
|
+
if (vg.some((e) => n.includes(e))) throw new a(`Google Sheets ${t} was rate limited.`);
|
|
10815
|
+
if (_g.some((e) => n.includes(e))) throw new i(`Google Sheets ${t} rejected the Connection.`);
|
|
10813
10816
|
}
|
|
10814
10817
|
throw e.status == 400 && n.includes("unable to parse range") ? new r("Google Sheets rejected the configured range.") : e.status == 413 ? new r("Google Sheets response is too large; narrow columnRange.") : new a(`Google Sheets ${t} failed with status ${e.status}.`);
|
|
10815
10818
|
}
|
|
10816
|
-
function
|
|
10819
|
+
function Ng(e) {
|
|
10817
10820
|
let t = 0;
|
|
10818
10821
|
for (let n of e.toUpperCase()) t = t * 26 + n.charCodeAt(0) - 64;
|
|
10819
10822
|
return t;
|
|
10820
10823
|
}
|
|
10821
|
-
function
|
|
10824
|
+
function Pg(e) {
|
|
10822
10825
|
let t = "";
|
|
10823
10826
|
for (let n = e; n > 0; n = Math.floor((n - 1) / 26)) t = String.fromCharCode(65 + (n - 1) % 26) + t;
|
|
10824
10827
|
return t;
|
|
10825
10828
|
}
|
|
10826
|
-
function
|
|
10829
|
+
function Fg(e) {
|
|
10827
10830
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
10828
10831
|
}
|
|
10829
10832
|
//#endregion
|
|
10830
10833
|
//#region src/trigger/providers/linear/on-issue-changed.ts
|
|
10831
|
-
var
|
|
10834
|
+
var Ig = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$", Lg = new RegExp(Ig), Rg = 6e4, zg = 50, Bg = {
|
|
10832
10835
|
buildOutputs: o,
|
|
10833
10836
|
snapshot: {
|
|
10834
10837
|
configInputs: [{
|
|
@@ -10836,7 +10839,7 @@ var Fg = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
10836
10839
|
jsonSchema: {
|
|
10837
10840
|
title: "Team ID",
|
|
10838
10841
|
type: "string",
|
|
10839
|
-
pattern:
|
|
10842
|
+
pattern: Ig
|
|
10840
10843
|
},
|
|
10841
10844
|
nullable: !1,
|
|
10842
10845
|
description: "Linear Team UUID. Use Copy model UUID in Linear to find it."
|
|
@@ -10847,7 +10850,7 @@ var Fg = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
10847
10850
|
type: "array",
|
|
10848
10851
|
items: {
|
|
10849
10852
|
type: "string",
|
|
10850
|
-
pattern:
|
|
10853
|
+
pattern: Ig
|
|
10851
10854
|
},
|
|
10852
10855
|
uniqueItems: !0,
|
|
10853
10856
|
maxItems: 50
|
|
@@ -10908,12 +10911,12 @@ var Fg = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
10908
10911
|
provider: "linear",
|
|
10909
10912
|
type: "poll"
|
|
10910
10913
|
},
|
|
10911
|
-
configOptions:
|
|
10914
|
+
configOptions: Gg,
|
|
10912
10915
|
async poll(e) {
|
|
10913
10916
|
let t = typeof e.config.teamId == "string" ? e.config.teamId.toLowerCase() : e.config.teamId, n = e.config.stateIds;
|
|
10914
|
-
if (typeof t != "string" || !
|
|
10917
|
+
if (typeof t != "string" || !Lg.test(t) || !Array.isArray(n) || n.length > 50 || n.some((e) => typeof e != "string" || !Lg.test(e))) throw new r("Linear Issue configuration is invalid.");
|
|
10915
10918
|
if (e.checkpoint == null) {
|
|
10916
|
-
|
|
10919
|
+
Ug((await Wg(e, "query LinearTeam($teamId: String!) { team(id: $teamId) { id } }", { teamId: t })).team, t);
|
|
10917
10920
|
let n = e.now.toISOString();
|
|
10918
10921
|
return {
|
|
10919
10922
|
checkpoint: {
|
|
@@ -10923,10 +10926,10 @@ var Fg = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
10923
10926
|
events: []
|
|
10924
10927
|
};
|
|
10925
10928
|
}
|
|
10926
|
-
let i =
|
|
10929
|
+
let i = Vg(e.checkpoint), o = i.until ?? new Date(Math.max(e.now.getTime(), Date.parse(i.since))).toISOString(), s = new Date(Math.max(Date.parse(i.startedAt), Date.parse(i.since) - Rg)).toISOString(), l = Ug((await Wg(e, `query LinearIssueChanges($teamId: String!, $filter: IssueFilter!, $after: String) {
|
|
10927
10930
|
team(id: $teamId) {
|
|
10928
10931
|
id
|
|
10929
|
-
issues(first: ${
|
|
10932
|
+
issues(first: ${zg}, after: $after, orderBy: updatedAt, includeArchived: true, filter: $filter) {
|
|
10930
10933
|
nodes { id identifier title url createdAt updatedAt state { id name type } }
|
|
10931
10934
|
pageInfo { hasNextPage endCursor }
|
|
10932
10935
|
}
|
|
@@ -10942,11 +10945,11 @@ var Fg = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
10942
10945
|
...n.length == 0 ? {} : { state: { id: { in: n } } }
|
|
10943
10946
|
}
|
|
10944
10947
|
})).team, t).issues;
|
|
10945
|
-
if (!c(l) || !Array.isArray(l.nodes) || l.nodes.length >
|
|
10948
|
+
if (!c(l) || !Array.isArray(l.nodes) || l.nodes.length > zg || !c(l.pageInfo) || typeof l.pageInfo.hasNextPage != "boolean") throw new a("Linear returned an invalid Issue page.");
|
|
10946
10949
|
let { hasNextPage: u, endCursor: d } = l.pageInfo;
|
|
10947
10950
|
if (u && (typeof d != "string" || d.length == 0 || d.length > 4096 || d == i.after || l.nodes.length == 0)) throw new a("Linear returned an invalid continuation cursor.");
|
|
10948
10951
|
let f = l.nodes.map((e) => {
|
|
10949
|
-
if (!c(e) || typeof e.id != "string" || !
|
|
10952
|
+
if (!c(e) || typeof e.id != "string" || !Lg.test(e.id) || typeof e.identifier != "string" || e.identifier.length == 0 || typeof e.title != "string" || typeof e.url != "string" || !Hg(e.createdAt) || !Hg(e.updatedAt) || Date.parse(e.createdAt) > Date.parse(e.updatedAt) || Date.parse(e.updatedAt) < Date.parse(s) || Date.parse(e.updatedAt) > Date.parse(o) || !c(e.state) || typeof e.state.id != "string" || !Lg.test(e.state.id) || typeof e.state.name != "string" || typeof e.state.type != "string" || n.length > 0 && !n.includes(e.state.id)) throw new a("Linear returned an invalid Issue.");
|
|
10950
10953
|
return {
|
|
10951
10954
|
dedupeKey: `${e.id}:${e.updatedAt}`,
|
|
10952
10955
|
payload: {
|
|
@@ -10979,8 +10982,8 @@ var Fg = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
10979
10982
|
};
|
|
10980
10983
|
}
|
|
10981
10984
|
};
|
|
10982
|
-
function
|
|
10983
|
-
if (!c(e) || !
|
|
10985
|
+
function Vg(e) {
|
|
10986
|
+
if (!c(e) || !Hg(e.startedAt) || !Hg(e.since) || Date.parse(e.since) < Date.parse(e.startedAt) || e.until != null && (!Hg(e.until) || Date.parse(e.until) < Date.parse(e.since)) || e.after != null && (typeof e.after != "string" || e.after.length == 0 || e.after.length > 4096 || e.until == null)) throw new r("Linear Issue checkpoint is invalid.");
|
|
10984
10987
|
return {
|
|
10985
10988
|
startedAt: e.startedAt,
|
|
10986
10989
|
since: e.since,
|
|
@@ -10988,15 +10991,15 @@ function Bg(e) {
|
|
|
10988
10991
|
...typeof e.after == "string" ? { after: e.after } : {}
|
|
10989
10992
|
};
|
|
10990
10993
|
}
|
|
10991
|
-
function
|
|
10994
|
+
function Hg(e) {
|
|
10992
10995
|
return typeof e == "string" && e.length <= 40 && /^\d{4}-\d{2}-\d{2}T/.test(e) && Number.isFinite(Date.parse(e));
|
|
10993
10996
|
}
|
|
10994
|
-
function
|
|
10997
|
+
function Ug(e, t) {
|
|
10995
10998
|
if (e === null) throw new r("The Linear team is unavailable or not accessible to this Connection.");
|
|
10996
10999
|
if (!c(e) || e.id !== t) throw new a("Linear returned an invalid Team.");
|
|
10997
11000
|
return e;
|
|
10998
11001
|
}
|
|
10999
|
-
async function
|
|
11002
|
+
async function Wg(e, t, n) {
|
|
11000
11003
|
e.signal?.throwIfAborted();
|
|
11001
11004
|
let o = await e.connector.execute({
|
|
11002
11005
|
endpoint: "/graphql",
|
|
@@ -11016,19 +11019,19 @@ async function Ug(e, t, n) {
|
|
|
11016
11019
|
if (o.status != 200 || !c(s) || !c(s.data) || s.errors != null && !Array.isArray(s.errors)) throw new a(`Linear returned an invalid query response (HTTP ${o.status}).`);
|
|
11017
11020
|
return s.data;
|
|
11018
11021
|
}
|
|
11019
|
-
async function
|
|
11022
|
+
async function Gg(e) {
|
|
11020
11023
|
let { field: t, config: n } = e;
|
|
11021
11024
|
if (t != "teamId" && t != "stateIds") throw new r("Unknown Linear configuration field.");
|
|
11022
|
-
if (t == "stateIds" && (typeof n.teamId != "string" || !
|
|
11025
|
+
if (t == "stateIds" && (typeof n.teamId != "string" || !Lg.test(n.teamId))) throw new r("Select a Linear Team first.");
|
|
11023
11026
|
let i = [], o = /* @__PURE__ */ new Set(), s = null;
|
|
11024
11027
|
for (let r = 0; r < 10; r++) {
|
|
11025
|
-
let r = await
|
|
11028
|
+
let r = await Wg(e, t == "teamId" ? "query LinearTeams($after: String) { teams(first: 100, after: $after) { nodes { id name key } pageInfo { hasNextPage endCursor } } }" : "query LinearStates($teamId: String!, $after: String) { team(id: $teamId) { id states(first: 100, after: $after) { nodes { id name color position } pageInfo { hasNextPage endCursor } } } }", {
|
|
11026
11029
|
after: s,
|
|
11027
11030
|
...t == "teamId" ? {} : { teamId: n.teamId }
|
|
11028
|
-
}), l = t == "teamId" ? r.teams :
|
|
11031
|
+
}), l = t == "teamId" ? r.teams : Ug(r.team, String(n.teamId)).states;
|
|
11029
11032
|
if (!c(l) || !Array.isArray(l.nodes) || l.nodes.length > 100 || !c(l.pageInfo) || typeof l.pageInfo.hasNextPage != "boolean") throw new a("Linear returned invalid configuration options.");
|
|
11030
11033
|
for (let e of l.nodes) {
|
|
11031
|
-
if (!c(e) || typeof e.id != "string" || !
|
|
11034
|
+
if (!c(e) || typeof e.id != "string" || !Lg.test(e.id) || typeof e.name != "string" || e.name.length == 0 || (t == "teamId" ? typeof e.key != "string" : typeof e.color != "string" || !/^#[0-9a-fA-F]{6}$/.test(e.color))) throw new a("Linear returned an invalid configuration option.");
|
|
11032
11035
|
i.push({
|
|
11033
11036
|
value: e.id,
|
|
11034
11037
|
label: t == "teamId" ? `${e.name} (${e.key})` : e.name,
|
|
@@ -11042,7 +11045,7 @@ async function Wg(e) {
|
|
|
11042
11045
|
}
|
|
11043
11046
|
throw new r("The Linear options list exceeds the supported limit of 1000 entries.");
|
|
11044
11047
|
}
|
|
11045
|
-
var
|
|
11048
|
+
var Kg = {
|
|
11046
11049
|
buildOutputs: o,
|
|
11047
11050
|
snapshot: {
|
|
11048
11051
|
configInputs: [
|
|
@@ -11142,13 +11145,13 @@ var Gg = {
|
|
|
11142
11145
|
type: "poll"
|
|
11143
11146
|
},
|
|
11144
11147
|
async poll(e) {
|
|
11145
|
-
let t =
|
|
11146
|
-
if (e.checkpoint === null) return
|
|
11147
|
-
let n =
|
|
11148
|
-
return n.target ===
|
|
11148
|
+
let t = qg(e.config);
|
|
11149
|
+
if (e.checkpoint === null) return Jg(e, t);
|
|
11150
|
+
let n = Xg(e.checkpoint);
|
|
11151
|
+
return n.target === c_(t) ? $g(e, t, Qg(n, Zg(t.events))) : Jg(e, t);
|
|
11149
11152
|
}
|
|
11150
11153
|
};
|
|
11151
|
-
function
|
|
11154
|
+
function qg(e) {
|
|
11152
11155
|
return {
|
|
11153
11156
|
dataSourceId: e.dataSourceId,
|
|
11154
11157
|
databaseId: e.databaseId,
|
|
@@ -11157,9 +11160,9 @@ function Kg(e) {
|
|
|
11157
11160
|
maxItemsPerPoll: e.maxItemsPerPoll
|
|
11158
11161
|
};
|
|
11159
11162
|
}
|
|
11160
|
-
async function
|
|
11161
|
-
let n = await
|
|
11162
|
-
return
|
|
11163
|
+
async function Jg(e, t) {
|
|
11164
|
+
let n = await Yg(e, t), r = Zg(t.events);
|
|
11165
|
+
return s_(await o_(e, {
|
|
11163
11166
|
body: {
|
|
11164
11167
|
page_size: 1,
|
|
11165
11168
|
sorts: [{
|
|
@@ -11174,31 +11177,31 @@ async function qg(e, t) {
|
|
|
11174
11177
|
cursorField: r,
|
|
11175
11178
|
dataSourceId: n,
|
|
11176
11179
|
since: (/* @__PURE__ */ new Date(Math.ceil(e.now.getTime() / 6e4) * 6e4)).toISOString(),
|
|
11177
|
-
target:
|
|
11180
|
+
target: c_(t)
|
|
11178
11181
|
},
|
|
11179
11182
|
events: []
|
|
11180
11183
|
};
|
|
11181
11184
|
}
|
|
11182
|
-
async function
|
|
11183
|
-
let n = await
|
|
11185
|
+
async function Yg(e, t) {
|
|
11186
|
+
let n = await o_(e, {
|
|
11184
11187
|
endpoint: `/databases/${encodeURIComponent(t.databaseId)}`,
|
|
11185
11188
|
method: "GET"
|
|
11186
11189
|
});
|
|
11187
|
-
|
|
11188
|
-
let i =
|
|
11189
|
-
let t =
|
|
11190
|
+
s_(n, "database resolve");
|
|
11191
|
+
let i = m_(n.data)?.data_sources, a = Array.isArray(i) ? i.flatMap((e) => {
|
|
11192
|
+
let t = m_(e)?.id;
|
|
11190
11193
|
return typeof t == "string" && t.length > 0 ? [t] : [];
|
|
11191
11194
|
}) : [];
|
|
11192
11195
|
if (t.dataSourceId.length > 0) {
|
|
11193
|
-
let e =
|
|
11196
|
+
let e = l_(t.dataSourceId), n = a.find((t) => l_(t) == e);
|
|
11194
11197
|
if (n == null) throw new r("The Notion data source does not belong to the configured database.");
|
|
11195
11198
|
return n;
|
|
11196
11199
|
}
|
|
11197
11200
|
if (a.length == 1) return a[0];
|
|
11198
11201
|
throw a.length == 0 ? new r("The Notion database has no data sources.") : new r("The Notion database has multiple data sources; configure dataSourceId.");
|
|
11199
11202
|
}
|
|
11200
|
-
function
|
|
11201
|
-
let t =
|
|
11203
|
+
function Xg(e) {
|
|
11204
|
+
let t = m_(e), n = t?.cursorField;
|
|
11202
11205
|
if (typeof t?.dataSourceId != "string" || t.dataSourceId.length == 0 || n !== "created_time" && n !== "last_edited_time" || typeof t.since != "string" || t.since.length == 0) throw new r("Notion checkpoint is invalid; recreate the Trigger.");
|
|
11203
11206
|
return {
|
|
11204
11207
|
cursorField: n,
|
|
@@ -11210,10 +11213,10 @@ function Yg(e) {
|
|
|
11210
11213
|
...t.sinceOnly === !0 ? { sinceOnly: !0 } : {}
|
|
11211
11214
|
};
|
|
11212
11215
|
}
|
|
11213
|
-
function
|
|
11216
|
+
function Zg(e) {
|
|
11214
11217
|
return e.length == 1 && e[0] == "page_added" ? "created_time" : "last_edited_time";
|
|
11215
11218
|
}
|
|
11216
|
-
function
|
|
11219
|
+
function Qg(e, t) {
|
|
11217
11220
|
return e.cursorField == t ? e : {
|
|
11218
11221
|
cursorField: t,
|
|
11219
11222
|
dataSourceId: e.dataSourceId,
|
|
@@ -11221,11 +11224,11 @@ function Zg(e, t) {
|
|
|
11221
11224
|
target: e.target
|
|
11222
11225
|
};
|
|
11223
11226
|
}
|
|
11224
|
-
async function
|
|
11227
|
+
async function $g(e, t, n) {
|
|
11225
11228
|
let r = [], i = 0, a = 0, o = null, s = n.startCursor, c = null;
|
|
11226
11229
|
for (let l = 0; l < 5; l += 1) {
|
|
11227
|
-
let l = await
|
|
11228
|
-
body:
|
|
11230
|
+
let l = await o_(e, {
|
|
11231
|
+
body: n_(n, t.maxItemsPerPoll - a, s),
|
|
11229
11232
|
endpoint: `/data_sources/${encodeURIComponent(n.dataSourceId)}/query`,
|
|
11230
11233
|
method: "POST"
|
|
11231
11234
|
});
|
|
@@ -11233,14 +11236,14 @@ async function Qg(e, t, n) {
|
|
|
11233
11236
|
c = "restarted";
|
|
11234
11237
|
break;
|
|
11235
11238
|
}
|
|
11236
|
-
|
|
11237
|
-
let u =
|
|
11239
|
+
s_(l, "data source query");
|
|
11240
|
+
let u = m_(l.data) ?? {};
|
|
11238
11241
|
for (let e of u.results ?? []) {
|
|
11239
11242
|
a += 1;
|
|
11240
11243
|
let s = n.cursorField == "created_time" ? e.created_time : e.last_edited_time;
|
|
11241
|
-
s != null && s.length > 0 && (o =
|
|
11242
|
-
let c =
|
|
11243
|
-
t.events.includes(c) ? r.push(
|
|
11244
|
+
s != null && s.length > 0 && (o = d_(o, s));
|
|
11245
|
+
let c = r_(e);
|
|
11246
|
+
t.events.includes(c) ? r.push(i_(e, c, t, n)) : i += 1;
|
|
11244
11247
|
}
|
|
11245
11248
|
if (u.request_status?.type == "incomplete") {
|
|
11246
11249
|
c = "truncated";
|
|
@@ -11266,36 +11269,36 @@ async function Qg(e, t, n) {
|
|
|
11266
11269
|
...l,
|
|
11267
11270
|
since: n.since,
|
|
11268
11271
|
startCursor: c.nextCursor,
|
|
11269
|
-
...
|
|
11272
|
+
...t_(n)
|
|
11270
11273
|
} : {
|
|
11271
11274
|
...l,
|
|
11272
|
-
|
|
11275
|
+
...e_(n, c, o, e.now)
|
|
11273
11276
|
},
|
|
11274
11277
|
events: r,
|
|
11275
11278
|
filtered: i,
|
|
11276
11279
|
...c == "complete" ? {} : { hasMore: !0 }
|
|
11277
11280
|
};
|
|
11278
11281
|
}
|
|
11279
|
-
function
|
|
11282
|
+
function e_(e, t, n, r) {
|
|
11280
11283
|
let i = {
|
|
11281
11284
|
since: e.since,
|
|
11282
|
-
...
|
|
11285
|
+
...t_(e)
|
|
11283
11286
|
}, a = Date.parse(e.since) + 6e4 <= r.getTime() ? {
|
|
11284
11287
|
since: e.since,
|
|
11285
11288
|
sinceExclusive: !0
|
|
11286
11289
|
} : i;
|
|
11287
|
-
return n != null &&
|
|
11290
|
+
return n != null && f_(n, e.since) ? { since: n } : t == "restarted" ? i : t == "complete" ? e.sinceOnly === !0 || n != null ? a : i : n == null ? i : e.sinceOnly === !0 ? a : {
|
|
11288
11291
|
since: e.since,
|
|
11289
11292
|
sinceOnly: !0
|
|
11290
11293
|
};
|
|
11291
11294
|
}
|
|
11292
|
-
function
|
|
11295
|
+
function t_(e) {
|
|
11293
11296
|
return {
|
|
11294
11297
|
...e.sinceExclusive === !0 ? { sinceExclusive: !0 } : {},
|
|
11295
11298
|
...e.sinceOnly === !0 ? { sinceOnly: !0 } : {}
|
|
11296
11299
|
};
|
|
11297
11300
|
}
|
|
11298
|
-
function
|
|
11301
|
+
function n_(e, t, n) {
|
|
11299
11302
|
let r = e.cursorField;
|
|
11300
11303
|
return {
|
|
11301
11304
|
filter: e.sinceOnly === !0 ? { and: [{
|
|
@@ -11316,70 +11319,70 @@ function t_(e, t, n) {
|
|
|
11316
11319
|
...n == null ? {} : { start_cursor: n }
|
|
11317
11320
|
};
|
|
11318
11321
|
}
|
|
11319
|
-
function
|
|
11320
|
-
return
|
|
11322
|
+
function r_(e) {
|
|
11323
|
+
return p_(e.created_time) === p_(e.last_edited_time) ? "page_added" : "page_updated";
|
|
11321
11324
|
}
|
|
11322
|
-
function
|
|
11325
|
+
function i_(e, t, n, r) {
|
|
11323
11326
|
return {
|
|
11324
|
-
dedupeKey: t == "page_added" ? `added:${e.id}` : `updated:${e.id}:${
|
|
11327
|
+
dedupeKey: t == "page_added" ? `added:${e.id}` : `updated:${e.id}:${p_(e.last_edited_time) ?? e.last_edited_time ?? ""}`,
|
|
11325
11328
|
payload: {
|
|
11326
11329
|
createdBy: { id: e.created_by?.id ?? "" },
|
|
11327
11330
|
createdTime: e.created_time ?? "",
|
|
11328
11331
|
dataSourceId: r.dataSourceId,
|
|
11329
|
-
databaseId:
|
|
11332
|
+
databaseId: u_(n.databaseId),
|
|
11330
11333
|
event: t,
|
|
11331
11334
|
lastEditedBy: { id: e.last_edited_by?.id ?? "" },
|
|
11332
11335
|
lastEditedTime: e.last_edited_time ?? "",
|
|
11333
11336
|
pageId: e.id,
|
|
11334
11337
|
...n.includeProperties ? { properties: e.properties ?? {} } : {},
|
|
11335
|
-
title:
|
|
11338
|
+
title: a_(e.properties ?? {}),
|
|
11336
11339
|
url: e.url ?? ""
|
|
11337
11340
|
}
|
|
11338
11341
|
};
|
|
11339
11342
|
}
|
|
11340
|
-
function
|
|
11343
|
+
function a_(e) {
|
|
11341
11344
|
for (let t of Object.values(e)) {
|
|
11342
|
-
let e =
|
|
11343
|
-
if (!(e?.type !== "title" || !Array.isArray(e.title))) return e.title.map((e) => typeof
|
|
11345
|
+
let e = m_(t);
|
|
11346
|
+
if (!(e?.type !== "title" || !Array.isArray(e.title))) return e.title.map((e) => typeof m_(e)?.plain_text == "string" ? m_(e).plain_text : "").join("");
|
|
11344
11347
|
}
|
|
11345
11348
|
return "";
|
|
11346
11349
|
}
|
|
11347
|
-
async function
|
|
11350
|
+
async function o_(e, t) {
|
|
11348
11351
|
try {
|
|
11349
11352
|
return await e.connector.execute(t, e.signal);
|
|
11350
11353
|
} catch (e) {
|
|
11351
11354
|
throw new a(`Notion proxy request to ${t.endpoint} failed.`, { cause: e });
|
|
11352
11355
|
}
|
|
11353
11356
|
}
|
|
11354
|
-
function
|
|
11357
|
+
function s_(e, t) {
|
|
11355
11358
|
if (!(e.status >= 200 && e.status < 300)) throw e.status == 401 || e.status == 403 ? new i(`Notion ${t} rejected the Connection.`) : e.status == 404 ? new r("The Notion target was not found or is not shared with the Connection.") : e.status == 400 ? new r(`Notion ${t} rejected the configuration.`) : new a(`Notion ${t} failed with status ${e.status}.`);
|
|
11356
11359
|
}
|
|
11357
|
-
function
|
|
11360
|
+
function c_(e) {
|
|
11358
11361
|
return `${e.databaseId}|${e.dataSourceId}`;
|
|
11359
11362
|
}
|
|
11360
|
-
function
|
|
11363
|
+
function l_(e) {
|
|
11361
11364
|
return e.replaceAll("-", "").toLowerCase();
|
|
11362
11365
|
}
|
|
11363
|
-
function
|
|
11364
|
-
let t =
|
|
11366
|
+
function u_(e) {
|
|
11367
|
+
let t = l_(e);
|
|
11365
11368
|
return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
|
|
11366
11369
|
}
|
|
11367
|
-
function
|
|
11370
|
+
function d_(e, t) {
|
|
11368
11371
|
let n = Date.parse(t);
|
|
11369
11372
|
return Number.isNaN(n) || e != null && n < Date.parse(e) ? e : t;
|
|
11370
11373
|
}
|
|
11371
|
-
function
|
|
11374
|
+
function f_(e, t) {
|
|
11372
11375
|
return !Number.isNaN(Date.parse(e)) && !Number.isNaN(Date.parse(t)) && Date.parse(e) > Date.parse(t);
|
|
11373
11376
|
}
|
|
11374
|
-
function
|
|
11377
|
+
function p_(e) {
|
|
11375
11378
|
if (e == null || e.length == 0) return null;
|
|
11376
11379
|
let t = Date.parse(e);
|
|
11377
11380
|
return Number.isNaN(t) ? null : new Date(t).toISOString();
|
|
11378
11381
|
}
|
|
11379
|
-
function
|
|
11382
|
+
function m_(e) {
|
|
11380
11383
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
11381
11384
|
}
|
|
11382
|
-
var
|
|
11385
|
+
var h_ = {
|
|
11383
11386
|
buildOutputs: o,
|
|
11384
11387
|
snapshot: {
|
|
11385
11388
|
configInputs: [
|
|
@@ -11496,14 +11499,14 @@ var m_ = {
|
|
|
11496
11499
|
type: "poll"
|
|
11497
11500
|
},
|
|
11498
11501
|
async poll(e) {
|
|
11499
|
-
let t =
|
|
11502
|
+
let t = g_(e.config);
|
|
11500
11503
|
if (e.checkpoint === null) return {
|
|
11501
|
-
checkpoint: await
|
|
11504
|
+
checkpoint: await __(e, t),
|
|
11502
11505
|
events: []
|
|
11503
11506
|
};
|
|
11504
|
-
let n =
|
|
11507
|
+
let n = y_(e.checkpoint), { items: r, next: i } = await b_(e, n, t.maxItemsPerPoll), a = [], o = 0;
|
|
11505
11508
|
for (let [e, i] of r) {
|
|
11506
|
-
let r = await
|
|
11509
|
+
let r = await x_(e, i, t, n);
|
|
11507
11510
|
r != "structural" && (r == "filtered" ? o += 1 : a.push(r));
|
|
11508
11511
|
}
|
|
11509
11512
|
return {
|
|
@@ -11514,7 +11517,7 @@ var m_ = {
|
|
|
11514
11517
|
};
|
|
11515
11518
|
}
|
|
11516
11519
|
};
|
|
11517
|
-
function
|
|
11520
|
+
function g_(e) {
|
|
11518
11521
|
return {
|
|
11519
11522
|
events: e.events,
|
|
11520
11523
|
itemId: e.itemId.trim(),
|
|
@@ -11523,25 +11526,25 @@ function h_(e) {
|
|
|
11523
11526
|
parentFolderId: e.parentFolderId.trim()
|
|
11524
11527
|
};
|
|
11525
11528
|
}
|
|
11526
|
-
async function
|
|
11527
|
-
let n = await
|
|
11529
|
+
async function __(e, t) {
|
|
11530
|
+
let n = await w_(e, "/me/drive/root/delta", { token: "latest" });
|
|
11528
11531
|
if (n.status == 404) throw new r("OneDrive is not provisioned for this account.");
|
|
11529
|
-
|
|
11530
|
-
let i =
|
|
11532
|
+
E_(n, "delta seeding");
|
|
11533
|
+
let i = j_(n.data)?.["@odata.deltaLink"], o = i == null ? null : k_(i);
|
|
11531
11534
|
if (o == null) throw new a("OneDrive delta seeding response has no delta token.");
|
|
11532
|
-
return await
|
|
11535
|
+
return await v_(e, "parentFolderId", t.parentFolderId), await v_(e, "itemId", t.itemId), {
|
|
11533
11536
|
deltaToken: o,
|
|
11534
11537
|
lastPolledAt: e.now.toISOString()
|
|
11535
11538
|
};
|
|
11536
11539
|
}
|
|
11537
|
-
async function
|
|
11540
|
+
async function v_(e, t, n) {
|
|
11538
11541
|
if (n.length == 0) return;
|
|
11539
|
-
let i = await
|
|
11542
|
+
let i = await w_(e, `/me/drive/items/${encodeURIComponent(n)}`, {});
|
|
11540
11543
|
if (i.status == 400 || i.status == 404) throw new r(`OneDrive ${t} does not identify an item in this drive.`);
|
|
11541
|
-
|
|
11544
|
+
E_(i, `${t} validation`);
|
|
11542
11545
|
}
|
|
11543
|
-
function
|
|
11544
|
-
let t =
|
|
11546
|
+
function y_(e) {
|
|
11547
|
+
let t = j_(e);
|
|
11545
11548
|
if (typeof t?.deltaToken != "string" || t.deltaToken.length == 0 || typeof t.lastPolledAt != "string" || Number.isNaN(Date.parse(t.lastPolledAt))) throw new r("OneDrive checkpoint is invalid; recreate the Trigger.");
|
|
11546
11549
|
return {
|
|
11547
11550
|
deltaToken: t.deltaToken,
|
|
@@ -11549,28 +11552,28 @@ function v_(e) {
|
|
|
11549
11552
|
...typeof t.pageToken == "string" && t.pageToken.length > 0 ? { pageToken: t.pageToken } : {}
|
|
11550
11553
|
};
|
|
11551
11554
|
}
|
|
11552
|
-
async function
|
|
11555
|
+
async function b_(e, t, n) {
|
|
11553
11556
|
let r = /* @__PURE__ */ new Map(), i = t.pageToken ?? t.deltaToken;
|
|
11554
11557
|
for (let t = 0; t < 5; t += 1) {
|
|
11555
|
-
let t = await
|
|
11558
|
+
let t = await w_(e, "/me/drive/root/delta", {
|
|
11556
11559
|
$top: n,
|
|
11557
11560
|
token: i
|
|
11558
11561
|
});
|
|
11559
|
-
|
|
11560
|
-
let o =
|
|
11562
|
+
T_(t);
|
|
11563
|
+
let o = j_(t.data) ?? {};
|
|
11561
11564
|
for (let e of o.value ?? []) e.id != null && e.id.length > 0 && r.set(e.id, e);
|
|
11562
11565
|
if (o["@odata.deltaLink"]) return {
|
|
11563
11566
|
items: r,
|
|
11564
11567
|
next: {
|
|
11565
11568
|
checkpoint: {
|
|
11566
|
-
deltaToken:
|
|
11569
|
+
deltaToken: O_(o["@odata.deltaLink"]),
|
|
11567
11570
|
lastPolledAt: e.now.toISOString()
|
|
11568
11571
|
},
|
|
11569
11572
|
hasMore: !1
|
|
11570
11573
|
}
|
|
11571
11574
|
};
|
|
11572
11575
|
if (!o["@odata.nextLink"]) throw new a("OneDrive delta response has no continuation link.");
|
|
11573
|
-
i =
|
|
11576
|
+
i = O_(o["@odata.nextLink"]);
|
|
11574
11577
|
}
|
|
11575
11578
|
return {
|
|
11576
11579
|
items: r,
|
|
@@ -11584,17 +11587,17 @@ async function y_(e, t, n) {
|
|
|
11584
11587
|
}
|
|
11585
11588
|
};
|
|
11586
11589
|
}
|
|
11587
|
-
async function
|
|
11590
|
+
async function x_(e, t, n, r) {
|
|
11588
11591
|
if (t.root != null) return "structural";
|
|
11589
|
-
let i =
|
|
11592
|
+
let i = S_(t);
|
|
11590
11593
|
if (i == null) return "structural";
|
|
11591
|
-
let a = t.deleted == null ?
|
|
11592
|
-
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" : await
|
|
11594
|
+
let a = t.deleted == null ? A_(t.createdDateTime, new Date(r.lastPolledAt)) ? "created" : "updated" : "deleted";
|
|
11595
|
+
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" : await C_(e, t, a, i, r.deltaToken);
|
|
11593
11596
|
}
|
|
11594
|
-
function
|
|
11597
|
+
function S_(e) {
|
|
11595
11598
|
return e.file == null ? e.folder == null ? e.deleted == null ? null : "file" : "folder" : "file";
|
|
11596
11599
|
}
|
|
11597
|
-
async function
|
|
11600
|
+
async function C_(e, t, n, r, i) {
|
|
11598
11601
|
return {
|
|
11599
11602
|
dedupeKey: t.deleted == null ? `${e}:${t.eTag ?? t.lastModifiedDateTime}` : await fu(du([
|
|
11600
11603
|
"one-drive-deleted",
|
|
@@ -11617,7 +11620,7 @@ async function S_(e, t, n, r, i) {
|
|
|
11617
11620
|
}
|
|
11618
11621
|
};
|
|
11619
11622
|
}
|
|
11620
|
-
async function
|
|
11623
|
+
async function w_(e, t, n) {
|
|
11621
11624
|
try {
|
|
11622
11625
|
return await e.connector.execute({
|
|
11623
11626
|
endpoint: t,
|
|
@@ -11628,31 +11631,31 @@ async function C_(e, t, n) {
|
|
|
11628
11631
|
throw new a(`OneDrive proxy request to ${t} failed.`, { cause: e });
|
|
11629
11632
|
}
|
|
11630
11633
|
}
|
|
11631
|
-
function
|
|
11632
|
-
if (e.status == 410 &&
|
|
11634
|
+
function T_(e) {
|
|
11635
|
+
if (e.status == 410 && D_(e.data)) throw new r("OneDrive delta token expired; recreate the Trigger.");
|
|
11633
11636
|
if (e.status == 404) throw new r("OneDrive is not provisioned for this account.");
|
|
11634
11637
|
if (e.status == 400) throw new r("OneDrive rejected the delta token; recreate the Trigger.");
|
|
11635
|
-
|
|
11638
|
+
E_(e, "delta list");
|
|
11636
11639
|
}
|
|
11637
|
-
function
|
|
11640
|
+
function E_(e, t) {
|
|
11638
11641
|
if (!(e.status >= 200 && e.status < 300)) throw e.status == 401 || e.status == 403 ? new i(`OneDrive ${t} rejected the Connection.`) : new a(`OneDrive ${t} failed with status ${e.status}.`);
|
|
11639
11642
|
}
|
|
11640
|
-
function
|
|
11641
|
-
let t =
|
|
11643
|
+
function D_(e) {
|
|
11644
|
+
let t = j_(e)?.error;
|
|
11642
11645
|
for (; t != null;) {
|
|
11643
|
-
let e =
|
|
11646
|
+
let e = j_(t);
|
|
11644
11647
|
if (e == null) break;
|
|
11645
11648
|
if (e.code == "resyncChangesApplyDifferences" || e.code == "resyncChangesUploadDifferences") return !0;
|
|
11646
11649
|
t = e.innerError ?? e.innererror;
|
|
11647
11650
|
}
|
|
11648
11651
|
return !1;
|
|
11649
11652
|
}
|
|
11650
|
-
function
|
|
11651
|
-
let t =
|
|
11653
|
+
function O_(e) {
|
|
11654
|
+
let t = k_(e);
|
|
11652
11655
|
if (t == null) throw new a("OneDrive delta link has no token.");
|
|
11653
11656
|
return t;
|
|
11654
11657
|
}
|
|
11655
|
-
function
|
|
11658
|
+
function k_(e) {
|
|
11656
11659
|
let t = /[?&]token=([^&#]+)/.exec(e)?.[1] ?? /\(token='([^']+)'\)/.exec(e)?.[1];
|
|
11657
11660
|
if (t == null) return null;
|
|
11658
11661
|
try {
|
|
@@ -11661,17 +11664,17 @@ function O_(e) {
|
|
|
11661
11664
|
return t;
|
|
11662
11665
|
}
|
|
11663
11666
|
}
|
|
11664
|
-
function
|
|
11667
|
+
function A_(e, t) {
|
|
11665
11668
|
if (e == null || e.length == 0) return !1;
|
|
11666
11669
|
let n = new Date(e);
|
|
11667
11670
|
return !Number.isNaN(n.getTime()) && n >= t;
|
|
11668
11671
|
}
|
|
11669
|
-
function
|
|
11672
|
+
function j_(e) {
|
|
11670
11673
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
11671
11674
|
}
|
|
11672
11675
|
//#endregion
|
|
11673
11676
|
//#region src/trigger/providers/outlook/on-message-received.ts
|
|
11674
|
-
var
|
|
11677
|
+
var M_ = "inbox", N_ = 25, P_ = 100, F_ = "1970-01-01T00:00:00Z", I_ = "id,internetMessageId,conversationId,subject,bodyPreview,from,toRecipients,receivedDateTime,hasAttachments,isRead,isDraft,importance,categories,parentFolderId,webLink", L_ = {
|
|
11675
11678
|
buildOutputs: o,
|
|
11676
11679
|
snapshot: {
|
|
11677
11680
|
configInputs: [
|
|
@@ -11682,7 +11685,7 @@ var j_ = "inbox", M_ = 25, N_ = 100, P_ = "1970-01-01T00:00:00Z", F_ = "id,inter
|
|
|
11682
11685
|
type: "string"
|
|
11683
11686
|
},
|
|
11684
11687
|
nullable: !1,
|
|
11685
|
-
value:
|
|
11688
|
+
value: M_,
|
|
11686
11689
|
description: "A well-known mail folder name, folder ID, or an empty string for the whole mailbox."
|
|
11687
11690
|
},
|
|
11688
11691
|
{
|
|
@@ -11699,7 +11702,7 @@ var j_ = "inbox", M_ = 25, N_ = 100, P_ = "1970-01-01T00:00:00Z", F_ = "id,inter
|
|
|
11699
11702
|
type: "integer"
|
|
11700
11703
|
},
|
|
11701
11704
|
nullable: !1,
|
|
11702
|
-
value:
|
|
11705
|
+
value: N_
|
|
11703
11706
|
},
|
|
11704
11707
|
{
|
|
11705
11708
|
handle: "readStatus",
|
|
@@ -11797,37 +11800,37 @@ var j_ = "inbox", M_ = 25, N_ = 100, P_ = "1970-01-01T00:00:00Z", F_ = "id,inter
|
|
|
11797
11800
|
type: "poll"
|
|
11798
11801
|
},
|
|
11799
11802
|
async poll(e) {
|
|
11800
|
-
let t =
|
|
11803
|
+
let t = R_(e.config);
|
|
11801
11804
|
if (e.checkpoint === null) return {
|
|
11802
|
-
checkpoint: await
|
|
11805
|
+
checkpoint: await z_(e, t),
|
|
11803
11806
|
events: []
|
|
11804
11807
|
};
|
|
11805
|
-
let n =
|
|
11806
|
-
$filter:
|
|
11808
|
+
let n = B_(e.checkpoint), i = await G_(e, V_(t.folder), {
|
|
11809
|
+
$filter: H_(t, n.lastReceivedDateTime),
|
|
11807
11810
|
$orderby: "receivedDateTime asc",
|
|
11808
|
-
$select:
|
|
11811
|
+
$select: I_,
|
|
11809
11812
|
$top: t.maxMessagesPerPoll
|
|
11810
11813
|
});
|
|
11811
|
-
|
|
11812
|
-
let a =
|
|
11814
|
+
K_(i, "message list");
|
|
11815
|
+
let a = J_(i.data);
|
|
11813
11816
|
if (a.length == 0) return {
|
|
11814
11817
|
checkpoint: n,
|
|
11815
11818
|
events: []
|
|
11816
11819
|
};
|
|
11817
11820
|
let o = Date.parse(n.lastReceivedDateTime), s = o, c = n.lastReceivedDateTime;
|
|
11818
11821
|
for (let e of a) {
|
|
11819
|
-
let t =
|
|
11822
|
+
let t = X_(e.receivedDateTime);
|
|
11820
11823
|
e.receivedDateTime != null && t != null && t > s && (s = t, c = e.receivedDateTime);
|
|
11821
11824
|
}
|
|
11822
11825
|
let l = s > o, u = new Set(n.boundaryMessageIds), d = a.length >= t.maxMessagesPerPoll;
|
|
11823
11826
|
if (d && !l && a.every((e) => typeof e.id == "string" && u.has(e.id))) throw new r("Outlook cursor is stuck on a full timestamp boundary; increase maxMessagesPerPoll and resume the Trigger.");
|
|
11824
11827
|
let f = new Set(l ? [] : n.boundaryMessageIds), p = [], m = 0;
|
|
11825
|
-
for (let e of a) if (e.id != null && e.id.length != 0 && (
|
|
11826
|
-
if (!
|
|
11828
|
+
for (let e of a) if (e.id != null && e.id.length != 0 && (X_(e.receivedDateTime) == s && f.add(e.id), !u.has(e.id))) {
|
|
11829
|
+
if (!U_(e, t)) {
|
|
11827
11830
|
m += 1;
|
|
11828
11831
|
continue;
|
|
11829
11832
|
}
|
|
11830
|
-
p.push(
|
|
11833
|
+
p.push(W_(e, e.id));
|
|
11831
11834
|
}
|
|
11832
11835
|
let h = d && (l || p.length > 0);
|
|
11833
11836
|
return {
|
|
@@ -11841,7 +11844,7 @@ var j_ = "inbox", M_ = 25, N_ = 100, P_ = "1970-01-01T00:00:00Z", F_ = "id,inter
|
|
|
11841
11844
|
};
|
|
11842
11845
|
}
|
|
11843
11846
|
};
|
|
11844
|
-
function
|
|
11847
|
+
function R_(e) {
|
|
11845
11848
|
return {
|
|
11846
11849
|
folder: e.folder,
|
|
11847
11850
|
includeDrafts: e.includeDrafts,
|
|
@@ -11852,23 +11855,23 @@ function L_(e) {
|
|
|
11852
11855
|
withAttachmentsOnly: e.withAttachmentsOnly
|
|
11853
11856
|
};
|
|
11854
11857
|
}
|
|
11855
|
-
async function
|
|
11856
|
-
let n = await
|
|
11858
|
+
async function z_(e, t) {
|
|
11859
|
+
let n = await G_(e, V_(t.folder), {
|
|
11857
11860
|
$orderby: "receivedDateTime desc",
|
|
11858
11861
|
$select: "id,receivedDateTime",
|
|
11859
|
-
$top:
|
|
11862
|
+
$top: P_
|
|
11860
11863
|
});
|
|
11861
|
-
|
|
11862
|
-
$filter:
|
|
11864
|
+
K_(n, "seed marker fetch"), K_(await G_(e, V_(t.folder), {
|
|
11865
|
+
$filter: H_(t, F_),
|
|
11863
11866
|
$orderby: "receivedDateTime desc",
|
|
11864
11867
|
$top: 1
|
|
11865
11868
|
}), "seed filter shape check");
|
|
11866
|
-
let r = J_(
|
|
11869
|
+
let r = Y_(J_(n.data));
|
|
11867
11870
|
if (r == null) return {
|
|
11868
11871
|
boundaryMessageIds: [],
|
|
11869
11872
|
lastReceivedDateTime: e.now.toISOString()
|
|
11870
11873
|
};
|
|
11871
|
-
let i =
|
|
11874
|
+
let i = J_(n.data).filter((e) => X_(e.receivedDateTime) == r.ms);
|
|
11872
11875
|
return i.length >= t.maxMessagesPerPoll ? {
|
|
11873
11876
|
boundaryMessageIds: [],
|
|
11874
11877
|
lastReceivedDateTime: new Date(r.ms + 1e3).toISOString()
|
|
@@ -11877,26 +11880,26 @@ async function R_(e, t) {
|
|
|
11877
11880
|
lastReceivedDateTime: r.iso
|
|
11878
11881
|
};
|
|
11879
11882
|
}
|
|
11880
|
-
function
|
|
11881
|
-
let t =
|
|
11882
|
-
if (typeof n != "string" ||
|
|
11883
|
+
function B_(e) {
|
|
11884
|
+
let t = Z_(e), n = t?.lastReceivedDateTime;
|
|
11885
|
+
if (typeof n != "string" || X_(n) == null) throw new r("Outlook checkpoint is invalid; recreate the Trigger.");
|
|
11883
11886
|
let i = t?.boundaryMessageIds;
|
|
11884
11887
|
return {
|
|
11885
11888
|
boundaryMessageIds: Array.isArray(i) ? i.filter((e) => typeof e == "string" && e.length > 0) : [],
|
|
11886
11889
|
lastReceivedDateTime: n
|
|
11887
11890
|
};
|
|
11888
11891
|
}
|
|
11889
|
-
function
|
|
11892
|
+
function V_(e) {
|
|
11890
11893
|
return e.length == 0 ? "/me/messages" : `/me/mailFolders/${encodeURIComponent(e)}/messages`;
|
|
11891
11894
|
}
|
|
11892
|
-
function
|
|
11895
|
+
function H_(e, t) {
|
|
11893
11896
|
let n = [`receivedDateTime ge ${t}`];
|
|
11894
11897
|
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 ");
|
|
11895
11898
|
}
|
|
11896
|
-
function
|
|
11899
|
+
function U_(e, t) {
|
|
11897
11900
|
return e.isDraft === !0 && !t.includeDrafts ? !1 : t.subjectContains.length == 0 || (e.subject ?? "").toLowerCase().includes(t.subjectContains.toLowerCase());
|
|
11898
11901
|
}
|
|
11899
|
-
function
|
|
11902
|
+
function W_(e, t) {
|
|
11900
11903
|
return {
|
|
11901
11904
|
dedupeKey: t,
|
|
11902
11905
|
payload: {
|
|
@@ -11919,7 +11922,7 @@ function U_(e, t) {
|
|
|
11919
11922
|
}
|
|
11920
11923
|
};
|
|
11921
11924
|
}
|
|
11922
|
-
async function
|
|
11925
|
+
async function G_(e, t, n) {
|
|
11923
11926
|
try {
|
|
11924
11927
|
return await e.connector.execute({
|
|
11925
11928
|
endpoint: t,
|
|
@@ -11931,28 +11934,28 @@ async function W_(e, t, n) {
|
|
|
11931
11934
|
throw new a(`Outlook proxy request to ${t} failed.`, { cause: e });
|
|
11932
11935
|
}
|
|
11933
11936
|
}
|
|
11934
|
-
function
|
|
11937
|
+
function K_(e, t) {
|
|
11935
11938
|
if (e.status >= 200 && e.status < 300) return;
|
|
11936
|
-
let n =
|
|
11939
|
+
let n = q_(e.data);
|
|
11937
11940
|
throw e.status == 401 ? new i(`Outlook ${t} rejected the Connection.`) : e.status == 403 && n.has("mailboxnotenabledforrestapi") ? new r("The Outlook mailbox is not reachable through the Graph mail APIs.") : e.status == 403 && (n.has("accessdenied") || n.has("erroraccessdenied")) ? new i(`Outlook ${t} rejected the Connection.`) : e.status == 404 && (n.has("erroritemnotfound") || n.has("itemnotfound")) ? new r("The configured Outlook folder does not exist.") : e.status == 400 && (n.has("errorinvalididmalformed") || n.has("inefficientfilter")) ? new r("Outlook rejected the configured folder or filters.") : new a(`Outlook ${t} failed with status ${e.status}.`);
|
|
11938
11941
|
}
|
|
11939
|
-
function
|
|
11940
|
-
let t = /* @__PURE__ */ new Set(), n =
|
|
11942
|
+
function q_(e) {
|
|
11943
|
+
let t = /* @__PURE__ */ new Set(), n = Z_(e)?.error;
|
|
11941
11944
|
for (let e = 0; e < 4; e += 1) {
|
|
11942
|
-
let e =
|
|
11945
|
+
let e = Z_(n);
|
|
11943
11946
|
if (e == null) break;
|
|
11944
11947
|
typeof e.code == "string" && e.code.length > 0 && t.add(e.code.toLowerCase()), n = e.innerError ?? e.innererror;
|
|
11945
11948
|
}
|
|
11946
11949
|
return t;
|
|
11947
11950
|
}
|
|
11948
|
-
function
|
|
11949
|
-
let t =
|
|
11951
|
+
function J_(e) {
|
|
11952
|
+
let t = Z_(e)?.value;
|
|
11950
11953
|
return Array.isArray(t) ? t : [];
|
|
11951
11954
|
}
|
|
11952
|
-
function
|
|
11955
|
+
function Y_(e) {
|
|
11953
11956
|
let t = null;
|
|
11954
11957
|
for (let n of e) {
|
|
11955
|
-
let e =
|
|
11958
|
+
let e = X_(n.receivedDateTime);
|
|
11956
11959
|
n.receivedDateTime != null && e != null && (t == null || e > t.ms) && (t = {
|
|
11957
11960
|
iso: n.receivedDateTime,
|
|
11958
11961
|
ms: e
|
|
@@ -11960,15 +11963,15 @@ function J_(e) {
|
|
|
11960
11963
|
}
|
|
11961
11964
|
return t;
|
|
11962
11965
|
}
|
|
11963
|
-
function
|
|
11966
|
+
function X_(e) {
|
|
11964
11967
|
if (e == null || e.length == 0) return null;
|
|
11965
11968
|
let t = Date.parse(e);
|
|
11966
11969
|
return Number.isNaN(t) ? null : t;
|
|
11967
11970
|
}
|
|
11968
|
-
function
|
|
11971
|
+
function Z_(e) {
|
|
11969
11972
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
11970
11973
|
}
|
|
11971
|
-
var
|
|
11974
|
+
var Q_ = {
|
|
11972
11975
|
initialState: {
|
|
11973
11976
|
checkpoint: null,
|
|
11974
11977
|
subscription: {}
|
|
@@ -12054,7 +12057,7 @@ var Z_ = {
|
|
|
12054
12057
|
outcome: "ignored",
|
|
12055
12058
|
reason: "Shopify topic header is missing."
|
|
12056
12059
|
};
|
|
12057
|
-
if (
|
|
12060
|
+
if (!$_(e.config).includes(t)) return {
|
|
12058
12061
|
outcome: "ignored",
|
|
12059
12062
|
reason: "Shopify topic is not subscribed."
|
|
12060
12063
|
};
|
|
@@ -12074,39 +12077,39 @@ var Z_ = {
|
|
|
12074
12077
|
};
|
|
12075
12078
|
},
|
|
12076
12079
|
async reconcile(e) {
|
|
12077
|
-
let n =
|
|
12080
|
+
let n = sv(e.state), r = await tv(e);
|
|
12078
12081
|
if (r == null) {
|
|
12079
12082
|
if (!e.active) return { outcome: "ready" };
|
|
12080
12083
|
throw new t("The Shopify store or webhook resource is unavailable.");
|
|
12081
12084
|
}
|
|
12082
12085
|
if (!e.active) {
|
|
12083
|
-
for (let t of r.values()) await
|
|
12084
|
-
return await n.saveSubscription({},
|
|
12086
|
+
for (let t of r.values()) await rv(e, t);
|
|
12087
|
+
return await n.saveSubscription({}, cv(e.now)), { outcome: "ready" };
|
|
12085
12088
|
}
|
|
12086
|
-
let i =
|
|
12089
|
+
let i = $_(e.config), a = [], o = [];
|
|
12087
12090
|
try {
|
|
12088
12091
|
for (let t of i) {
|
|
12089
12092
|
let n = r.get(t);
|
|
12090
12093
|
if (n != null) a.push(n);
|
|
12091
12094
|
else {
|
|
12092
|
-
let n = await
|
|
12095
|
+
let n = await ev(e, t);
|
|
12093
12096
|
a.push(n.id), n.created && o.push(n.id);
|
|
12094
12097
|
}
|
|
12095
12098
|
}
|
|
12096
12099
|
} catch (t) {
|
|
12097
|
-
throw await Promise.allSettled(o.map((t) =>
|
|
12100
|
+
throw await Promise.allSettled(o.map((t) => rv(e, t))), t;
|
|
12098
12101
|
}
|
|
12099
|
-
for (let [t, n] of r) i.includes(t) || await
|
|
12100
|
-
return await n.saveSubscription({ webhookIds: a },
|
|
12102
|
+
for (let [t, n] of r) i.includes(t) || await rv(e, n);
|
|
12103
|
+
return await n.saveSubscription({ webhookIds: a }, cv(e.now)), { outcome: "ready" };
|
|
12101
12104
|
}
|
|
12102
12105
|
};
|
|
12103
|
-
function
|
|
12106
|
+
function $_(e) {
|
|
12104
12107
|
return [...new Set(e.topics)];
|
|
12105
12108
|
}
|
|
12106
|
-
async function
|
|
12107
|
-
let r = await
|
|
12109
|
+
async function ev(e, t) {
|
|
12110
|
+
let r = await iv(e, "subscription create", {
|
|
12108
12111
|
body: { webhook: {
|
|
12109
|
-
address:
|
|
12112
|
+
address: nv(e),
|
|
12110
12113
|
format: "json",
|
|
12111
12114
|
topic: t
|
|
12112
12115
|
} },
|
|
@@ -12114,22 +12117,22 @@ async function $_(e, t) {
|
|
|
12114
12117
|
method: "POST"
|
|
12115
12118
|
});
|
|
12116
12119
|
if (r.status == 422) {
|
|
12117
|
-
let n = (await
|
|
12120
|
+
let n = (await tv(e))?.get(t);
|
|
12118
12121
|
if (n != null) return {
|
|
12119
12122
|
created: !1,
|
|
12120
12123
|
id: n
|
|
12121
12124
|
};
|
|
12122
12125
|
}
|
|
12123
|
-
|
|
12124
|
-
let i =
|
|
12126
|
+
av(r, "subscription create");
|
|
12127
|
+
let i = ov(lv(lv(r.data)?.webhook)?.id);
|
|
12125
12128
|
if (i == null) throw new n("Shopify subscription response is missing its ID.");
|
|
12126
12129
|
return {
|
|
12127
12130
|
created: !0,
|
|
12128
12131
|
id: i
|
|
12129
12132
|
};
|
|
12130
12133
|
}
|
|
12131
|
-
async function
|
|
12132
|
-
let t =
|
|
12134
|
+
async function tv(e) {
|
|
12135
|
+
let t = nv(e), n = await iv(e, "subscription list", {
|
|
12133
12136
|
endpoint: "/webhooks.json",
|
|
12134
12137
|
method: "GET",
|
|
12135
12138
|
query: {
|
|
@@ -12138,34 +12141,34 @@ async function ev(e) {
|
|
|
12138
12141
|
}
|
|
12139
12142
|
});
|
|
12140
12143
|
if (n.status == 404) return null;
|
|
12141
|
-
|
|
12142
|
-
let r =
|
|
12144
|
+
av(n, "subscription list");
|
|
12145
|
+
let r = lv(n.data)?.webhooks, i = /* @__PURE__ */ new Map();
|
|
12143
12146
|
if (!Array.isArray(r)) return i;
|
|
12144
12147
|
for (let e of r) {
|
|
12145
|
-
let n =
|
|
12148
|
+
let n = lv(e), r = ov(n?.id);
|
|
12146
12149
|
n?.address === t && typeof n.topic == "string" && r != null && i.set(n.topic, r);
|
|
12147
12150
|
}
|
|
12148
12151
|
return i;
|
|
12149
12152
|
}
|
|
12150
|
-
function
|
|
12153
|
+
function nv(e) {
|
|
12151
12154
|
let t = new URL(e.endpointUrl);
|
|
12152
12155
|
return t.searchParams.set("open_flow_callback", e.callbackSecret), t.href;
|
|
12153
12156
|
}
|
|
12154
|
-
async function
|
|
12155
|
-
let n = await
|
|
12157
|
+
async function rv(e, t) {
|
|
12158
|
+
let n = await iv(e, "subscription delete", {
|
|
12156
12159
|
endpoint: `/webhooks/${encodeURIComponent(t)}.json`,
|
|
12157
12160
|
method: "DELETE"
|
|
12158
12161
|
});
|
|
12159
|
-
n.status != 404 &&
|
|
12162
|
+
n.status != 404 && av(n, "subscription delete");
|
|
12160
12163
|
}
|
|
12161
|
-
async function
|
|
12164
|
+
async function iv(t, r, i) {
|
|
12162
12165
|
try {
|
|
12163
12166
|
return await t.connector.execute(i, t.signal);
|
|
12164
12167
|
} catch (t) {
|
|
12165
12168
|
throw t instanceof e ? t : new n(`Shopify ${r} request failed.`, { cause: t });
|
|
12166
12169
|
}
|
|
12167
12170
|
}
|
|
12168
|
-
function
|
|
12171
|
+
function av(r, i) {
|
|
12169
12172
|
if (!(r.status >= 200 && r.status < 300)) throw r.status == 401 || r.status == 403 ? new e(`Shopify ${i} rejected the Connection.`) : [
|
|
12170
12173
|
402,
|
|
12171
12174
|
404,
|
|
@@ -12174,34 +12177,34 @@ function iv(r, i) {
|
|
|
12174
12177
|
501
|
|
12175
12178
|
].includes(r.status) ? new t(`Shopify ${i} rejected the subscription.`) : new n(`Shopify ${i} failed with status ${r.status}.`);
|
|
12176
12179
|
}
|
|
12177
|
-
function
|
|
12180
|
+
function ov(e) {
|
|
12178
12181
|
return typeof e == "string" ? e.trim().length == 0 ? null : e : typeof e == "number" && Number.isFinite(e) ? String(e) : null;
|
|
12179
12182
|
}
|
|
12180
|
-
function
|
|
12183
|
+
function sv(e) {
|
|
12181
12184
|
if (e == null) throw new t("Shopify Integration state is missing.");
|
|
12182
12185
|
return e;
|
|
12183
12186
|
}
|
|
12184
|
-
function
|
|
12187
|
+
function cv(e) {
|
|
12185
12188
|
return new Date(e.getTime() + 2592e6);
|
|
12186
12189
|
}
|
|
12187
|
-
function
|
|
12190
|
+
function lv(e) {
|
|
12188
12191
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
12189
12192
|
}
|
|
12190
12193
|
//#endregion
|
|
12191
12194
|
//#region src/trigger/providers/slack/on-message-posted.ts
|
|
12192
|
-
var
|
|
12195
|
+
var uv = 15, dv = 6e4, fv = /* @__PURE__ */ new Set([
|
|
12193
12196
|
"file_share",
|
|
12194
12197
|
"thread_broadcast",
|
|
12195
12198
|
"me_message",
|
|
12196
12199
|
"bot_message"
|
|
12197
|
-
]),
|
|
12200
|
+
]), pv = /* @__PURE__ */ new Set([
|
|
12198
12201
|
"invalid_auth",
|
|
12199
12202
|
"not_authed",
|
|
12200
12203
|
"token_revoked",
|
|
12201
12204
|
"token_expired",
|
|
12202
12205
|
"account_inactive",
|
|
12203
12206
|
"two_factor_setup_required"
|
|
12204
|
-
]),
|
|
12207
|
+
]), mv = /* @__PURE__ */ new Set([
|
|
12205
12208
|
"channel_not_found",
|
|
12206
12209
|
"not_in_channel",
|
|
12207
12210
|
"missing_scope",
|
|
@@ -12217,7 +12220,7 @@ var lv = 15, uv = 6e4, dv = /* @__PURE__ */ new Set([
|
|
|
12217
12220
|
"method_deprecated",
|
|
12218
12221
|
"deprecated_endpoint",
|
|
12219
12222
|
"accesslimited"
|
|
12220
|
-
]),
|
|
12223
|
+
]), hv = {
|
|
12221
12224
|
buildOutputs: o,
|
|
12222
12225
|
snapshot: {
|
|
12223
12226
|
configInputs: [
|
|
@@ -12278,7 +12281,7 @@ var lv = 15, uv = 6e4, dv = /* @__PURE__ */ new Set([
|
|
|
12278
12281
|
type: "integer"
|
|
12279
12282
|
},
|
|
12280
12283
|
nullable: !1,
|
|
12281
|
-
value:
|
|
12284
|
+
value: uv,
|
|
12282
12285
|
description: "Maximum number of messages processed per poll."
|
|
12283
12286
|
},
|
|
12284
12287
|
{
|
|
@@ -12345,27 +12348,27 @@ var lv = 15, uv = 6e4, dv = /* @__PURE__ */ new Set([
|
|
|
12345
12348
|
type: "poll"
|
|
12346
12349
|
},
|
|
12347
12350
|
async poll(e) {
|
|
12348
|
-
let t =
|
|
12351
|
+
let t = gv(e.config);
|
|
12349
12352
|
if (e.checkpoint === null) return {
|
|
12350
|
-
checkpoint: { lastTs: await
|
|
12353
|
+
checkpoint: { lastTs: await _v(e, t.channelId) },
|
|
12351
12354
|
events: []
|
|
12352
12355
|
};
|
|
12353
|
-
let n =
|
|
12356
|
+
let n = vv(e.checkpoint), r = await yv(e, t, n), i = Sv(r), a = [], o = 0;
|
|
12354
12357
|
for (let e of i.toReversed()) {
|
|
12355
|
-
if (!
|
|
12358
|
+
if (!wv(e.message, t)) {
|
|
12356
12359
|
o += 1;
|
|
12357
12360
|
continue;
|
|
12358
12361
|
}
|
|
12359
|
-
a.push(
|
|
12362
|
+
a.push(Tv(e, t.channelId));
|
|
12360
12363
|
}
|
|
12361
12364
|
return {
|
|
12362
|
-
checkpoint:
|
|
12365
|
+
checkpoint: Cv(n, r, i),
|
|
12363
12366
|
events: a,
|
|
12364
12367
|
filtered: o
|
|
12365
12368
|
};
|
|
12366
12369
|
}
|
|
12367
12370
|
};
|
|
12368
|
-
function
|
|
12371
|
+
function gv(e) {
|
|
12369
12372
|
return {
|
|
12370
12373
|
channelId: e.channelId,
|
|
12371
12374
|
fromUserIds: e.fromUserIds,
|
|
@@ -12376,16 +12379,16 @@ function hv(e) {
|
|
|
12376
12379
|
textContains: e.textContains
|
|
12377
12380
|
};
|
|
12378
12381
|
}
|
|
12379
|
-
async function
|
|
12380
|
-
let n = await
|
|
12382
|
+
async function _v(e, t) {
|
|
12383
|
+
let n = await bv(e, {
|
|
12381
12384
|
channel: t,
|
|
12382
12385
|
limit: 1
|
|
12383
12386
|
});
|
|
12384
|
-
|
|
12387
|
+
xv(n, "baseline history fetch");
|
|
12385
12388
|
let r = n.data.messages?.[0]?.ts;
|
|
12386
|
-
return r != null &&
|
|
12389
|
+
return r != null && Ev(r) ? r : `${Math.floor((e.now.getTime() - dv) / 1e3)}.000000`;
|
|
12387
12390
|
}
|
|
12388
|
-
function
|
|
12391
|
+
function vv(e) {
|
|
12389
12392
|
let t = e;
|
|
12390
12393
|
if (typeof t.lastTs != "string" || t.lastTs.length == 0) throw new r("Slack checkpoint lastTs is missing.");
|
|
12391
12394
|
let n = t.drainLatest, i = t.pendingHighTs;
|
|
@@ -12397,17 +12400,17 @@ function _v(e) {
|
|
|
12397
12400
|
pendingHighTs: i
|
|
12398
12401
|
};
|
|
12399
12402
|
}
|
|
12400
|
-
async function
|
|
12401
|
-
let r = await
|
|
12403
|
+
async function yv(e, t, n) {
|
|
12404
|
+
let r = await bv(e, {
|
|
12402
12405
|
channel: t.channelId,
|
|
12403
12406
|
inclusive: "false",
|
|
12404
12407
|
latest: n.drainLatest,
|
|
12405
12408
|
limit: t.maxMessagesPerPoll,
|
|
12406
12409
|
oldest: n.lastTs
|
|
12407
12410
|
});
|
|
12408
|
-
return
|
|
12411
|
+
return xv(r, "history list"), r.data;
|
|
12409
12412
|
}
|
|
12410
|
-
async function
|
|
12413
|
+
async function bv(e, t) {
|
|
12411
12414
|
try {
|
|
12412
12415
|
return await e.connector.execute({
|
|
12413
12416
|
endpoint: "/conversations.history",
|
|
@@ -12418,19 +12421,19 @@ async function yv(e, t) {
|
|
|
12418
12421
|
throw new a("Slack proxy request failed.", { cause: e });
|
|
12419
12422
|
}
|
|
12420
12423
|
}
|
|
12421
|
-
function
|
|
12424
|
+
function xv(e, t) {
|
|
12422
12425
|
let n = e.data;
|
|
12423
12426
|
if (e.status >= 200 && e.status < 300 && n.ok === !0) return;
|
|
12424
12427
|
let o = typeof n.error == "string" ? n.error : "";
|
|
12425
|
-
throw
|
|
12428
|
+
throw pv.has(o) ? new i(`Slack ${t} rejected with ${o}.`) : mv.has(o) ? new r(`Slack ${t} rejected with ${o}.`) : new a(`Slack ${t} failed with ${o || `status ${e.status}`}.`);
|
|
12426
12429
|
}
|
|
12427
|
-
function
|
|
12428
|
-
return (e.messages ?? []).flatMap((e) => e.ts != null &&
|
|
12430
|
+
function Sv(e) {
|
|
12431
|
+
return (e.messages ?? []).flatMap((e) => e.ts != null && Ev(e.ts) ? [{
|
|
12429
12432
|
message: e,
|
|
12430
12433
|
ts: e.ts
|
|
12431
12434
|
}] : []);
|
|
12432
12435
|
}
|
|
12433
|
-
function
|
|
12436
|
+
function Cv(e, t, n) {
|
|
12434
12437
|
let r = n[0]?.ts, i = n.at(-1)?.ts;
|
|
12435
12438
|
if (t.has_more === !0) {
|
|
12436
12439
|
if (r == null || i == null) throw new a("Slack history reports has_more without a usable timestamp.");
|
|
@@ -12442,10 +12445,10 @@ function Sv(e, t, n) {
|
|
|
12442
12445
|
}
|
|
12443
12446
|
return e.pendingHighTs == null ? { lastTs: r ?? e.lastTs } : { lastTs: e.pendingHighTs };
|
|
12444
12447
|
}
|
|
12445
|
-
function Cv(e, t) {
|
|
12446
|
-
return !t.includeBotMessages && (e.bot_id != null || e.subtype == "bot_message") || !t.includeSystemMessages && e.subtype != null && !dv.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());
|
|
12447
|
-
}
|
|
12448
12448
|
function wv(e, t) {
|
|
12449
|
+
return !t.includeBotMessages && (e.bot_id != null || e.subtype == "bot_message") || !t.includeSystemMessages && e.subtype != null && !fv.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());
|
|
12450
|
+
}
|
|
12451
|
+
function Tv(e, t) {
|
|
12449
12452
|
return {
|
|
12450
12453
|
dedupeKey: `${t}:${e.ts}`,
|
|
12451
12454
|
payload: {
|
|
@@ -12464,12 +12467,12 @@ function wv(e, t) {
|
|
|
12464
12467
|
}
|
|
12465
12468
|
};
|
|
12466
12469
|
}
|
|
12467
|
-
function
|
|
12470
|
+
function Ev(e) {
|
|
12468
12471
|
return /^\d+(?:\.\d+)?$/.test(e) && !Number.isNaN(new Date(Math.round(Number(e) * 1e3)).getTime());
|
|
12469
12472
|
}
|
|
12470
12473
|
//#endregion
|
|
12471
12474
|
//#region src/trigger/providers/stripe/on-event.ts
|
|
12472
|
-
var
|
|
12475
|
+
var Dv = 300, Ov = "/v1/webhook_endpoints", kv = { "Content-Type": "application/x-www-form-urlencoded" }, Av = {
|
|
12473
12476
|
initialState: {
|
|
12474
12477
|
checkpoint: null,
|
|
12475
12478
|
subscription: {}
|
|
@@ -12546,8 +12549,8 @@ var Ev = 300, Dv = "/v1/webhook_endpoints", Ov = { "Content-Type": "application/
|
|
|
12546
12549
|
type: "integration"
|
|
12547
12550
|
},
|
|
12548
12551
|
async receive(e) {
|
|
12549
|
-
let t =
|
|
12550
|
-
if (t == null || !await
|
|
12552
|
+
let t = Bv(e.state);
|
|
12553
|
+
if (t == null || !await Vv(e.header("stripe-signature"), t, e.rawBody, e.now)) return {
|
|
12551
12554
|
body: "",
|
|
12552
12555
|
contentType: "text/plain",
|
|
12553
12556
|
outcome: "respond",
|
|
@@ -12562,7 +12565,7 @@ var Ev = 300, Dv = "/v1/webhook_endpoints", Ov = { "Content-Type": "application/
|
|
|
12562
12565
|
outcome: "ignored",
|
|
12563
12566
|
reason: "Stripe event identity is missing."
|
|
12564
12567
|
};
|
|
12565
|
-
let a =
|
|
12568
|
+
let a = jv(e.config);
|
|
12566
12569
|
return !a.events.includes("*") && !a.events.includes(r) ? {
|
|
12567
12570
|
outcome: "ignored",
|
|
12568
12571
|
reason: "Stripe event is not subscribed."
|
|
@@ -12578,156 +12581,156 @@ var Ev = 300, Dv = "/v1/webhook_endpoints", Ov = { "Content-Type": "application/
|
|
|
12578
12581
|
};
|
|
12579
12582
|
},
|
|
12580
12583
|
async reconcile(e) {
|
|
12581
|
-
let t =
|
|
12584
|
+
let t = Rv(e.state), n = jv(e.config), r = zv(t), i = Bv(t);
|
|
12582
12585
|
if (!e.active) {
|
|
12583
|
-
if (r ??= await
|
|
12584
|
-
let t = await
|
|
12585
|
-
endpoint: `${
|
|
12586
|
+
if (r ??= await Pv(e), r != null) {
|
|
12587
|
+
let t = await Fv(e, "endpoint delete", {
|
|
12588
|
+
endpoint: `${Ov}/${r}`,
|
|
12586
12589
|
method: "DELETE"
|
|
12587
12590
|
});
|
|
12588
|
-
t.status != 404 &&
|
|
12591
|
+
t.status != 404 && Iv(t, "endpoint delete");
|
|
12589
12592
|
}
|
|
12590
|
-
return await t.saveSubscription({},
|
|
12593
|
+
return await t.saveSubscription({}, Hv(e.now)), { outcome: "ready" };
|
|
12591
12594
|
}
|
|
12592
|
-
if (r ??= await
|
|
12593
|
-
let t = await
|
|
12594
|
-
endpoint: `${
|
|
12595
|
+
if (r ??= await Pv(e), r != null && i == null) {
|
|
12596
|
+
let t = await Fv(e, "endpoint delete", {
|
|
12597
|
+
endpoint: `${Ov}/${r}`,
|
|
12595
12598
|
method: "DELETE"
|
|
12596
12599
|
});
|
|
12597
|
-
t.status != 404 &&
|
|
12600
|
+
t.status != 404 && Iv(t, "endpoint delete"), r = null;
|
|
12598
12601
|
}
|
|
12599
12602
|
if (r == null) {
|
|
12600
|
-
let t = await
|
|
12601
|
-
body:
|
|
12602
|
-
endpoint:
|
|
12603
|
+
let t = await Fv(e, "endpoint create", {
|
|
12604
|
+
body: Mv(e.endpointUrl, n),
|
|
12605
|
+
endpoint: Ov,
|
|
12603
12606
|
headers: {
|
|
12604
|
-
...
|
|
12607
|
+
...kv,
|
|
12605
12608
|
"Idempotency-Key": e.idempotencyKey
|
|
12606
12609
|
},
|
|
12607
12610
|
method: "POST"
|
|
12608
12611
|
});
|
|
12609
|
-
|
|
12610
|
-
let a =
|
|
12612
|
+
Iv(t, "endpoint create");
|
|
12613
|
+
let a = Lv(t.data);
|
|
12611
12614
|
r = a.id, i = a.secret;
|
|
12612
12615
|
}
|
|
12613
|
-
let a = await
|
|
12614
|
-
body:
|
|
12616
|
+
let a = await Fv(e, "endpoint update", {
|
|
12617
|
+
body: Nv([
|
|
12615
12618
|
...n.events.map((e, t) => [`enabled_events[${t}]`, e]),
|
|
12616
12619
|
["disabled", "false"],
|
|
12617
12620
|
["description", "Managed by Open Flow."]
|
|
12618
12621
|
]),
|
|
12619
|
-
endpoint: `${
|
|
12620
|
-
headers:
|
|
12622
|
+
endpoint: `${Ov}/${r}`,
|
|
12623
|
+
headers: kv,
|
|
12621
12624
|
method: "POST"
|
|
12622
12625
|
});
|
|
12623
|
-
return a.status == 404 ? (await t.saveSubscription({}, e.now), { outcome: "pending" }) : (
|
|
12626
|
+
return a.status == 404 ? (await t.saveSubscription({}, e.now), { outcome: "pending" }) : (Iv(a, "endpoint update"), await t.saveSubscription({
|
|
12624
12627
|
endpointId: r,
|
|
12625
12628
|
signingSecret: i
|
|
12626
|
-
},
|
|
12629
|
+
}, Hv(e.now)), { outcome: "ready" });
|
|
12627
12630
|
}
|
|
12628
12631
|
};
|
|
12629
|
-
function
|
|
12632
|
+
function jv(e) {
|
|
12630
12633
|
return {
|
|
12631
12634
|
apiVersion: e.apiVersion,
|
|
12632
12635
|
events: [...new Set(e.events)],
|
|
12633
12636
|
includeConnectedAccounts: e.includeConnectedAccounts
|
|
12634
12637
|
};
|
|
12635
12638
|
}
|
|
12636
|
-
function
|
|
12639
|
+
function Mv(e, t) {
|
|
12637
12640
|
let n = [
|
|
12638
12641
|
["url", e],
|
|
12639
12642
|
...t.events.map((e, t) => [`enabled_events[${t}]`, e]),
|
|
12640
12643
|
["description", "Managed by Open Flow."]
|
|
12641
12644
|
];
|
|
12642
|
-
return t.includeConnectedAccounts && n.push(["connect", "true"]), t.apiVersion.length > 0 && n.push(["api_version", t.apiVersion]),
|
|
12645
|
+
return t.includeConnectedAccounts && n.push(["connect", "true"]), t.apiVersion.length > 0 && n.push(["api_version", t.apiVersion]), Nv(n);
|
|
12643
12646
|
}
|
|
12644
|
-
function
|
|
12647
|
+
function Nv(e) {
|
|
12645
12648
|
let t = new URLSearchParams();
|
|
12646
12649
|
for (let [n, r] of e) t.append(n, r);
|
|
12647
12650
|
return t.toString();
|
|
12648
12651
|
}
|
|
12649
|
-
async function
|
|
12652
|
+
async function Pv(e) {
|
|
12650
12653
|
let t;
|
|
12651
12654
|
for (let n = 0; n < 10; n += 1) {
|
|
12652
|
-
let n = await
|
|
12653
|
-
endpoint:
|
|
12655
|
+
let n = await Fv(e, "endpoint list", {
|
|
12656
|
+
endpoint: Ov,
|
|
12654
12657
|
method: "GET",
|
|
12655
12658
|
query: {
|
|
12656
12659
|
limit: 100,
|
|
12657
12660
|
...t == null ? {} : { starting_after: t }
|
|
12658
12661
|
}
|
|
12659
12662
|
});
|
|
12660
|
-
|
|
12661
|
-
let r =
|
|
12663
|
+
Iv(n, "endpoint list");
|
|
12664
|
+
let r = Uv(n.data), i = Array.isArray(r?.data) ? r.data : [];
|
|
12662
12665
|
for (let t of i) {
|
|
12663
|
-
let n =
|
|
12666
|
+
let n = Uv(t);
|
|
12664
12667
|
if (n?.url === e.endpointUrl && typeof n.id == "string") return n.id;
|
|
12665
12668
|
}
|
|
12666
|
-
let a =
|
|
12669
|
+
let a = Uv(i.at(-1))?.id;
|
|
12667
12670
|
if (r?.has_more !== !0 || typeof a != "string") return null;
|
|
12668
12671
|
t = a;
|
|
12669
12672
|
}
|
|
12670
12673
|
return null;
|
|
12671
12674
|
}
|
|
12672
|
-
async function
|
|
12675
|
+
async function Fv(t, r, i) {
|
|
12673
12676
|
try {
|
|
12674
12677
|
return await t.connector.execute(i, t.signal);
|
|
12675
12678
|
} catch (t) {
|
|
12676
12679
|
throw t instanceof e ? t : new n(`Stripe ${r} request failed.`, { cause: t });
|
|
12677
12680
|
}
|
|
12678
12681
|
}
|
|
12679
|
-
function
|
|
12682
|
+
function Iv(r, i) {
|
|
12680
12683
|
if (!(r.status >= 200 && r.status < 300)) {
|
|
12681
12684
|
if (r.status == 401 || r.status == 403) throw new e(`Stripe ${i} rejected the Connection.`);
|
|
12682
12685
|
if (r.status == 400 || r.status == 404) {
|
|
12683
|
-
let e =
|
|
12686
|
+
let e = Uv(Uv(r.data)?.error)?.message;
|
|
12684
12687
|
throw new t(`Stripe ${i} rejected the subscription${typeof e == "string" ? `: ${e}` : "."}`);
|
|
12685
12688
|
}
|
|
12686
12689
|
throw new n(`Stripe ${i} failed with status ${r.status}.`);
|
|
12687
12690
|
}
|
|
12688
12691
|
}
|
|
12689
|
-
function
|
|
12690
|
-
let t =
|
|
12692
|
+
function Lv(e) {
|
|
12693
|
+
let t = Uv(e);
|
|
12691
12694
|
if (typeof t?.id != "string" || typeof t.secret != "string" || t.secret.length == 0) throw new n("Stripe endpoint response is missing its ID or signing secret.");
|
|
12692
12695
|
return {
|
|
12693
12696
|
id: t.id,
|
|
12694
12697
|
secret: t.secret
|
|
12695
12698
|
};
|
|
12696
12699
|
}
|
|
12697
|
-
function
|
|
12700
|
+
function Rv(e) {
|
|
12698
12701
|
if (e == null) throw new t("Stripe Integration state is missing.");
|
|
12699
12702
|
return e;
|
|
12700
12703
|
}
|
|
12701
|
-
function
|
|
12704
|
+
function zv(e) {
|
|
12702
12705
|
let t = e.subscription.endpointId;
|
|
12703
12706
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
12704
12707
|
}
|
|
12705
|
-
function
|
|
12708
|
+
function Bv(e) {
|
|
12706
12709
|
let t = e?.subscription.signingSecret;
|
|
12707
12710
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
12708
12711
|
}
|
|
12709
|
-
async function
|
|
12712
|
+
async function Vv(e, t, n, r) {
|
|
12710
12713
|
if (e == null) return !1;
|
|
12711
12714
|
let i = e.split(",").map((e) => e.trim().split("=", 2)), a = i.find(([e]) => e == "t")?.[1];
|
|
12712
12715
|
if (a == null || !/^\d+$/.test(a)) return !1;
|
|
12713
12716
|
let o = Number(a);
|
|
12714
|
-
if (!Number.isSafeInteger(o) || Math.abs(Math.floor(r.getTime() / 1e3) - o) >
|
|
12717
|
+
if (!Number.isSafeInteger(o) || Math.abs(Math.floor(r.getTime() / 1e3) - o) > Dv) return !1;
|
|
12715
12718
|
let s = i.filter(([e, t]) => e == "v1" && t != null).map(([, e]) => e), c = [Te(`${a}.`), n];
|
|
12716
12719
|
return (await Promise.all(s.map((e) => Oe(t, c, e)))).some(Boolean);
|
|
12717
12720
|
}
|
|
12718
|
-
function
|
|
12721
|
+
function Hv(e) {
|
|
12719
12722
|
return new Date(e.getTime() + 2592e6);
|
|
12720
12723
|
}
|
|
12721
|
-
function
|
|
12724
|
+
function Uv(e) {
|
|
12722
12725
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
12723
12726
|
}
|
|
12724
12727
|
//#endregion
|
|
12725
12728
|
//#region src/trigger/providers/telegram/on-update.ts
|
|
12726
|
-
var
|
|
12729
|
+
var Wv = /* @__PURE__ */ new Set([
|
|
12727
12730
|
"chat_member",
|
|
12728
12731
|
"message_reaction",
|
|
12729
12732
|
"message_reaction_count"
|
|
12730
|
-
]),
|
|
12733
|
+
]), Gv = /* @__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("."), Kv = Gv.filter((e) => e != "*" && !Wv.has(e)), qv = {
|
|
12731
12734
|
snapshot: {
|
|
12732
12735
|
configInputs: [
|
|
12733
12736
|
{
|
|
@@ -12755,7 +12758,7 @@ var Uv = /* @__PURE__ */ new Set([
|
|
|
12755
12758
|
{
|
|
12756
12759
|
handle: "updates",
|
|
12757
12760
|
jsonSchema: {
|
|
12758
|
-
items: { enum:
|
|
12761
|
+
items: { enum: Gv },
|
|
12759
12762
|
minItems: 1,
|
|
12760
12763
|
type: "array",
|
|
12761
12764
|
uniqueItems: !0
|
|
@@ -12814,13 +12817,13 @@ var Uv = /* @__PURE__ */ new Set([
|
|
|
12814
12817
|
type: "integration"
|
|
12815
12818
|
},
|
|
12816
12819
|
receive(e) {
|
|
12817
|
-
if (!
|
|
12820
|
+
if (!Xv(e.header("x-telegram-bot-api-secret-token"), e.callbackSecret)) return {
|
|
12818
12821
|
body: "",
|
|
12819
12822
|
contentType: "text/plain",
|
|
12820
12823
|
outcome: "respond",
|
|
12821
12824
|
status: 404
|
|
12822
12825
|
};
|
|
12823
|
-
if (!
|
|
12826
|
+
if (!Zv(e.payload) || !Number.isSafeInteger(e.payload.update_id)) return {
|
|
12824
12827
|
outcome: "ignored",
|
|
12825
12828
|
reason: "Telegram update_id is missing."
|
|
12826
12829
|
};
|
|
@@ -12829,21 +12832,21 @@ var Uv = /* @__PURE__ */ new Set([
|
|
|
12829
12832
|
outcome: "ignored",
|
|
12830
12833
|
reason: "Telegram update body is missing."
|
|
12831
12834
|
};
|
|
12832
|
-
let n =
|
|
12833
|
-
if (!(
|
|
12835
|
+
let n = Jv(e.config);
|
|
12836
|
+
if (!(Yv(n) ?? Kv).includes(t)) return {
|
|
12834
12837
|
outcome: "ignored",
|
|
12835
12838
|
reason: "Telegram update type is not subscribed."
|
|
12836
12839
|
};
|
|
12837
12840
|
let r = e.payload[t];
|
|
12838
12841
|
if (n.chatIds.length > 0) {
|
|
12839
|
-
let e =
|
|
12842
|
+
let e = $v(r);
|
|
12840
12843
|
if (e == null || !n.chatIds.includes(e)) return {
|
|
12841
12844
|
outcome: "ignored",
|
|
12842
12845
|
reason: "Telegram chat does not match."
|
|
12843
12846
|
};
|
|
12844
12847
|
}
|
|
12845
12848
|
if (n.userIds.length > 0) {
|
|
12846
|
-
let e =
|
|
12849
|
+
let e = ey(r);
|
|
12847
12850
|
if (e == null || !n.userIds.includes(e)) return {
|
|
12848
12851
|
outcome: "ignored",
|
|
12849
12852
|
reason: "Telegram user does not match."
|
|
@@ -12861,19 +12864,19 @@ var Uv = /* @__PURE__ */ new Set([
|
|
|
12861
12864
|
};
|
|
12862
12865
|
},
|
|
12863
12866
|
async reconcile(e) {
|
|
12864
|
-
let n = await
|
|
12865
|
-
if (!e.active) return n == e.endpointUrl && await
|
|
12866
|
-
if (n != "" && n != e.endpointUrl) throw new t(`The Telegram bot already sends updates to ${
|
|
12867
|
-
let r =
|
|
12868
|
-
return await
|
|
12869
|
-
allowed_updates:
|
|
12867
|
+
let n = await ty(e);
|
|
12868
|
+
if (!e.active) return n == e.endpointUrl && await ny(e), { outcome: "ready" };
|
|
12869
|
+
if (n != "" && n != e.endpointUrl) throw new t(`The Telegram bot already sends updates to ${iy(n)}.`);
|
|
12870
|
+
let r = Jv(e.config);
|
|
12871
|
+
return await ry(e, "setWebhook", {
|
|
12872
|
+
allowed_updates: Yv(r) ?? [],
|
|
12870
12873
|
drop_pending_updates: n == "" && r.dropPendingUpdates,
|
|
12871
12874
|
secret_token: e.callbackSecret,
|
|
12872
12875
|
url: e.endpointUrl
|
|
12873
12876
|
}), { outcome: "ready" };
|
|
12874
12877
|
}
|
|
12875
12878
|
};
|
|
12876
|
-
function
|
|
12879
|
+
function Jv(e) {
|
|
12877
12880
|
return {
|
|
12878
12881
|
chatIds: e.chatIds,
|
|
12879
12882
|
dropPendingUpdates: e.dropPendingUpdates,
|
|
@@ -12881,38 +12884,38 @@ function qv(e) {
|
|
|
12881
12884
|
userIds: e.userIds
|
|
12882
12885
|
};
|
|
12883
12886
|
}
|
|
12884
|
-
function
|
|
12887
|
+
function Yv(e) {
|
|
12885
12888
|
if (!e.updates.includes("*")) return e.updates;
|
|
12886
12889
|
let t = e.updates.filter((e) => e != "*");
|
|
12887
|
-
return t.length == 0 ? null : [.../* @__PURE__ */ new Set([...
|
|
12890
|
+
return t.length == 0 ? null : [.../* @__PURE__ */ new Set([...Kv, ...t])];
|
|
12888
12891
|
}
|
|
12889
|
-
function
|
|
12892
|
+
function Xv(e, t) {
|
|
12890
12893
|
if (e == null || e.length != t.length) return !1;
|
|
12891
12894
|
let n = 0;
|
|
12892
12895
|
for (let r = 0; r < t.length; r += 1) n |= e.charCodeAt(r) ^ t.charCodeAt(r);
|
|
12893
12896
|
return n == 0;
|
|
12894
12897
|
}
|
|
12895
|
-
function Xv(e) {
|
|
12896
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
12897
|
-
}
|
|
12898
12898
|
function Zv(e) {
|
|
12899
|
-
|
|
12899
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
12900
12900
|
}
|
|
12901
12901
|
function Qv(e) {
|
|
12902
|
-
if (
|
|
12902
|
+
if (Zv(e)) return typeof e.id == "string" || typeof e.id == "number" ? String(e.id) : void 0;
|
|
12903
12903
|
}
|
|
12904
12904
|
function $v(e) {
|
|
12905
|
-
if (
|
|
12905
|
+
if (Zv(e)) return Qv(e.chat) ?? (Zv(e.message) ? Qv(e.message.chat) : void 0);
|
|
12906
|
+
}
|
|
12907
|
+
function ey(e) {
|
|
12908
|
+
if (Zv(e)) return Qv(e.from) ?? Qv(e.user);
|
|
12906
12909
|
}
|
|
12907
|
-
async function
|
|
12908
|
-
let t = await
|
|
12910
|
+
async function ty(e) {
|
|
12911
|
+
let t = await ry(e, "getWebhookInfo"), r = Zv(t.result) ? t.result.url : void 0;
|
|
12909
12912
|
if (typeof r != "string") throw new n("Telegram getWebhookInfo response is missing result.url.");
|
|
12910
12913
|
return r;
|
|
12911
12914
|
}
|
|
12912
|
-
async function
|
|
12913
|
-
await
|
|
12915
|
+
async function ny(e) {
|
|
12916
|
+
await ry(e, "deleteWebhook", { drop_pending_updates: !1 });
|
|
12914
12917
|
}
|
|
12915
|
-
async function
|
|
12918
|
+
async function ry(r, i, a) {
|
|
12916
12919
|
let o;
|
|
12917
12920
|
try {
|
|
12918
12921
|
o = await r.connector.execute({
|
|
@@ -12923,19 +12926,19 @@ async function ny(r, i, a) {
|
|
|
12923
12926
|
} catch (t) {
|
|
12924
12927
|
throw t instanceof e ? t : new n(`Telegram ${i} request failed.`, { cause: t });
|
|
12925
12928
|
}
|
|
12926
|
-
let s =
|
|
12929
|
+
let s = Zv(o.data) ? o.data : {};
|
|
12927
12930
|
if (o.status >= 200 && o.status < 300 && s.ok === !0) return s;
|
|
12928
12931
|
let c = typeof s.description == "string" ? s.description : `HTTP ${o.status}`;
|
|
12929
12932
|
throw o.status == 401 || o.status == 403 ? new e(`Telegram ${i} rejected the Connection.`) : o.status >= 400 && o.status < 500 && o.status != 429 ? new t(`Telegram ${i} rejected the subscription: ${c}`) : new n(`Telegram ${i} failed: ${c}`);
|
|
12930
12933
|
}
|
|
12931
|
-
function
|
|
12934
|
+
function iy(e) {
|
|
12932
12935
|
try {
|
|
12933
12936
|
return new URL(e).host;
|
|
12934
12937
|
} catch {
|
|
12935
12938
|
return "an invalid URL";
|
|
12936
12939
|
}
|
|
12937
12940
|
}
|
|
12938
|
-
var
|
|
12941
|
+
var ay = {
|
|
12939
12942
|
initialState: {
|
|
12940
12943
|
checkpoint: null,
|
|
12941
12944
|
subscription: {}
|
|
@@ -13047,7 +13050,7 @@ var iy = {
|
|
|
13047
13050
|
outcome: "ignored",
|
|
13048
13051
|
reason: "WooCommerce topic header is missing."
|
|
13049
13052
|
};
|
|
13050
|
-
if (!
|
|
13053
|
+
if (!oy(e.config).events.includes(t)) return {
|
|
13051
13054
|
outcome: "ignored",
|
|
13052
13055
|
reason: "WooCommerce topic is not subscribed."
|
|
13053
13056
|
};
|
|
@@ -13067,31 +13070,31 @@ var iy = {
|
|
|
13067
13070
|
};
|
|
13068
13071
|
},
|
|
13069
13072
|
async reconcile(e) {
|
|
13070
|
-
let t =
|
|
13073
|
+
let t = _y(e.state), n = oy(e.config), r = await ly(e);
|
|
13071
13074
|
if (!e.active) {
|
|
13072
|
-
for (let t of r) await
|
|
13073
|
-
return await t.saveSubscription({},
|
|
13075
|
+
for (let t of r) await uy(e, t.id);
|
|
13076
|
+
return await t.saveSubscription({}, vy(e.now)), { outcome: "ready" };
|
|
13074
13077
|
}
|
|
13075
13078
|
let i = /* @__PURE__ */ new Map();
|
|
13076
13079
|
for (let e of r) n.events.includes(e.topic) && !i.has(e.topic) && i.set(e.topic, e.id);
|
|
13077
13080
|
let a = new Set(i.values());
|
|
13078
|
-
for (let t of r) a.has(t.id) || await
|
|
13081
|
+
for (let t of r) a.has(t.id) || await uy(e, t.id);
|
|
13079
13082
|
let o = [];
|
|
13080
13083
|
for (let t of n.events) {
|
|
13081
13084
|
let r = i.get(t);
|
|
13082
|
-
o.push(r == null ? await
|
|
13085
|
+
o.push(r == null ? await sy(e, n, t) : await cy(e, r, t));
|
|
13083
13086
|
}
|
|
13084
|
-
return await t.saveSubscription({ webhookIds: o },
|
|
13087
|
+
return await t.saveSubscription({ webhookIds: o }, vy(e.now)), { outcome: "ready" };
|
|
13085
13088
|
}
|
|
13086
13089
|
};
|
|
13087
|
-
function
|
|
13090
|
+
function oy(e) {
|
|
13088
13091
|
return {
|
|
13089
13092
|
events: [...new Set(e.events)],
|
|
13090
13093
|
webhookName: e.webhookName
|
|
13091
13094
|
};
|
|
13092
13095
|
}
|
|
13093
|
-
async function
|
|
13094
|
-
let r = await
|
|
13096
|
+
async function sy(e, t, n) {
|
|
13097
|
+
let r = await dy(e, `webhook create (${n})`, {
|
|
13095
13098
|
body: {
|
|
13096
13099
|
delivery_url: e.endpointUrl,
|
|
13097
13100
|
name: `${t.webhookName} - ${n}`,
|
|
@@ -13101,10 +13104,10 @@ async function oy(e, t, n) {
|
|
|
13101
13104
|
endpoint: "/webhooks",
|
|
13102
13105
|
method: "POST"
|
|
13103
13106
|
});
|
|
13104
|
-
return
|
|
13107
|
+
return fy(r, `webhook create (${n})`), hy(r.data);
|
|
13105
13108
|
}
|
|
13106
|
-
async function
|
|
13107
|
-
let r = await
|
|
13109
|
+
async function cy(e, t, n) {
|
|
13110
|
+
let r = await dy(e, `webhook update (${n})`, {
|
|
13108
13111
|
body: {
|
|
13109
13112
|
delivery_url: e.endpointUrl,
|
|
13110
13113
|
secret: e.callbackSecret,
|
|
@@ -13114,12 +13117,12 @@ async function sy(e, t, n) {
|
|
|
13114
13117
|
endpoint: `/webhooks/${t}`,
|
|
13115
13118
|
method: "PUT"
|
|
13116
13119
|
});
|
|
13117
|
-
return
|
|
13120
|
+
return py(r) ? sy(e, oy(e.config), n) : (fy(r, `webhook update (${n})`), t);
|
|
13118
13121
|
}
|
|
13119
|
-
async function
|
|
13122
|
+
async function ly(e) {
|
|
13120
13123
|
let t = [];
|
|
13121
13124
|
for (let n = 1; n <= 10; n += 1) {
|
|
13122
|
-
let r = await
|
|
13125
|
+
let r = await dy(e, "webhook list", {
|
|
13123
13126
|
endpoint: "/webhooks",
|
|
13124
13127
|
method: "GET",
|
|
13125
13128
|
query: {
|
|
@@ -13129,12 +13132,12 @@ async function cy(e) {
|
|
|
13129
13132
|
status: "all"
|
|
13130
13133
|
}
|
|
13131
13134
|
});
|
|
13132
|
-
|
|
13135
|
+
fy(r, "webhook list");
|
|
13133
13136
|
let i = Array.isArray(r.data) ? r.data : [];
|
|
13134
13137
|
for (let n of i) {
|
|
13135
|
-
let r =
|
|
13138
|
+
let r = yy(n);
|
|
13136
13139
|
if (r?.delivery_url !== e.endpointUrl || typeof r.topic != "string") continue;
|
|
13137
|
-
let i =
|
|
13140
|
+
let i = gy(r.id);
|
|
13138
13141
|
i != null && t.push({
|
|
13139
13142
|
id: i,
|
|
13140
13143
|
topic: r.topic
|
|
@@ -13144,54 +13147,54 @@ async function cy(e) {
|
|
|
13144
13147
|
}
|
|
13145
13148
|
throw new n("WooCommerce webhook list did not finish within ten pages.");
|
|
13146
13149
|
}
|
|
13147
|
-
async function
|
|
13148
|
-
let n = await
|
|
13150
|
+
async function uy(e, t) {
|
|
13151
|
+
let n = await dy(e, "webhook delete", {
|
|
13149
13152
|
endpoint: `/webhooks/${t}`,
|
|
13150
13153
|
method: "DELETE",
|
|
13151
13154
|
query: { force: "true" }
|
|
13152
13155
|
});
|
|
13153
|
-
n.status != 404 &&
|
|
13156
|
+
n.status != 404 && fy(n, "webhook delete");
|
|
13154
13157
|
}
|
|
13155
|
-
async function
|
|
13158
|
+
async function dy(t, r, i) {
|
|
13156
13159
|
try {
|
|
13157
13160
|
return await t.connector.execute(i, t.signal);
|
|
13158
13161
|
} catch (t) {
|
|
13159
13162
|
throw t instanceof e ? t : new n(`WooCommerce ${r} request failed.`, { cause: t });
|
|
13160
13163
|
}
|
|
13161
13164
|
}
|
|
13162
|
-
function
|
|
13165
|
+
function fy(r, i) {
|
|
13163
13166
|
if (r.status >= 200 && r.status < 300) return;
|
|
13164
|
-
let a =
|
|
13167
|
+
let a = my(r.data);
|
|
13165
13168
|
throw r.status == 401 || r.status == 403 ? new e(`WooCommerce ${i} rejected the Connection.`) : r.status == 404 || r.status == 400 && (a.endsWith("_invalid_topic") || a.endsWith("_invalid_delivery_url")) || r.status == 501 && a == "woocommerce_rest_trash_not_supported" ? new t(`WooCommerce ${i} rejected the subscription.`) : new n(`WooCommerce ${i} failed with status ${r.status}.`);
|
|
13166
13169
|
}
|
|
13167
|
-
function fy(e) {
|
|
13168
|
-
return e.status == 400 && py(e.data) == "woocommerce_rest_webhook_invalid_id";
|
|
13169
|
-
}
|
|
13170
13170
|
function py(e) {
|
|
13171
|
-
|
|
13172
|
-
return typeof t == "string" ? t : "";
|
|
13171
|
+
return e.status == 400 && my(e.data) == "woocommerce_rest_webhook_invalid_id";
|
|
13173
13172
|
}
|
|
13174
13173
|
function my(e) {
|
|
13175
|
-
let t =
|
|
13174
|
+
let t = yy(e)?.code;
|
|
13175
|
+
return typeof t == "string" ? t : "";
|
|
13176
|
+
}
|
|
13177
|
+
function hy(e) {
|
|
13178
|
+
let t = gy(yy(e)?.id);
|
|
13176
13179
|
if (t == null) throw new n("WooCommerce webhook response is missing its ID.");
|
|
13177
13180
|
return t;
|
|
13178
13181
|
}
|
|
13179
|
-
function
|
|
13182
|
+
function gy(e) {
|
|
13180
13183
|
return typeof e == "string" && e.length > 0 ? e : typeof e == "number" && Number.isFinite(e) ? String(e) : null;
|
|
13181
13184
|
}
|
|
13182
|
-
function
|
|
13185
|
+
function _y(e) {
|
|
13183
13186
|
if (e == null) throw new t("WooCommerce Integration state is missing.");
|
|
13184
13187
|
return e;
|
|
13185
13188
|
}
|
|
13186
|
-
function
|
|
13189
|
+
function vy(e) {
|
|
13187
13190
|
return new Date(e.getTime() + 2592e6);
|
|
13188
13191
|
}
|
|
13189
|
-
function
|
|
13192
|
+
function yy(e) {
|
|
13190
13193
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
13191
13194
|
}
|
|
13192
13195
|
//#endregion
|
|
13193
13196
|
//#region src/trigger/providers/zendesk/on-event.ts
|
|
13194
|
-
var
|
|
13197
|
+
var by = 3e5, xy = /* @__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(","), Sy = "/api/v2/webhooks", Cy = {
|
|
13195
13198
|
initialState: {
|
|
13196
13199
|
checkpoint: null,
|
|
13197
13200
|
subscription: {}
|
|
@@ -13201,7 +13204,7 @@ var yy = 3e5, by = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_chang
|
|
|
13201
13204
|
handle: "events",
|
|
13202
13205
|
jsonSchema: {
|
|
13203
13206
|
items: {
|
|
13204
|
-
enum:
|
|
13207
|
+
enum: xy,
|
|
13205
13208
|
type: "string"
|
|
13206
13209
|
},
|
|
13207
13210
|
minItems: 1,
|
|
@@ -13250,8 +13253,8 @@ var yy = 3e5, by = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_chang
|
|
|
13250
13253
|
type: "integration"
|
|
13251
13254
|
},
|
|
13252
13255
|
async receive(e) {
|
|
13253
|
-
let t =
|
|
13254
|
-
if (t == null || n == null || !Number.isFinite(r) || Math.abs(e.now.getTime() - r) >
|
|
13256
|
+
let t = Ny(e.state), n = e.header("x-zendesk-webhook-signature-timestamp"), r = n == null ? NaN : Date.parse(n);
|
|
13257
|
+
if (t == null || n == null || !Number.isFinite(r) || Math.abs(e.now.getTime() - r) > by || !await De(t, [Te(n), e.rawBody], e.header("x-zendesk-webhook-signature"))) return {
|
|
13255
13258
|
body: "",
|
|
13256
13259
|
contentType: "text/plain",
|
|
13257
13260
|
outcome: "respond",
|
|
@@ -13283,137 +13286,137 @@ var yy = 3e5, by = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_chang
|
|
|
13283
13286
|
};
|
|
13284
13287
|
},
|
|
13285
13288
|
async reconcile(e) {
|
|
13286
|
-
let t =
|
|
13289
|
+
let t = jy(e.state), n = await Ty(e), r = My(t);
|
|
13287
13290
|
if (!e.active) {
|
|
13288
|
-
for (let t of r == null ? n : [.../* @__PURE__ */ new Set([r, ...n])]) await
|
|
13289
|
-
return await t.saveSubscription({},
|
|
13291
|
+
for (let t of r == null ? n : [.../* @__PURE__ */ new Set([r, ...n])]) await Ey(e, t);
|
|
13292
|
+
return await t.saveSubscription({}, Fy(e.now)), { outcome: "ready" };
|
|
13290
13293
|
}
|
|
13291
13294
|
let i = r ?? n[0];
|
|
13292
13295
|
if (i == null) {
|
|
13293
|
-
let t = await
|
|
13294
|
-
body:
|
|
13295
|
-
endpoint:
|
|
13296
|
+
let t = await Dy(e, "webhook create", {
|
|
13297
|
+
body: wy(e),
|
|
13298
|
+
endpoint: Sy,
|
|
13296
13299
|
method: "POST"
|
|
13297
13300
|
});
|
|
13298
|
-
|
|
13301
|
+
Oy(t, "webhook create"), i = Ay(Iy(t.data)?.webhook);
|
|
13299
13302
|
} else {
|
|
13300
|
-
let n = await
|
|
13301
|
-
body:
|
|
13302
|
-
endpoint: `${
|
|
13303
|
+
let n = await Dy(e, "webhook update", {
|
|
13304
|
+
body: wy(e),
|
|
13305
|
+
endpoint: `${Sy}/${i}`,
|
|
13303
13306
|
method: "PUT"
|
|
13304
13307
|
});
|
|
13305
13308
|
if (n.status == 404) return await t.saveSubscription({}, e.now), { outcome: "pending" };
|
|
13306
|
-
|
|
13309
|
+
Oy(n, "webhook update");
|
|
13307
13310
|
}
|
|
13308
|
-
for (let t of n.filter((e) => e != i)) await
|
|
13311
|
+
for (let t of n.filter((e) => e != i)) await Ey(e, t);
|
|
13309
13312
|
return await t.saveSubscription({
|
|
13310
|
-
signingSecret: await
|
|
13313
|
+
signingSecret: await Py(e, i),
|
|
13311
13314
|
webhookId: i
|
|
13312
|
-
},
|
|
13315
|
+
}, Fy(e.now)), { outcome: "ready" };
|
|
13313
13316
|
}
|
|
13314
13317
|
};
|
|
13315
|
-
function
|
|
13318
|
+
function wy(e) {
|
|
13316
13319
|
return { webhook: {
|
|
13317
13320
|
description: "Managed by Open Flow. Do not edit.",
|
|
13318
13321
|
endpoint: e.endpointUrl,
|
|
13319
13322
|
http_method: "POST",
|
|
13320
|
-
name:
|
|
13323
|
+
name: ky(e.endpointUrl),
|
|
13321
13324
|
request_format: "json",
|
|
13322
13325
|
status: "active",
|
|
13323
13326
|
subscriptions: [...new Set(e.config.events)]
|
|
13324
13327
|
} };
|
|
13325
13328
|
}
|
|
13326
|
-
async function
|
|
13329
|
+
async function Ty(e) {
|
|
13327
13330
|
let t = [], n;
|
|
13328
13331
|
for (let r = 0; r < 10; r += 1) {
|
|
13329
|
-
let r = await
|
|
13330
|
-
endpoint:
|
|
13332
|
+
let r = await Dy(e, "webhook list", {
|
|
13333
|
+
endpoint: Sy,
|
|
13331
13334
|
method: "GET",
|
|
13332
13335
|
query: {
|
|
13333
|
-
"filter[name_contains]":
|
|
13336
|
+
"filter[name_contains]": ky(e.endpointUrl),
|
|
13334
13337
|
"page[size]": "100",
|
|
13335
13338
|
...n == null ? {} : { "page[after]": n }
|
|
13336
13339
|
}
|
|
13337
13340
|
});
|
|
13338
|
-
|
|
13339
|
-
let i =
|
|
13341
|
+
Oy(r, "webhook list");
|
|
13342
|
+
let i = Iy(r.data), a = Array.isArray(i?.webhooks) ? i.webhooks : [];
|
|
13340
13343
|
for (let n of a) {
|
|
13341
|
-
let r =
|
|
13344
|
+
let r = Iy(n);
|
|
13342
13345
|
r?.endpoint === e.endpointUrl && typeof r.id == "string" && t.push(r.id);
|
|
13343
13346
|
}
|
|
13344
|
-
let o =
|
|
13347
|
+
let o = Iy(i?.meta);
|
|
13345
13348
|
if (o?.has_more !== !0 || typeof o.after_cursor != "string") return t;
|
|
13346
13349
|
n = o.after_cursor;
|
|
13347
13350
|
}
|
|
13348
13351
|
return t;
|
|
13349
13352
|
}
|
|
13350
|
-
async function
|
|
13351
|
-
let n = await
|
|
13352
|
-
endpoint: `${
|
|
13353
|
+
async function Ey(e, t) {
|
|
13354
|
+
let n = await Dy(e, "webhook delete", {
|
|
13355
|
+
endpoint: `${Sy}/${t}`,
|
|
13353
13356
|
method: "DELETE"
|
|
13354
13357
|
});
|
|
13355
|
-
n.status != 404 &&
|
|
13358
|
+
n.status != 404 && Oy(n, "webhook delete");
|
|
13356
13359
|
}
|
|
13357
|
-
async function
|
|
13360
|
+
async function Dy(t, r, i) {
|
|
13358
13361
|
try {
|
|
13359
13362
|
return await t.connector.execute(i, t.signal);
|
|
13360
13363
|
} catch (t) {
|
|
13361
13364
|
throw t instanceof e ? t : new n(`Zendesk ${r} request failed.`, { cause: t });
|
|
13362
13365
|
}
|
|
13363
13366
|
}
|
|
13364
|
-
function
|
|
13367
|
+
function Oy(r, i) {
|
|
13365
13368
|
if (!(r.status >= 200 && r.status < 300)) throw r.status == 401 || r.status == 403 ? new e(`Zendesk ${i} rejected the Connection.`) : [
|
|
13366
13369
|
400,
|
|
13367
13370
|
404,
|
|
13368
13371
|
422
|
|
13369
13372
|
].includes(r.status) ? new t(`Zendesk ${i} rejected the subscription.`) : new n(`Zendesk ${i} failed with status ${r.status}.`);
|
|
13370
13373
|
}
|
|
13371
|
-
function
|
|
13374
|
+
function ky(e) {
|
|
13372
13375
|
return `open-flow-${e.slice(e.lastIndexOf("/") + 1)}`;
|
|
13373
13376
|
}
|
|
13374
|
-
function
|
|
13375
|
-
let t =
|
|
13377
|
+
function Ay(e) {
|
|
13378
|
+
let t = Iy(e)?.id;
|
|
13376
13379
|
if (typeof t != "string") throw new n("Zendesk webhook response is missing its ID.");
|
|
13377
13380
|
return t;
|
|
13378
13381
|
}
|
|
13379
|
-
function
|
|
13382
|
+
function jy(e) {
|
|
13380
13383
|
if (e == null) throw new t("Zendesk Integration state is missing.");
|
|
13381
13384
|
return e;
|
|
13382
13385
|
}
|
|
13383
|
-
function
|
|
13386
|
+
function My(e) {
|
|
13384
13387
|
let t = e.subscription.webhookId;
|
|
13385
13388
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
13386
13389
|
}
|
|
13387
|
-
function
|
|
13390
|
+
function Ny(e) {
|
|
13388
13391
|
let t = e?.subscription.signingSecret;
|
|
13389
13392
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
13390
13393
|
}
|
|
13391
|
-
async function
|
|
13392
|
-
let r = await
|
|
13393
|
-
endpoint: `${
|
|
13394
|
+
async function Py(e, t) {
|
|
13395
|
+
let r = await Dy(e, "webhook signing secret", {
|
|
13396
|
+
endpoint: `${Sy}/${t}/signing_secret`,
|
|
13394
13397
|
method: "GET"
|
|
13395
13398
|
});
|
|
13396
|
-
|
|
13397
|
-
let i =
|
|
13399
|
+
Oy(r, "webhook signing secret");
|
|
13400
|
+
let i = Iy(Iy(r.data)?.signing_secret)?.secret;
|
|
13398
13401
|
if (typeof i != "string" || i.length == 0) throw new n("Zendesk webhook signing secret response is invalid.");
|
|
13399
13402
|
return i;
|
|
13400
13403
|
}
|
|
13401
|
-
function
|
|
13404
|
+
function Fy(e) {
|
|
13402
13405
|
return new Date(e.getTime() + 2592e6);
|
|
13403
13406
|
}
|
|
13404
|
-
function
|
|
13407
|
+
function Iy(e) {
|
|
13405
13408
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
13406
13409
|
}
|
|
13407
13410
|
//#endregion
|
|
13408
13411
|
//#region src/trigger/providers/fieldDescriptions.ts
|
|
13409
|
-
var
|
|
13412
|
+
var Ly = {
|
|
13410
13413
|
driveId: "Shared drive ID. Leave empty to monitor the connected account.",
|
|
13411
13414
|
includeCorpusRemovals: "Include the accessible file resource when an item leaves the change corpus.",
|
|
13412
13415
|
includeItemsFromAllDrives: "Include items from My Drive and shared drives.",
|
|
13413
13416
|
includeRemoved: "Include changes caused by deletion or loss of access.",
|
|
13414
13417
|
pageSize: "Maximum number of changes included in one Flow Run.",
|
|
13415
13418
|
restrictToMyDrive: "Restrict changes to the My Drive hierarchy."
|
|
13416
|
-
},
|
|
13419
|
+
}, Ry = {
|
|
13417
13420
|
"feishu_app_bot.on_event": {
|
|
13418
13421
|
configInputs: {
|
|
13419
13422
|
sourceId: "Event source that receives events for this trigger.",
|
|
@@ -13502,11 +13505,11 @@ var Iy = {
|
|
|
13502
13505
|
outputs: { events: "Calendar events created, updated, or cancelled since the previous poll." }
|
|
13503
13506
|
},
|
|
13504
13507
|
"googledrive.changes_detected": {
|
|
13505
|
-
configInputs:
|
|
13508
|
+
configInputs: Ly,
|
|
13506
13509
|
outputs: { events: "Google Drive changes available when the notification was received." }
|
|
13507
13510
|
},
|
|
13508
13511
|
"googledrive.watch_changes": {
|
|
13509
|
-
configInputs:
|
|
13512
|
+
configInputs: Ly,
|
|
13510
13513
|
outputs: { events: "Google Drive changes observed by notifications or periodic scans." }
|
|
13511
13514
|
},
|
|
13512
13515
|
"googledrive.on_file_change": {
|
|
@@ -13647,7 +13650,7 @@ var Iy = {
|
|
|
13647
13650
|
subject: "Zendesk subject associated with the event."
|
|
13648
13651
|
}
|
|
13649
13652
|
}
|
|
13650
|
-
},
|
|
13653
|
+
}, zy = {
|
|
13651
13654
|
en: {
|
|
13652
13655
|
"feishu_app_bot.on_event": {
|
|
13653
13656
|
sourceId: "Event source",
|
|
@@ -13942,34 +13945,34 @@ var Iy = {
|
|
|
13942
13945
|
"woocommerce.on_store_event": { events: "Événements" },
|
|
13943
13946
|
"zendesk.on_event": { events: "Événements" }
|
|
13944
13947
|
}
|
|
13945
|
-
},
|
|
13948
|
+
}, By = {
|
|
13946
13949
|
"zh-CN": () => import("./zh-CN-CxZ3yYfR.js"),
|
|
13947
13950
|
"zh-TW": () => import("./zh-TW-CRmc3FMz.js"),
|
|
13948
13951
|
ja: () => import("./ja-BJF-VrP2.js"),
|
|
13949
13952
|
ko: () => import("./ko-Bght_VaB.js"),
|
|
13950
13953
|
ru: () => import("./ru-DrP4BRM5.js"),
|
|
13951
13954
|
fr: () => import("./fr-ClB96SQY.js")
|
|
13952
|
-
},
|
|
13953
|
-
function
|
|
13954
|
-
if (e == "en") return
|
|
13955
|
-
let t =
|
|
13955
|
+
}, Vy = /* @__PURE__ */ new Map(), Hy = Promise.resolve({});
|
|
13956
|
+
function Uy(e) {
|
|
13957
|
+
if (e == "en") return Hy;
|
|
13958
|
+
let t = Vy.get(e);
|
|
13956
13959
|
if (t != null) return t;
|
|
13957
|
-
let n =
|
|
13958
|
-
return
|
|
13959
|
-
|
|
13960
|
+
let n = By[e]().then((e) => e.default);
|
|
13961
|
+
return Vy.set(e, n), n.catch(() => {
|
|
13962
|
+
Vy.get(e) == n && Vy.delete(e);
|
|
13960
13963
|
}), n;
|
|
13961
13964
|
}
|
|
13962
|
-
async function
|
|
13963
|
-
let n = (await
|
|
13965
|
+
async function Wy(e, t) {
|
|
13966
|
+
let n = (await Uy(t))[e.key], r = Ry[e.key];
|
|
13964
13967
|
return {
|
|
13965
|
-
configInputs:
|
|
13966
|
-
configInputLabels:
|
|
13968
|
+
configInputs: Gy(e.configInputs, n?.configInputs, r?.configInputs),
|
|
13969
|
+
configInputLabels: zy[t][e.key] ?? {},
|
|
13967
13970
|
displayName: n?.displayName ?? e.displayName,
|
|
13968
13971
|
description: n?.description ?? e.description,
|
|
13969
|
-
outputs:
|
|
13972
|
+
outputs: Gy(e.outputs, n?.outputs, r?.outputs)
|
|
13970
13973
|
};
|
|
13971
13974
|
}
|
|
13972
|
-
function
|
|
13975
|
+
function Gy(e, t, n) {
|
|
13973
13976
|
return Object.fromEntries(e.flatMap((e) => {
|
|
13974
13977
|
if (!("handle" in e)) return [];
|
|
13975
13978
|
let r = t?.[e.handle] ?? n?.[e.handle] ?? e.description;
|
|
@@ -13978,7 +13981,7 @@ function Wy(e, t, n) {
|
|
|
13978
13981
|
}
|
|
13979
13982
|
//#endregion
|
|
13980
13983
|
//#region src/trigger/providers/definitions.ts
|
|
13981
|
-
var
|
|
13984
|
+
var Ky = [
|
|
13982
13985
|
...f,
|
|
13983
13986
|
re,
|
|
13984
13987
|
Pu,
|
|
@@ -13986,20 +13989,20 @@ var Gy = [
|
|
|
13986
13989
|
hu,
|
|
13987
13990
|
yu,
|
|
13988
13991
|
$u,
|
|
13989
|
-
|
|
13990
|
-
|
|
13991
|
-
|
|
13992
|
-
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
|
|
13996
|
-
|
|
13997
|
-
|
|
13998
|
-
|
|
13999
|
-
|
|
14000
|
-
|
|
14001
|
-
|
|
14002
|
-
|
|
14003
|
-
],
|
|
13992
|
+
Ch,
|
|
13993
|
+
Kh,
|
|
13994
|
+
Zh,
|
|
13995
|
+
yg,
|
|
13996
|
+
Bg,
|
|
13997
|
+
Kg,
|
|
13998
|
+
h_,
|
|
13999
|
+
L_,
|
|
14000
|
+
Q_,
|
|
14001
|
+
hv,
|
|
14002
|
+
Av,
|
|
14003
|
+
qv,
|
|
14004
|
+
ay,
|
|
14005
|
+
Cy
|
|
14006
|
+
], qy = Ky.filter((e) => e.snapshot.type == "poll"), Jy = Ky.filter((e) => e.snapshot.type == "integration");
|
|
14004
14007
|
//#endregion
|
|
14005
|
-
export { d as feishuResponse, u as feishuSubscriptions,
|
|
14008
|
+
export { d as feishuResponse, u as feishuSubscriptions, Jy as integrationDefinitions, Wy as localizeTrigger, te as matchesFeishuEvent, qy as pollDefinitions, h as receiveFeishuEvent, Ky as triggerDefinitions };
|