@oomol-lab/open-flow 0.1.0-beta.23 → 0.1.0-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{createResourceDialog-PKbMMpEk.js → createResourceDialog-BwI2JmPE.js} +7 -7
- package/dist/browser/flow-authoring.js +249 -250
- package/dist/browser/flow-change.d.ts +16 -7
- package/dist/browser/flow-change.js +824 -804
- package/dist/browser/{flowChanges-BUlMz4iC.js → flowChanges-BqPtWEI9.js} +2706 -2906
- package/dist/browser/{flowWorkspace-DLArN17T.js → flowWorkspace-CpMGzmfz.js} +37249 -35916
- package/dist/browser/{inputValues-CcGVt51C.js → inputValues-CeeJw_G8.js} +1 -1
- package/dist/browser/licenses.md +24 -0
- package/dist/browser/{lite-Cy6aeiL6.js → lite-BuKZ8joP.js} +50 -43
- package/dist/browser/{input-group-C2frNYAx.js → switch-CyZ96-UF.js} +1519 -612
- package/dist/browser/theme.css +30 -4
- package/dist/browser/ui-input.d.ts +3 -1
- package/dist/browser/ui.css +1 -1
- package/dist/browser/ui.js +10 -8
- package/dist/browser/warmCodeTheme-DVv4-rDO.js +35 -0
- package/dist/browser/workbench.css +1 -1
- package/dist/browser/workbench.js +753 -714
- package/dist/browser/{workbenchSelect-CPRUXKbf.js → workbenchSelect-BUu7CjUA.js} +504 -490
- package/dist/common/control-api-conformance.js +18 -18
- package/dist/common/control-api.d.ts +43 -15
- package/dist/common/control-api.js +1803 -1755
- package/dist/common/control-requests.js +2 -7
- package/dist/common/engine-contract.d.ts +2 -2
- package/dist/common/flow-encoding.js +587 -589
- package/dist/common/flow-graph.d.ts +31 -1
- package/dist/common/flow-schema.d.ts +11 -1
- package/dist/common/flow-semantics.d.ts +2 -1
- package/dist/common/flow-semantics.js +1542 -1457
- package/dist/common/mcp.d.ts +1 -0
- package/dist/common/mcp.js +308 -260
- package/dist/common/provider-triggers.js +934 -931
- package/dist/common/run-lifecycle.d.ts +1 -1
- package/dist/common/run-lifecycle.js +5 -5
- package/dist/common/runtime-contract.d.ts +2 -0
- package/dist/common/runtime-contract.js +96 -32
- package/dist/common/scheduler.d.ts +39 -21
- package/dist/common/scheduler.js +2358 -2339
- package/package.json +1 -1
|
@@ -4433,28 +4433,28 @@ var P = /*@__PURE__*/ w("ZodType", (e, t) => (vs(), O.init(e, t), e.def = t, e.t
|
|
|
4433
4433
|
return e.add(this, t), this;
|
|
4434
4434
|
},
|
|
4435
4435
|
refine(e, t) {
|
|
4436
|
-
return this.check(
|
|
4436
|
+
return this.check(Pc(e, t));
|
|
4437
4437
|
},
|
|
4438
4438
|
superRefine(e, t) {
|
|
4439
|
-
return this.check(
|
|
4439
|
+
return this.check(Fc(e, t));
|
|
4440
4440
|
},
|
|
4441
4441
|
overwrite(e) {
|
|
4442
4442
|
return this.check(/* @__PURE__ */ ro(e));
|
|
4443
4443
|
},
|
|
4444
4444
|
optional() {
|
|
4445
|
-
return
|
|
4445
|
+
return mc(this);
|
|
4446
4446
|
},
|
|
4447
4447
|
exactOptional() {
|
|
4448
|
-
return
|
|
4448
|
+
return gc(this);
|
|
4449
4449
|
},
|
|
4450
4450
|
nullable() {
|
|
4451
|
-
return
|
|
4451
|
+
return vc(this);
|
|
4452
4452
|
},
|
|
4453
4453
|
nullish() {
|
|
4454
|
-
return
|
|
4454
|
+
return mc(vc(this));
|
|
4455
4455
|
},
|
|
4456
4456
|
nonoptional(e) {
|
|
4457
|
-
return
|
|
4457
|
+
return wc(this, e);
|
|
4458
4458
|
},
|
|
4459
4459
|
array() {
|
|
4460
4460
|
return B(this);
|
|
@@ -4463,25 +4463,25 @@ var P = /*@__PURE__*/ w("ZodType", (e, t) => (vs(), O.init(e, t), e.def = t, e.t
|
|
|
4463
4463
|
return H([this, e]);
|
|
4464
4464
|
},
|
|
4465
4465
|
and(e) {
|
|
4466
|
-
return
|
|
4466
|
+
return ac(this, e);
|
|
4467
4467
|
},
|
|
4468
4468
|
transform(e) {
|
|
4469
|
-
return
|
|
4469
|
+
return Oc(this, fc(e));
|
|
4470
4470
|
},
|
|
4471
4471
|
default(e) {
|
|
4472
|
-
return
|
|
4472
|
+
return bc(this, e);
|
|
4473
4473
|
},
|
|
4474
4474
|
prefault(e) {
|
|
4475
|
-
return
|
|
4475
|
+
return Sc(this, e);
|
|
4476
4476
|
},
|
|
4477
4477
|
catch(e) {
|
|
4478
|
-
return
|
|
4478
|
+
return Ec(this, e);
|
|
4479
4479
|
},
|
|
4480
4480
|
pipe(e) {
|
|
4481
|
-
return
|
|
4481
|
+
return Oc(this, e);
|
|
4482
4482
|
},
|
|
4483
4483
|
readonly() {
|
|
4484
|
-
return
|
|
4484
|
+
return Ac(this);
|
|
4485
4485
|
},
|
|
4486
4486
|
describe(e) {
|
|
4487
4487
|
let t = this.clone();
|
|
@@ -4905,13 +4905,13 @@ var tc = /*@__PURE__*/ w("ZodObject", (e, t) => {
|
|
|
4905
4905
|
return ft(this, e);
|
|
4906
4906
|
},
|
|
4907
4907
|
partial(...e) {
|
|
4908
|
-
return gt(
|
|
4908
|
+
return gt(pc, this, e[0]);
|
|
4909
4909
|
},
|
|
4910
4910
|
exactPartial(...e) {
|
|
4911
|
-
return gt(
|
|
4911
|
+
return gt(hc, this, e[0], "exactPartial");
|
|
4912
4912
|
},
|
|
4913
4913
|
required(...e) {
|
|
4914
|
-
return _t(
|
|
4914
|
+
return _t(Cc, this, e[0]);
|
|
4915
4915
|
}
|
|
4916
4916
|
});
|
|
4917
4917
|
function V(e, t) {
|
|
@@ -4921,27 +4921,35 @@ function V(e, t) {
|
|
|
4921
4921
|
...b(t)
|
|
4922
4922
|
});
|
|
4923
4923
|
}
|
|
4924
|
-
|
|
4924
|
+
function nc(e, t) {
|
|
4925
|
+
return new tc({
|
|
4926
|
+
type: "object",
|
|
4927
|
+
shape: e,
|
|
4928
|
+
catchall: $s(),
|
|
4929
|
+
...b(t)
|
|
4930
|
+
});
|
|
4931
|
+
}
|
|
4932
|
+
var rc = /*@__PURE__*/ w("ZodUnion", (e, t) => {
|
|
4925
4933
|
gi.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Bo(e, t, n, r), e.options = t.options;
|
|
4926
4934
|
});
|
|
4927
4935
|
function H(e, t) {
|
|
4928
|
-
return new
|
|
4936
|
+
return new rc({
|
|
4929
4937
|
type: "union",
|
|
4930
4938
|
options: e,
|
|
4931
4939
|
...b(t)
|
|
4932
4940
|
});
|
|
4933
4941
|
}
|
|
4934
|
-
var
|
|
4942
|
+
var ic = /*@__PURE__*/ w("ZodIntersection", (e, t) => {
|
|
4935
4943
|
_i.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Vo(e, t, n, r);
|
|
4936
4944
|
});
|
|
4937
|
-
function
|
|
4938
|
-
return new
|
|
4945
|
+
function ac(e, t) {
|
|
4946
|
+
return new ic({
|
|
4939
4947
|
type: "intersection",
|
|
4940
4948
|
left: e,
|
|
4941
4949
|
right: t
|
|
4942
4950
|
});
|
|
4943
4951
|
}
|
|
4944
|
-
var
|
|
4952
|
+
var oc = /*@__PURE__*/ w("ZodTuple", (e, t) => {
|
|
4945
4953
|
ys(), bi.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Ho(e, t, n, r);
|
|
4946
4954
|
}, {
|
|
4947
4955
|
rest(e) {
|
|
@@ -4955,46 +4963,46 @@ var ac = /*@__PURE__*/ w("ZodTuple", (e, t) => {
|
|
|
4955
4963
|
if (e.checks?.length) throw Error(".partial() cannot be used on tuple schemas containing refinements");
|
|
4956
4964
|
return this.clone({
|
|
4957
4965
|
...e,
|
|
4958
|
-
items: e.items.map((e) => new
|
|
4966
|
+
items: e.items.map((e) => new pc({
|
|
4959
4967
|
type: "optional",
|
|
4960
4968
|
innerType: e
|
|
4961
4969
|
}))
|
|
4962
4970
|
});
|
|
4963
4971
|
}
|
|
4964
4972
|
});
|
|
4965
|
-
function
|
|
4973
|
+
function sc(e, t, n) {
|
|
4966
4974
|
let r = t instanceof O;
|
|
4967
|
-
return new
|
|
4975
|
+
return new oc({
|
|
4968
4976
|
type: "tuple",
|
|
4969
4977
|
items: e,
|
|
4970
4978
|
rest: r ? t : null,
|
|
4971
4979
|
...b(r ? n : t)
|
|
4972
4980
|
});
|
|
4973
4981
|
}
|
|
4974
|
-
var
|
|
4982
|
+
var cc = /*@__PURE__*/ w("ZodRecord", (e, t) => {
|
|
4975
4983
|
ys(), wi.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Ko(e, t, n, r), e.keyType = t.keyType, e.valueType = t.valueType;
|
|
4976
4984
|
});
|
|
4977
4985
|
function U(e, t, n) {
|
|
4978
|
-
return !t || !t._zod ? new
|
|
4986
|
+
return !t || !t._zod ? new cc({
|
|
4979
4987
|
type: "record",
|
|
4980
4988
|
keyType: F(),
|
|
4981
4989
|
valueType: e,
|
|
4982
4990
|
...b(t)
|
|
4983
|
-
}) : new
|
|
4991
|
+
}) : new cc({
|
|
4984
4992
|
type: "record",
|
|
4985
4993
|
keyType: e,
|
|
4986
4994
|
valueType: t,
|
|
4987
4995
|
...b(n)
|
|
4988
4996
|
});
|
|
4989
4997
|
}
|
|
4990
|
-
var
|
|
4998
|
+
var lc = /*@__PURE__*/ w("ZodEnum", (e, t) => {
|
|
4991
4999
|
Ti.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => No(e, t, n, r), e.enum = t.entries, e.options = Object.values(t.entries);
|
|
4992
5000
|
let n = new Set(Object.keys(t.entries));
|
|
4993
5001
|
e.extract = (e, r) => {
|
|
4994
5002
|
let i = {};
|
|
4995
5003
|
for (let r of e) if (n.has(r)) i[r] = t.entries[r];
|
|
4996
5004
|
else throw Error(`Key ${r} not found in enum`);
|
|
4997
|
-
return new
|
|
5005
|
+
return new lc({
|
|
4998
5006
|
...t,
|
|
4999
5007
|
checks: [],
|
|
5000
5008
|
...b(r),
|
|
@@ -5004,7 +5012,7 @@ var cc = /*@__PURE__*/ w("ZodEnum", (e, t) => {
|
|
|
5004
5012
|
let i = { ...t.entries };
|
|
5005
5013
|
for (let t of e) if (n.has(t)) delete i[t];
|
|
5006
5014
|
else throw Error(`Key ${t} not found in enum`);
|
|
5007
|
-
return new
|
|
5015
|
+
return new lc({
|
|
5008
5016
|
...t,
|
|
5009
5017
|
checks: [],
|
|
5010
5018
|
...b(r),
|
|
@@ -5013,26 +5021,26 @@ var cc = /*@__PURE__*/ w("ZodEnum", (e, t) => {
|
|
|
5013
5021
|
};
|
|
5014
5022
|
});
|
|
5015
5023
|
function W(e, t) {
|
|
5016
|
-
return new
|
|
5024
|
+
return new lc({
|
|
5017
5025
|
type: "enum",
|
|
5018
5026
|
entries: Array.isArray(e) ? Object.fromEntries(e.map((e) => [e, e])) : e,
|
|
5019
5027
|
...b(t)
|
|
5020
5028
|
});
|
|
5021
5029
|
}
|
|
5022
|
-
var
|
|
5030
|
+
var uc = /*@__PURE__*/ w("ZodLiteral", (e, t) => {
|
|
5023
5031
|
Ei.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Po(e, t, n, r), e.values = new Set(t.values), Object.defineProperty(e, "value", { get() {
|
|
5024
5032
|
if (t.values.length > 1) throw Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
5025
5033
|
return t.values[0];
|
|
5026
5034
|
} });
|
|
5027
5035
|
});
|
|
5028
5036
|
function G(e, t) {
|
|
5029
|
-
return new
|
|
5037
|
+
return new uc({
|
|
5030
5038
|
type: "literal",
|
|
5031
5039
|
values: Array.isArray(e) ? e : [e],
|
|
5032
5040
|
...b(t)
|
|
5033
5041
|
});
|
|
5034
5042
|
}
|
|
5035
|
-
var
|
|
5043
|
+
var dc = /*@__PURE__*/ w("ZodTransform", (e, t) => {
|
|
5036
5044
|
ys(), Di.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Io(e, t, n, r), e._zod.parse = (n, r) => {
|
|
5037
5045
|
if (r.direction === "backward") throw new Ut(e.constructor.name);
|
|
5038
5046
|
n.addIssue = (r) => {
|
|
@@ -5046,44 +5054,44 @@ var uc = /*@__PURE__*/ w("ZodTransform", (e, t) => {
|
|
|
5046
5054
|
return i instanceof Promise ? i.then((e) => (n.value = e, n)) : (n.value = i, n);
|
|
5047
5055
|
};
|
|
5048
5056
|
});
|
|
5049
|
-
function
|
|
5050
|
-
return new
|
|
5057
|
+
function fc(e) {
|
|
5058
|
+
return new dc({
|
|
5051
5059
|
type: "transform",
|
|
5052
5060
|
transform: e
|
|
5053
5061
|
});
|
|
5054
5062
|
}
|
|
5055
|
-
var
|
|
5063
|
+
var pc = /*@__PURE__*/ w("ZodOptional", (e, t) => {
|
|
5056
5064
|
ki.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => ns(e, t, n, r), e.unwrap = () => e._zod.def.innerType;
|
|
5057
5065
|
});
|
|
5058
|
-
function
|
|
5059
|
-
return new
|
|
5066
|
+
function mc(e) {
|
|
5067
|
+
return new pc({
|
|
5060
5068
|
type: "optional",
|
|
5061
5069
|
innerType: e
|
|
5062
5070
|
});
|
|
5063
5071
|
}
|
|
5064
|
-
var
|
|
5072
|
+
var hc = /*@__PURE__*/ w("ZodExactOptional", (e, t) => {
|
|
5065
5073
|
Ai.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => ns(e, t, n, r), e.unwrap = () => e._zod.def.innerType;
|
|
5066
5074
|
});
|
|
5067
|
-
function
|
|
5068
|
-
return new
|
|
5075
|
+
function gc(e) {
|
|
5076
|
+
return new hc({
|
|
5069
5077
|
type: "optional",
|
|
5070
5078
|
innerType: e
|
|
5071
5079
|
});
|
|
5072
5080
|
}
|
|
5073
|
-
var
|
|
5081
|
+
var _c = /*@__PURE__*/ w("ZodNullable", (e, t) => {
|
|
5074
5082
|
ji.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => qo(e, t, n, r), e.unwrap = () => e._zod.def.innerType;
|
|
5075
5083
|
});
|
|
5076
|
-
function
|
|
5077
|
-
return new
|
|
5084
|
+
function vc(e) {
|
|
5085
|
+
return new _c({
|
|
5078
5086
|
type: "nullable",
|
|
5079
5087
|
innerType: e
|
|
5080
5088
|
});
|
|
5081
5089
|
}
|
|
5082
|
-
var
|
|
5090
|
+
var yc = /*@__PURE__*/ w("ZodDefault", (e, t) => {
|
|
5083
5091
|
Mi.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Zo(e, t, n, r), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
|
|
5084
5092
|
});
|
|
5085
|
-
function
|
|
5086
|
-
return new
|
|
5093
|
+
function bc(e, t) {
|
|
5094
|
+
return new yc({
|
|
5087
5095
|
type: "default",
|
|
5088
5096
|
innerType: e,
|
|
5089
5097
|
get defaultValue() {
|
|
@@ -5091,11 +5099,11 @@ function yc(e, t) {
|
|
|
5091
5099
|
}
|
|
5092
5100
|
});
|
|
5093
5101
|
}
|
|
5094
|
-
var
|
|
5102
|
+
var xc = /*@__PURE__*/ w("ZodPrefault", (e, t) => {
|
|
5095
5103
|
Pi.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Qo(e, t, n, r), e.unwrap = () => e._zod.def.innerType;
|
|
5096
5104
|
});
|
|
5097
|
-
function
|
|
5098
|
-
return new
|
|
5105
|
+
function Sc(e, t) {
|
|
5106
|
+
return new xc({
|
|
5099
5107
|
type: "prefault",
|
|
5100
5108
|
innerType: e,
|
|
5101
5109
|
get defaultValue() {
|
|
@@ -5103,65 +5111,65 @@ function xc(e, t) {
|
|
|
5103
5111
|
}
|
|
5104
5112
|
});
|
|
5105
5113
|
}
|
|
5106
|
-
var
|
|
5114
|
+
var Cc = /*@__PURE__*/ w("ZodNonOptional", (e, t) => {
|
|
5107
5115
|
Fi.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Jo(e, t, n, r), e.unwrap = () => e._zod.def.innerType;
|
|
5108
5116
|
});
|
|
5109
|
-
function
|
|
5110
|
-
return new
|
|
5117
|
+
function wc(e, t) {
|
|
5118
|
+
return new Cc({
|
|
5111
5119
|
type: "nonoptional",
|
|
5112
5120
|
innerType: e,
|
|
5113
5121
|
...b(t)
|
|
5114
5122
|
});
|
|
5115
5123
|
}
|
|
5116
|
-
var
|
|
5124
|
+
var Tc = /*@__PURE__*/ w("ZodCatch", (e, t) => {
|
|
5117
5125
|
Ri.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => $o(e, t, n, r), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
|
|
5118
5126
|
});
|
|
5119
|
-
function
|
|
5120
|
-
return new
|
|
5127
|
+
function Ec(e, t) {
|
|
5128
|
+
return new Tc({
|
|
5121
5129
|
type: "catch",
|
|
5122
5130
|
innerType: e,
|
|
5123
5131
|
catchValue: typeof t == "function" ? t : Lt(t)
|
|
5124
5132
|
});
|
|
5125
5133
|
}
|
|
5126
|
-
var
|
|
5134
|
+
var Dc = /*@__PURE__*/ w("ZodPipe", (e, t) => {
|
|
5127
5135
|
zi.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => es(e, t, n, r), e.in = t.in, e.out = t.out;
|
|
5128
5136
|
});
|
|
5129
|
-
function
|
|
5130
|
-
return new
|
|
5137
|
+
function Oc(e, t) {
|
|
5138
|
+
return new Dc({
|
|
5131
5139
|
type: "pipe",
|
|
5132
5140
|
in: e,
|
|
5133
5141
|
out: t
|
|
5134
5142
|
});
|
|
5135
5143
|
}
|
|
5136
|
-
var
|
|
5144
|
+
var kc = /*@__PURE__*/ w("ZodReadonly", (e, t) => {
|
|
5137
5145
|
Vi.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => ts(e, t, n, r), e.unwrap = () => e._zod.def.innerType;
|
|
5138
5146
|
});
|
|
5139
|
-
function
|
|
5140
|
-
return new
|
|
5147
|
+
function Ac(e) {
|
|
5148
|
+
return new kc({
|
|
5141
5149
|
type: "readonly",
|
|
5142
5150
|
innerType: e
|
|
5143
5151
|
});
|
|
5144
5152
|
}
|
|
5145
|
-
var
|
|
5153
|
+
var jc = /*@__PURE__*/ w("ZodLazy", (e, t) => {
|
|
5146
5154
|
Ui.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => rs(e, t, n, r), e.unwrap = () => e._zod.def.getter();
|
|
5147
5155
|
});
|
|
5148
|
-
function
|
|
5149
|
-
return new
|
|
5156
|
+
function Mc(e) {
|
|
5157
|
+
return new jc({
|
|
5150
5158
|
type: "lazy",
|
|
5151
5159
|
getter: e
|
|
5152
5160
|
});
|
|
5153
5161
|
}
|
|
5154
|
-
var
|
|
5162
|
+
var Nc = /*@__PURE__*/ w("ZodCustom", (e, t) => {
|
|
5155
5163
|
Wi.init(e, t), P.init(e, t), e._zod.processJSONSchema = (t, n, r) => Fo(e, t, n, r);
|
|
5156
5164
|
});
|
|
5157
|
-
function
|
|
5158
|
-
return /* @__PURE__ */ uo(
|
|
5165
|
+
function Pc(e, t = {}) {
|
|
5166
|
+
return /* @__PURE__ */ uo(Nc, e, t);
|
|
5159
5167
|
}
|
|
5160
|
-
function
|
|
5168
|
+
function Fc(e, t) {
|
|
5161
5169
|
return /* @__PURE__ */ fo(e, t);
|
|
5162
5170
|
}
|
|
5163
|
-
function
|
|
5164
|
-
let t =
|
|
5171
|
+
function Ic(e) {
|
|
5172
|
+
let t = Mc(() => H([
|
|
5165
5173
|
F(e),
|
|
5166
5174
|
L(),
|
|
5167
5175
|
R(),
|
|
@@ -5173,38 +5181,38 @@ function Fc(e) {
|
|
|
5173
5181
|
}
|
|
5174
5182
|
//#endregion
|
|
5175
5183
|
//#region src/flow/common/changeSchema.ts
|
|
5176
|
-
var K = F(), q =
|
|
5184
|
+
var K = F(), q = Ic(), Lc = B(K), Rc = V({
|
|
5177
5185
|
description: K.optional(),
|
|
5178
5186
|
jsonSchema: q,
|
|
5179
5187
|
nullable: R(),
|
|
5180
5188
|
handle: K
|
|
5181
|
-
}), J =
|
|
5189
|
+
}), J = Rc.extend({ value: q.optional() }), zc = V({
|
|
5182
5190
|
collapsed: R().optional(),
|
|
5183
5191
|
group: K
|
|
5184
|
-
}),
|
|
5192
|
+
}), Bc = V({
|
|
5185
5193
|
kind: G("node"),
|
|
5186
5194
|
nodeId: K,
|
|
5187
5195
|
output: K
|
|
5188
|
-
}),
|
|
5196
|
+
}), Vc = V({
|
|
5189
5197
|
kind: G("flow"),
|
|
5190
5198
|
input: K
|
|
5191
|
-
}),
|
|
5192
|
-
zc,
|
|
5199
|
+
}), Hc = H([
|
|
5193
5200
|
Bc,
|
|
5201
|
+
Vc,
|
|
5194
5202
|
V({
|
|
5195
5203
|
kind: G("binding"),
|
|
5196
5204
|
bindingId: K
|
|
5197
5205
|
})
|
|
5198
|
-
]),
|
|
5206
|
+
]), Uc = H([V({
|
|
5199
5207
|
kind: G("value"),
|
|
5200
5208
|
value: q
|
|
5201
5209
|
}), V({
|
|
5202
5210
|
kind: G("sources"),
|
|
5203
|
-
sources: B(
|
|
5204
|
-
})]),
|
|
5205
|
-
inputs: B(H([J,
|
|
5206
|
-
outputs: B(H([
|
|
5207
|
-
},
|
|
5211
|
+
sources: B(Hc)
|
|
5212
|
+
})]), Wc = U(K, Uc), Gc = {
|
|
5213
|
+
inputs: B(H([J, zc])),
|
|
5214
|
+
outputs: B(H([Rc, zc]))
|
|
5215
|
+
}, Kc = V({
|
|
5208
5216
|
kind: G("connector"),
|
|
5209
5217
|
action: K,
|
|
5210
5218
|
connectionId: K.optional(),
|
|
@@ -5212,19 +5220,19 @@ var K = F(), q = Fc(), Ic = B(K), Lc = V({
|
|
|
5212
5220
|
connectionId: K,
|
|
5213
5221
|
alias: K.optional()
|
|
5214
5222
|
}))
|
|
5215
|
-
}),
|
|
5216
|
-
...
|
|
5223
|
+
}), qc = V({
|
|
5224
|
+
...Gc,
|
|
5217
5225
|
name: K,
|
|
5218
5226
|
moduleId: K,
|
|
5219
|
-
capabilities: B(
|
|
5220
|
-
}),
|
|
5227
|
+
capabilities: B(Kc).optional()
|
|
5228
|
+
}), Jc = H([V({
|
|
5221
5229
|
kind: G("value"),
|
|
5222
5230
|
value: q
|
|
5223
5231
|
}), V({
|
|
5224
5232
|
kind: G("input"),
|
|
5225
5233
|
input: K
|
|
5226
|
-
})]),
|
|
5227
|
-
...
|
|
5234
|
+
})]), Yc = H([Jc, V({ kind: G("model") })]), Xc = V({
|
|
5235
|
+
...Gc,
|
|
5228
5236
|
name: K,
|
|
5229
5237
|
executor: H([
|
|
5230
5238
|
V({
|
|
@@ -5240,7 +5248,7 @@ var K = F(), q = Fc(), Ic = B(K), Lc = V({
|
|
|
5240
5248
|
kind: G("agent"),
|
|
5241
5249
|
code: R().optional(),
|
|
5242
5250
|
model: K,
|
|
5243
|
-
prompt:
|
|
5251
|
+
prompt: Jc,
|
|
5244
5252
|
system: K,
|
|
5245
5253
|
maxRounds: L(),
|
|
5246
5254
|
tools: B(V({
|
|
@@ -5250,16 +5258,16 @@ var K = F(), q = Fc(), Ic = B(K), Lc = V({
|
|
|
5250
5258
|
action: K,
|
|
5251
5259
|
connectionId: K.optional(),
|
|
5252
5260
|
approval: R(),
|
|
5253
|
-
inputs: B(J.extend({ source:
|
|
5261
|
+
inputs: B(J.extend({ source: Yc }))
|
|
5254
5262
|
})),
|
|
5255
5263
|
notification: V({
|
|
5256
5264
|
taskId: K,
|
|
5257
5265
|
messageHandle: K,
|
|
5258
|
-
inputs: U(K,
|
|
5266
|
+
inputs: U(K, Jc)
|
|
5259
5267
|
}).optional()
|
|
5260
5268
|
})
|
|
5261
5269
|
])
|
|
5262
|
-
}),
|
|
5270
|
+
}), Zc = {
|
|
5263
5271
|
input: J,
|
|
5264
5272
|
cases: B(V({
|
|
5265
5273
|
output: K,
|
|
@@ -5292,25 +5300,20 @@ var K = F(), q = Fc(), Ic = B(K), Lc = V({
|
|
|
5292
5300
|
}))
|
|
5293
5301
|
})),
|
|
5294
5302
|
defaultOutput: K.optional()
|
|
5295
|
-
}, Zc = {
|
|
5296
|
-
actions: H([oc([G("continue")]), oc([G("approve"), G("reject")])]),
|
|
5297
|
-
prompt: K,
|
|
5298
|
-
notification: V({
|
|
5299
|
-
inputs: Uc,
|
|
5300
|
-
messageHandle: K,
|
|
5301
|
-
taskId: K
|
|
5302
|
-
}).optional()
|
|
5303
5303
|
}, Qc = {
|
|
5304
|
+
actions: H([sc([G("continue")]), sc([G("approve"), G("reject")])]),
|
|
5305
|
+
prompt: K
|
|
5306
|
+
}, $c = {
|
|
5304
5307
|
inputsDef: B(J),
|
|
5305
5308
|
options: V({
|
|
5306
|
-
allowedMethods:
|
|
5307
|
-
allowedOrigins:
|
|
5309
|
+
allowedMethods: Lc.optional(),
|
|
5310
|
+
allowedOrigins: Lc.optional(),
|
|
5308
5311
|
noResponseBody: R().optional(),
|
|
5309
5312
|
responseData: K.optional(),
|
|
5310
5313
|
responseHeaders: U(K, K).optional(),
|
|
5311
5314
|
responseStatusCode: L().optional()
|
|
5312
5315
|
}).optional()
|
|
5313
|
-
},
|
|
5316
|
+
}, el = B(H([V({
|
|
5314
5317
|
type: G("cron"),
|
|
5315
5318
|
expression: K,
|
|
5316
5319
|
timezone: K
|
|
@@ -5324,7 +5327,7 @@ var K = F(), q = Fc(), Ic = B(K), Lc = V({
|
|
|
5324
5327
|
"week"
|
|
5325
5328
|
]),
|
|
5326
5329
|
value: L()
|
|
5327
|
-
})])),
|
|
5330
|
+
})])), tl = {
|
|
5328
5331
|
configSchema: q,
|
|
5329
5332
|
definitionVersion: L(),
|
|
5330
5333
|
description: K,
|
|
@@ -5333,7 +5336,7 @@ var K = F(), q = Fc(), Ic = B(K), Lc = V({
|
|
|
5333
5336
|
name: K,
|
|
5334
5337
|
payloadSchema: q,
|
|
5335
5338
|
provider: K
|
|
5336
|
-
},
|
|
5339
|
+
}, nl = V({
|
|
5337
5340
|
body: V({
|
|
5338
5341
|
allowArray: R(),
|
|
5339
5342
|
allowEmpty: R(),
|
|
@@ -5353,129 +5356,129 @@ var K = F(), q = Fc(), Ic = B(K), Lc = V({
|
|
|
5353
5356
|
"PUT"
|
|
5354
5357
|
])),
|
|
5355
5358
|
successStatus: L()
|
|
5356
|
-
}),
|
|
5359
|
+
}), rl = {
|
|
5357
5360
|
name: K,
|
|
5358
5361
|
description: K.optional(),
|
|
5359
5362
|
icon: K.optional()
|
|
5360
|
-
},
|
|
5361
|
-
inputs:
|
|
5363
|
+
}, il = {
|
|
5364
|
+
inputs: Wc,
|
|
5362
5365
|
name: K.optional(),
|
|
5363
5366
|
description: K.optional(),
|
|
5364
5367
|
icon: K.optional(),
|
|
5365
5368
|
timeoutMs: L().optional()
|
|
5366
|
-
},
|
|
5369
|
+
}, al = H([
|
|
5367
5370
|
V({
|
|
5368
|
-
...
|
|
5371
|
+
...il,
|
|
5369
5372
|
kind: G("condition"),
|
|
5370
|
-
...
|
|
5373
|
+
...Zc
|
|
5371
5374
|
}),
|
|
5372
5375
|
V({
|
|
5373
|
-
...
|
|
5376
|
+
...il,
|
|
5374
5377
|
inputs: z().transform(() => ({})).default({}),
|
|
5375
5378
|
kind: G("value"),
|
|
5376
5379
|
values: B(J)
|
|
5377
5380
|
}),
|
|
5378
5381
|
V({
|
|
5379
|
-
...
|
|
5382
|
+
...il,
|
|
5380
5383
|
kind: G("subflow"),
|
|
5381
5384
|
subflowId: K
|
|
5382
5385
|
}),
|
|
5383
5386
|
V({
|
|
5384
|
-
...
|
|
5387
|
+
...il,
|
|
5385
5388
|
kind: G("task"),
|
|
5386
|
-
task:
|
|
5389
|
+
task: qc,
|
|
5387
5390
|
additionalInputs: B(J).optional()
|
|
5388
5391
|
}),
|
|
5389
5392
|
V({
|
|
5390
|
-
...
|
|
5393
|
+
...il,
|
|
5391
5394
|
kind: G("task"),
|
|
5392
5395
|
taskId: K,
|
|
5393
5396
|
additionalInputs: B(J).optional()
|
|
5394
5397
|
}),
|
|
5395
|
-
|
|
5396
|
-
...
|
|
5398
|
+
nc({
|
|
5399
|
+
...il,
|
|
5397
5400
|
kind: G("wait"),
|
|
5398
5401
|
input: J,
|
|
5399
|
-
...
|
|
5402
|
+
...Qc
|
|
5400
5403
|
}).omit({ timeoutMs: !0 }),
|
|
5401
5404
|
V({
|
|
5402
|
-
...
|
|
5405
|
+
...rl,
|
|
5403
5406
|
kind: G("manual")
|
|
5404
5407
|
}),
|
|
5405
5408
|
V({
|
|
5406
|
-
...
|
|
5409
|
+
...rl,
|
|
5407
5410
|
kind: G("webhook"),
|
|
5408
|
-
|
|
5411
|
+
...$c
|
|
5409
5412
|
}),
|
|
5410
5413
|
V({
|
|
5411
|
-
...
|
|
5414
|
+
...rl,
|
|
5412
5415
|
kind: G("cron"),
|
|
5413
|
-
cronTimes:
|
|
5416
|
+
cronTimes: el
|
|
5414
5417
|
}),
|
|
5415
5418
|
V({
|
|
5416
|
-
...
|
|
5419
|
+
...rl,
|
|
5417
5420
|
kind: G("poll"),
|
|
5418
5421
|
bindingId: K,
|
|
5419
5422
|
config: U(K, q),
|
|
5420
5423
|
definition: V({
|
|
5421
|
-
...
|
|
5424
|
+
...tl,
|
|
5422
5425
|
type: G("poll")
|
|
5423
5426
|
}),
|
|
5424
|
-
pollTimes:
|
|
5427
|
+
pollTimes: el
|
|
5425
5428
|
}),
|
|
5426
5429
|
V({
|
|
5427
|
-
...
|
|
5430
|
+
...rl,
|
|
5428
5431
|
kind: G("integration"),
|
|
5429
5432
|
bindingId: K,
|
|
5430
5433
|
config: U(K, q),
|
|
5431
5434
|
definition: V({
|
|
5432
|
-
...
|
|
5435
|
+
...tl,
|
|
5433
5436
|
type: G("integration"),
|
|
5434
|
-
endpoint:
|
|
5437
|
+
endpoint: nl
|
|
5435
5438
|
})
|
|
5436
5439
|
})
|
|
5437
|
-
]),
|
|
5440
|
+
]), ol = H([V({ kind: G("flow") }), V({
|
|
5438
5441
|
kind: G("subflow"),
|
|
5439
5442
|
id: K
|
|
5440
|
-
})]),
|
|
5443
|
+
})]), sl = V({
|
|
5441
5444
|
source: K,
|
|
5442
5445
|
target: K,
|
|
5443
5446
|
sourceHandle: K.optional()
|
|
5444
5447
|
}), Y = {
|
|
5445
5448
|
nodeId: K,
|
|
5446
|
-
target:
|
|
5447
|
-
},
|
|
5449
|
+
target: ol
|
|
5450
|
+
}, cl = V({
|
|
5448
5451
|
name: K,
|
|
5449
5452
|
inputs: B(J),
|
|
5450
|
-
outputs: B(
|
|
5451
|
-
}), cl = V({
|
|
5452
|
-
nodes: U(K, il),
|
|
5453
|
-
edges: B(ol).default([])
|
|
5453
|
+
outputs: B(Rc.extend({ sources: B(H([Bc, Vc])) }))
|
|
5454
5454
|
}), ll = V({
|
|
5455
|
+
nodes: U(K, al),
|
|
5456
|
+
edges: B(sl).default([])
|
|
5457
|
+
}), ul = V({
|
|
5455
5458
|
kind: W(["connection", "variable"]),
|
|
5456
5459
|
target: K
|
|
5457
|
-
}),
|
|
5460
|
+
}), dl = V({
|
|
5458
5461
|
name: K,
|
|
5459
|
-
imports:
|
|
5462
|
+
imports: Lc,
|
|
5460
5463
|
source: K
|
|
5461
|
-
}),
|
|
5462
|
-
bindings: U(K,
|
|
5463
|
-
graph:
|
|
5464
|
-
subflows: U(K,
|
|
5465
|
-
tasks: U(K,
|
|
5464
|
+
}), fl = V({
|
|
5465
|
+
bindings: U(K, ul),
|
|
5466
|
+
graph: ll,
|
|
5467
|
+
subflows: U(K, cl.extend({ graph: ll })),
|
|
5468
|
+
tasks: U(K, Xc)
|
|
5466
5469
|
});
|
|
5467
5470
|
V({
|
|
5468
5471
|
modelVersion: G(1),
|
|
5469
|
-
document:
|
|
5470
|
-
modules: U(K,
|
|
5472
|
+
document: fl,
|
|
5473
|
+
modules: U(K, dl)
|
|
5471
5474
|
}).extend({
|
|
5472
5475
|
kind: G("open-flow-flow-revision"),
|
|
5473
5476
|
version: G(1)
|
|
5474
5477
|
});
|
|
5475
|
-
var
|
|
5478
|
+
var pl = {
|
|
5476
5479
|
"binding.create": {
|
|
5477
5480
|
bindingId: K,
|
|
5478
|
-
binding:
|
|
5481
|
+
binding: ul
|
|
5479
5482
|
},
|
|
5480
5483
|
"binding.delete": { bindingId: K },
|
|
5481
5484
|
"binding.target.set": {
|
|
@@ -5484,16 +5487,16 @@ var fl = {
|
|
|
5484
5487
|
value: K
|
|
5485
5488
|
},
|
|
5486
5489
|
"graph.edge.connect": {
|
|
5487
|
-
target:
|
|
5488
|
-
edge:
|
|
5490
|
+
target: ol,
|
|
5491
|
+
edge: sl
|
|
5489
5492
|
},
|
|
5490
5493
|
"graph.edge.disconnect": {
|
|
5491
|
-
target:
|
|
5492
|
-
edge:
|
|
5494
|
+
target: ol,
|
|
5495
|
+
edge: sl
|
|
5493
5496
|
},
|
|
5494
5497
|
"graph.node.create": {
|
|
5495
5498
|
...Y,
|
|
5496
|
-
node:
|
|
5499
|
+
node: al
|
|
5497
5500
|
},
|
|
5498
5501
|
"graph.node.delete": Y,
|
|
5499
5502
|
"graph.node.field.set": H([V({
|
|
@@ -5516,8 +5519,8 @@ var fl = {
|
|
|
5516
5519
|
"graph.node.input.set": {
|
|
5517
5520
|
...Y,
|
|
5518
5521
|
handle: K,
|
|
5519
|
-
before:
|
|
5520
|
-
value:
|
|
5522
|
+
before: Uc.optional(),
|
|
5523
|
+
value: Uc.optional()
|
|
5521
5524
|
},
|
|
5522
5525
|
"graph.node.additional-inputs.set": {
|
|
5523
5526
|
...Y,
|
|
@@ -5526,8 +5529,8 @@ var fl = {
|
|
|
5526
5529
|
},
|
|
5527
5530
|
"graph.node.condition.set": {
|
|
5528
5531
|
...Y,
|
|
5529
|
-
before: V(
|
|
5530
|
-
value: V(
|
|
5532
|
+
before: V(Zc),
|
|
5533
|
+
value: V(Zc)
|
|
5531
5534
|
},
|
|
5532
5535
|
"graph.node.values.set": {
|
|
5533
5536
|
...Y,
|
|
@@ -5537,19 +5540,19 @@ var fl = {
|
|
|
5537
5540
|
"graph.node.wait.set": {
|
|
5538
5541
|
...Y,
|
|
5539
5542
|
target: V({ kind: G("flow") }),
|
|
5540
|
-
before: V(
|
|
5541
|
-
value: V(
|
|
5543
|
+
before: V(Qc),
|
|
5544
|
+
value: V(Qc)
|
|
5542
5545
|
},
|
|
5543
5546
|
"graph.node.webhook.set": {
|
|
5544
5547
|
...Y,
|
|
5545
5548
|
target: V({ kind: G("flow") }),
|
|
5546
|
-
before: V(
|
|
5547
|
-
value: V(
|
|
5549
|
+
before: V($c),
|
|
5550
|
+
value: V($c)
|
|
5548
5551
|
},
|
|
5549
5552
|
"graph.node.task.ports.set": {
|
|
5550
5553
|
...Y,
|
|
5551
|
-
before: V(
|
|
5552
|
-
value: V(
|
|
5554
|
+
before: V(Gc),
|
|
5555
|
+
value: V(Gc)
|
|
5553
5556
|
},
|
|
5554
5557
|
"graph.node.task.name.set": {
|
|
5555
5558
|
...Y,
|
|
@@ -5558,8 +5561,8 @@ var fl = {
|
|
|
5558
5561
|
},
|
|
5559
5562
|
"graph.node.task.capabilities.set": {
|
|
5560
5563
|
...Y,
|
|
5561
|
-
before: B(
|
|
5562
|
-
value: B(
|
|
5564
|
+
before: B(Kc).optional(),
|
|
5565
|
+
value: B(Kc).optional()
|
|
5563
5566
|
},
|
|
5564
5567
|
"graph.trigger.config.set": {
|
|
5565
5568
|
nodeId: K,
|
|
@@ -5569,12 +5572,12 @@ var fl = {
|
|
|
5569
5572
|
},
|
|
5570
5573
|
"graph.trigger.schedule.set": {
|
|
5571
5574
|
nodeId: K,
|
|
5572
|
-
before:
|
|
5573
|
-
value:
|
|
5575
|
+
before: el,
|
|
5576
|
+
value: el
|
|
5574
5577
|
},
|
|
5575
5578
|
"module.create": {
|
|
5576
5579
|
moduleId: K,
|
|
5577
|
-
module:
|
|
5580
|
+
module: dl
|
|
5578
5581
|
},
|
|
5579
5582
|
"module.delete": { moduleId: K },
|
|
5580
5583
|
"module.rename": {
|
|
@@ -5584,24 +5587,24 @@ var fl = {
|
|
|
5584
5587
|
},
|
|
5585
5588
|
"module.source.replace": {
|
|
5586
5589
|
moduleId: K,
|
|
5587
|
-
beforeImports:
|
|
5590
|
+
beforeImports: Lc,
|
|
5588
5591
|
beforeSource: K,
|
|
5589
|
-
imports:
|
|
5592
|
+
imports: Lc,
|
|
5590
5593
|
source: K
|
|
5591
5594
|
},
|
|
5592
5595
|
"subflow.create": {
|
|
5593
5596
|
subflowId: K,
|
|
5594
|
-
subflow:
|
|
5597
|
+
subflow: cl.extend({ graph: ll })
|
|
5595
5598
|
},
|
|
5596
5599
|
"subflow.definition.set": {
|
|
5597
5600
|
subflowId: K,
|
|
5598
|
-
before:
|
|
5599
|
-
definition:
|
|
5601
|
+
before: cl,
|
|
5602
|
+
definition: cl
|
|
5600
5603
|
},
|
|
5601
5604
|
"subflow.delete": { subflowId: K },
|
|
5602
5605
|
"task.create": {
|
|
5603
5606
|
taskId: K,
|
|
5604
|
-
task:
|
|
5607
|
+
task: Xc
|
|
5605
5608
|
},
|
|
5606
5609
|
"task.delete": { taskId: K },
|
|
5607
5610
|
"task.connector.connection.set": {
|
|
@@ -5611,8 +5614,8 @@ var fl = {
|
|
|
5611
5614
|
},
|
|
5612
5615
|
"task.agent.set": {
|
|
5613
5616
|
taskId: K,
|
|
5614
|
-
before:
|
|
5615
|
-
value:
|
|
5617
|
+
before: Xc,
|
|
5618
|
+
value: Xc
|
|
5616
5619
|
},
|
|
5617
5620
|
"task.llm.mode.set": {
|
|
5618
5621
|
taskId: K,
|
|
@@ -5625,32 +5628,32 @@ var fl = {
|
|
|
5625
5628
|
value: K
|
|
5626
5629
|
}
|
|
5627
5630
|
};
|
|
5628
|
-
B(H([...new Map(Object.entries(
|
|
5631
|
+
B(H([...new Map(Object.entries(pl).map(([e, t]) => [e, t instanceof P ? t : V({
|
|
5629
5632
|
kind: G(e),
|
|
5630
5633
|
...t
|
|
5631
5634
|
})])).values()])).min(1);
|
|
5632
5635
|
//#endregion
|
|
5633
5636
|
//#region src/flow/common/encoding.ts
|
|
5634
|
-
var
|
|
5635
|
-
function
|
|
5637
|
+
var ml = new TextEncoder();
|
|
5638
|
+
function hl(e) {
|
|
5636
5639
|
if (e == null || typeof e == "boolean" || typeof e == "string" || typeof e == "number") return JSON.stringify(e);
|
|
5637
|
-
if (Array.isArray(e)) return `[${e.map(
|
|
5640
|
+
if (Array.isArray(e)) return `[${e.map(hl).join(",")}]`;
|
|
5638
5641
|
let t = e;
|
|
5639
|
-
return `{${Object.keys(t).toSorted().map((e) => `${JSON.stringify(e)}:${
|
|
5642
|
+
return `{${Object.keys(t).toSorted().map((e) => `${JSON.stringify(e)}:${hl(t[e])}`).join(",")}}`;
|
|
5640
5643
|
}
|
|
5641
|
-
function
|
|
5642
|
-
return
|
|
5644
|
+
function gl(e) {
|
|
5645
|
+
return ml.encode(hl(e));
|
|
5643
5646
|
}
|
|
5644
|
-
async function
|
|
5647
|
+
async function _l(e) {
|
|
5645
5648
|
let t = new Uint8Array(e.byteLength);
|
|
5646
5649
|
return t.set(e), `sha256:${[...new Uint8Array(await crypto.subtle.digest("SHA-256", t))].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
5647
5650
|
}
|
|
5648
|
-
var
|
|
5651
|
+
var vl = U(F(), z()), yl = V({
|
|
5649
5652
|
jsonSchema: z(),
|
|
5650
5653
|
nullable: R(),
|
|
5651
5654
|
value: z().optional(),
|
|
5652
5655
|
description: F().optional()
|
|
5653
|
-
}).strict(),
|
|
5656
|
+
}).strict(), bl = U(F(), yl), xl = H([V({
|
|
5654
5657
|
kind: G("value"),
|
|
5655
5658
|
value: z()
|
|
5656
5659
|
}).strict(), V({
|
|
@@ -5660,36 +5663,36 @@ var _l = U(F(), z()), vl = V({
|
|
|
5660
5663
|
nodeId: F(),
|
|
5661
5664
|
output: F()
|
|
5662
5665
|
}).strict())
|
|
5663
|
-
}).strict()]),
|
|
5666
|
+
}).strict()]), Sl = {
|
|
5664
5667
|
name: F().optional(),
|
|
5665
5668
|
description: F().optional(),
|
|
5666
5669
|
icon: F().optional()
|
|
5667
|
-
},
|
|
5670
|
+
}, Cl = H([
|
|
5668
5671
|
V({
|
|
5669
|
-
...
|
|
5672
|
+
...Sl,
|
|
5670
5673
|
kind: G("cron"),
|
|
5671
5674
|
cronTimes: B(z())
|
|
5672
5675
|
}).strict(),
|
|
5673
5676
|
V({
|
|
5674
|
-
...
|
|
5677
|
+
...Sl,
|
|
5675
5678
|
kind: G("manual")
|
|
5676
5679
|
}).strict(),
|
|
5677
5680
|
V({
|
|
5678
|
-
...
|
|
5681
|
+
...Sl,
|
|
5679
5682
|
kind: G("task"),
|
|
5680
5683
|
concurrency: G(1).optional(),
|
|
5681
|
-
inputs: U(F(),
|
|
5684
|
+
inputs: U(F(), xl),
|
|
5682
5685
|
task: V({
|
|
5683
5686
|
name: F(),
|
|
5684
5687
|
moduleId: F(),
|
|
5685
|
-
inputs:
|
|
5686
|
-
outputs: U(F(),
|
|
5688
|
+
inputs: bl,
|
|
5689
|
+
outputs: U(F(), yl.omit({ value: !0 }))
|
|
5687
5690
|
}).strict()
|
|
5688
5691
|
}).strict()
|
|
5689
5692
|
]);
|
|
5690
5693
|
V({
|
|
5691
5694
|
name: F(),
|
|
5692
|
-
graph: V({ nodes: U(F(),
|
|
5695
|
+
graph: V({ nodes: U(F(), Cl) }).strict()
|
|
5693
5696
|
}).strict(), V({
|
|
5694
5697
|
kind: G("open-flow-project-revision"),
|
|
5695
5698
|
version: G(1),
|
|
@@ -5700,15 +5703,15 @@ V({
|
|
|
5700
5703
|
imports: B(F())
|
|
5701
5704
|
}).strict()),
|
|
5702
5705
|
document: V({
|
|
5703
|
-
bindings:
|
|
5704
|
-
flows:
|
|
5705
|
-
subflows:
|
|
5706
|
-
tasks:
|
|
5706
|
+
bindings: vl,
|
|
5707
|
+
flows: vl,
|
|
5708
|
+
subflows: vl,
|
|
5709
|
+
tasks: vl
|
|
5707
5710
|
}).strict()
|
|
5708
5711
|
}).strict();
|
|
5709
5712
|
//#endregion
|
|
5710
5713
|
//#region src/trigger/providers/github/watch-pull-request.ts
|
|
5711
|
-
var
|
|
5714
|
+
var wl = {
|
|
5712
5715
|
configSchema: {
|
|
5713
5716
|
type: "object",
|
|
5714
5717
|
additionalProperties: !1,
|
|
@@ -5782,7 +5785,7 @@ var Cl = {
|
|
|
5782
5785
|
required: ["pullRequest", "version"]
|
|
5783
5786
|
}
|
|
5784
5787
|
};
|
|
5785
|
-
function
|
|
5788
|
+
function Tl(e) {
|
|
5786
5789
|
return {
|
|
5787
5790
|
owner: e.owner,
|
|
5788
5791
|
repo: e.repo,
|
|
@@ -5790,8 +5793,8 @@ function wl(e) {
|
|
|
5790
5793
|
insecureSsl: !1
|
|
5791
5794
|
};
|
|
5792
5795
|
}
|
|
5793
|
-
var
|
|
5794
|
-
snapshot:
|
|
5796
|
+
var El = {
|
|
5797
|
+
snapshot: wl,
|
|
5795
5798
|
initialState: {
|
|
5796
5799
|
checkpoint: null,
|
|
5797
5800
|
subscription: {}
|
|
@@ -5799,7 +5802,7 @@ var Tl = {
|
|
|
5799
5802
|
async reconcile(e) {
|
|
5800
5803
|
if (e.state == null) throw new t("GitHub listener state is missing.");
|
|
5801
5804
|
if (e.active && e.state.checkpoint == null) {
|
|
5802
|
-
let t = await
|
|
5805
|
+
let t = await Dl(e);
|
|
5803
5806
|
await e.state.saveCheckpoint({
|
|
5804
5807
|
version: t.version,
|
|
5805
5808
|
sequence: 0
|
|
@@ -5807,13 +5810,13 @@ var Tl = {
|
|
|
5807
5810
|
}
|
|
5808
5811
|
return await Me.reconcile({
|
|
5809
5812
|
...e,
|
|
5810
|
-
config:
|
|
5813
|
+
config: Tl(e.config)
|
|
5811
5814
|
});
|
|
5812
5815
|
},
|
|
5813
5816
|
async receive(e) {
|
|
5814
5817
|
let t = await Me.receive({
|
|
5815
5818
|
...e,
|
|
5816
|
-
config:
|
|
5819
|
+
config: Tl(e.config)
|
|
5817
5820
|
});
|
|
5818
5821
|
return t.outcome == "event" ? !s(e.payload) || e.payload.number !== e.config.number ? {
|
|
5819
5822
|
outcome: "ignored",
|
|
@@ -5825,7 +5828,7 @@ var Tl = {
|
|
|
5825
5828
|
async read(e) {
|
|
5826
5829
|
let n = e.checkpoint;
|
|
5827
5830
|
if (!s(n) || typeof n.version != "string" || !Number.isSafeInteger(n.sequence) || Number(n.sequence) < 0 || Number(n.sequence) >= 2 ** 53 - 1) throw new t("GitHub listener checkpoint is invalid.");
|
|
5828
|
-
let r = await
|
|
5831
|
+
let r = await Dl(e);
|
|
5829
5832
|
if (r.version == n.version) return {
|
|
5830
5833
|
checkpoint: n,
|
|
5831
5834
|
dedupeKey: r.version,
|
|
@@ -5845,7 +5848,7 @@ var Tl = {
|
|
|
5845
5848
|
}
|
|
5846
5849
|
}
|
|
5847
5850
|
};
|
|
5848
|
-
async function
|
|
5851
|
+
async function Dl(r) {
|
|
5849
5852
|
let { owner: i, repo: a, number: o } = r.config;
|
|
5850
5853
|
if (typeof i != "string" || typeof a != "string" || !Number.isSafeInteger(o) || Number(o) < 1) throw new t("GitHub pull request configuration is invalid.");
|
|
5851
5854
|
let c = await r.connector.execute({
|
|
@@ -5873,12 +5876,12 @@ async function El(r) {
|
|
|
5873
5876
|
};
|
|
5874
5877
|
return {
|
|
5875
5878
|
pullRequest: u,
|
|
5876
|
-
version: await gl(
|
|
5879
|
+
version: await _l(gl(u))
|
|
5877
5880
|
};
|
|
5878
5881
|
}
|
|
5879
5882
|
//#endregion
|
|
5880
5883
|
//#region src/trigger/providers/gitlab/on-project-event.ts
|
|
5881
|
-
var
|
|
5884
|
+
var Ol = [
|
|
5882
5885
|
"push",
|
|
5883
5886
|
"tag_push",
|
|
5884
5887
|
"issues",
|
|
@@ -5896,7 +5899,7 @@ var Dl = [
|
|
|
5896
5899
|
"emoji",
|
|
5897
5900
|
"resource_access_token",
|
|
5898
5901
|
"resource_deploy_token"
|
|
5899
|
-
],
|
|
5902
|
+
], kl = /* @__PURE__ */ new Map([
|
|
5900
5903
|
["Push Hook", "push"],
|
|
5901
5904
|
["Tag Push Hook", "tag_push"],
|
|
5902
5905
|
["Issue Hook", "issues"],
|
|
@@ -5914,7 +5917,7 @@ var Dl = [
|
|
|
5914
5917
|
["Emoji Hook", "emoji"],
|
|
5915
5918
|
["Resource Access Token Hook", "resource_access_token"],
|
|
5916
5919
|
["Resource Deploy Token Hook", "resource_deploy_token"]
|
|
5917
|
-
]),
|
|
5920
|
+
]), Al = {
|
|
5918
5921
|
initialState: {
|
|
5919
5922
|
checkpoint: null,
|
|
5920
5923
|
subscription: {}
|
|
@@ -5925,7 +5928,7 @@ var Dl = [
|
|
|
5925
5928
|
properties: {
|
|
5926
5929
|
events: {
|
|
5927
5930
|
items: {
|
|
5928
|
-
enum:
|
|
5931
|
+
enum: Ol,
|
|
5929
5932
|
type: "string"
|
|
5930
5933
|
},
|
|
5931
5934
|
minItems: 1,
|
|
@@ -5998,12 +6001,12 @@ var Dl = [
|
|
|
5998
6001
|
outcome: "ignored",
|
|
5999
6002
|
reason: "GitLab event header is missing."
|
|
6000
6003
|
};
|
|
6001
|
-
let n =
|
|
6004
|
+
let n = kl.get(t);
|
|
6002
6005
|
if (n == null) return {
|
|
6003
6006
|
outcome: "ignored",
|
|
6004
6007
|
reason: "GitLab event header is unknown."
|
|
6005
6008
|
};
|
|
6006
|
-
if (!
|
|
6009
|
+
if (!jl(e.config).events.includes(n)) return {
|
|
6007
6010
|
outcome: "ignored",
|
|
6008
6011
|
reason: "GitLab event is not subscribed."
|
|
6009
6012
|
};
|
|
@@ -6020,36 +6023,36 @@ var Dl = [
|
|
|
6020
6023
|
};
|
|
6021
6024
|
},
|
|
6022
6025
|
async reconcile(e) {
|
|
6023
|
-
let n =
|
|
6026
|
+
let n = zl(e.state), r = jl(e.config), i = Bl(n);
|
|
6024
6027
|
if (!e.active) {
|
|
6025
|
-
let t = i == null ? await
|
|
6026
|
-
for (let n of t ?? []) await
|
|
6027
|
-
return await n.saveSubscription({},
|
|
6028
|
+
let t = i == null ? await Pl(e, r) : [i];
|
|
6029
|
+
for (let n of t ?? []) await Fl(e, r, n);
|
|
6030
|
+
return await n.saveSubscription({}, Vl(e.now)), { outcome: "ready" };
|
|
6028
6031
|
}
|
|
6029
|
-
let a = await
|
|
6032
|
+
let a = await Pl(e, r);
|
|
6030
6033
|
if (a == null) throw new t("The GitLab project does not exist or is not visible.");
|
|
6031
6034
|
let o = i ?? a[0];
|
|
6032
6035
|
if (o == null) {
|
|
6033
|
-
let t = await
|
|
6034
|
-
body:
|
|
6035
|
-
endpoint:
|
|
6036
|
+
let t = await Il(e, "hook create", {
|
|
6037
|
+
body: Nl(e.endpointUrl, e.callbackSecret, r),
|
|
6038
|
+
endpoint: Ml(r),
|
|
6036
6039
|
method: "POST"
|
|
6037
6040
|
});
|
|
6038
|
-
|
|
6041
|
+
Ll(t, "hook create"), o = Rl(t.data);
|
|
6039
6042
|
} else {
|
|
6040
|
-
let t = await
|
|
6041
|
-
body:
|
|
6042
|
-
endpoint: `${
|
|
6043
|
+
let t = await Il(e, "hook update", {
|
|
6044
|
+
body: Nl(e.endpointUrl, e.callbackSecret, r),
|
|
6045
|
+
endpoint: `${Ml(r)}/${o}`,
|
|
6043
6046
|
method: "PUT"
|
|
6044
6047
|
});
|
|
6045
6048
|
if (t.status == 404) return await n.saveSubscription({}, e.now), { outcome: "pending" };
|
|
6046
|
-
|
|
6049
|
+
Ll(t, "hook update");
|
|
6047
6050
|
}
|
|
6048
|
-
for (let t of a.filter((e) => e != o)) await
|
|
6049
|
-
return await n.saveSubscription({ hookId: o },
|
|
6051
|
+
for (let t of a.filter((e) => e != o)) await Fl(e, r, t);
|
|
6052
|
+
return await n.saveSubscription({ hookId: o }, Vl(e.now)), { outcome: "ready" };
|
|
6050
6053
|
}
|
|
6051
6054
|
};
|
|
6052
|
-
function
|
|
6055
|
+
function jl(e) {
|
|
6053
6056
|
return {
|
|
6054
6057
|
events: e.events,
|
|
6055
6058
|
insecureSsl: e.insecureSsl ?? !1,
|
|
@@ -6057,10 +6060,10 @@ function Al(e) {
|
|
|
6057
6060
|
pushBranchFilter: e.pushBranchFilter ?? ""
|
|
6058
6061
|
};
|
|
6059
6062
|
}
|
|
6060
|
-
function
|
|
6063
|
+
function Ml(e) {
|
|
6061
6064
|
return `/projects/${encodeURIComponent(e.project)}/hooks`;
|
|
6062
6065
|
}
|
|
6063
|
-
function
|
|
6066
|
+
function Nl(e, t, n) {
|
|
6064
6067
|
return {
|
|
6065
6068
|
branch_filter_strategy: "wildcard",
|
|
6066
6069
|
description: "Managed by Open Flow.",
|
|
@@ -6069,14 +6072,14 @@ function Ml(e, t, n) {
|
|
|
6069
6072
|
push_events_branch_filter: n.pushBranchFilter,
|
|
6070
6073
|
url: e,
|
|
6071
6074
|
token: t,
|
|
6072
|
-
...Object.fromEntries(
|
|
6075
|
+
...Object.fromEntries(Ol.map((e) => [`${e}_events`, n.events.includes(e)]))
|
|
6073
6076
|
};
|
|
6074
6077
|
}
|
|
6075
|
-
async function
|
|
6078
|
+
async function Pl(e, t) {
|
|
6076
6079
|
let n = [];
|
|
6077
6080
|
for (let r = 1; r <= 10; r += 1) {
|
|
6078
|
-
let i = await
|
|
6079
|
-
endpoint:
|
|
6081
|
+
let i = await Il(e, "hook list", {
|
|
6082
|
+
endpoint: Ml(t),
|
|
6080
6083
|
method: "GET",
|
|
6081
6084
|
query: {
|
|
6082
6085
|
page: r,
|
|
@@ -6084,59 +6087,59 @@ async function Nl(e, t) {
|
|
|
6084
6087
|
}
|
|
6085
6088
|
});
|
|
6086
6089
|
if (i.status == 404) return null;
|
|
6087
|
-
|
|
6090
|
+
Ll(i, "hook list");
|
|
6088
6091
|
let a = Array.isArray(i.data) ? i.data : [];
|
|
6089
6092
|
for (let t of a) {
|
|
6090
|
-
let r =
|
|
6093
|
+
let r = Hl(t);
|
|
6091
6094
|
r?.url === e.endpointUrl && (typeof r.id == "number" || typeof r.id == "string") && n.push(String(r.id));
|
|
6092
6095
|
}
|
|
6093
6096
|
if (a.length < 100) break;
|
|
6094
6097
|
}
|
|
6095
6098
|
return n;
|
|
6096
6099
|
}
|
|
6097
|
-
async function
|
|
6098
|
-
let r = await
|
|
6099
|
-
endpoint: `${
|
|
6100
|
+
async function Fl(e, t, n) {
|
|
6101
|
+
let r = await Il(e, "hook delete", {
|
|
6102
|
+
endpoint: `${Ml(t)}/${n}`,
|
|
6100
6103
|
method: "DELETE"
|
|
6101
6104
|
});
|
|
6102
|
-
r.status != 404 &&
|
|
6105
|
+
r.status != 404 && Ll(r, "hook delete");
|
|
6103
6106
|
}
|
|
6104
|
-
async function
|
|
6107
|
+
async function Il(t, r, i) {
|
|
6105
6108
|
try {
|
|
6106
6109
|
return await t.connector.execute(i, t.signal);
|
|
6107
6110
|
} catch (t) {
|
|
6108
6111
|
throw t instanceof e ? t : new n(`GitLab ${r} request failed.`, { cause: t });
|
|
6109
6112
|
}
|
|
6110
6113
|
}
|
|
6111
|
-
function
|
|
6114
|
+
function Ll(r, i) {
|
|
6112
6115
|
if (!(r.status >= 200 && r.status < 300)) throw r.status == 401 || r.status == 403 ? new e(`GitLab ${i} rejected the Connection.`) : [
|
|
6113
6116
|
400,
|
|
6114
6117
|
404,
|
|
6115
6118
|
422
|
|
6116
6119
|
].includes(r.status) ? new t(`GitLab ${i} rejected the subscription.`) : new n(`GitLab ${i} failed with status ${r.status}.`);
|
|
6117
6120
|
}
|
|
6118
|
-
function
|
|
6119
|
-
let t =
|
|
6121
|
+
function Rl(e) {
|
|
6122
|
+
let t = Hl(e)?.id;
|
|
6120
6123
|
if (typeof t != "number" && typeof t != "string") throw new n("GitLab hook response is missing its ID.");
|
|
6121
6124
|
return String(t);
|
|
6122
6125
|
}
|
|
6123
|
-
function
|
|
6126
|
+
function zl(e) {
|
|
6124
6127
|
if (e == null) throw new t("GitLab Integration state is missing.");
|
|
6125
6128
|
return e;
|
|
6126
6129
|
}
|
|
6127
|
-
function
|
|
6130
|
+
function Bl(e) {
|
|
6128
6131
|
let t = e.subscription.hookId;
|
|
6129
6132
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
6130
6133
|
}
|
|
6131
|
-
function
|
|
6134
|
+
function Vl(e) {
|
|
6132
6135
|
return new Date(e.getTime() + 2592e6);
|
|
6133
6136
|
}
|
|
6134
|
-
function
|
|
6137
|
+
function Hl(e) {
|
|
6135
6138
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
6136
6139
|
}
|
|
6137
6140
|
//#endregion
|
|
6138
6141
|
//#region src/trigger/providers/gmail/on-message-received.ts
|
|
6139
|
-
var
|
|
6142
|
+
var Ul = 25, Wl = 5, Gl = {
|
|
6140
6143
|
snapshot: {
|
|
6141
6144
|
configSchema: {
|
|
6142
6145
|
additionalProperties: !1,
|
|
@@ -6161,7 +6164,7 @@ var Hl = 25, Ul = 5, Wl = {
|
|
|
6161
6164
|
type: "array"
|
|
6162
6165
|
},
|
|
6163
6166
|
maxMessagesPerPoll: {
|
|
6164
|
-
default:
|
|
6167
|
+
default: Ul,
|
|
6165
6168
|
maximum: 100,
|
|
6166
6169
|
minimum: 1,
|
|
6167
6170
|
type: "integer"
|
|
@@ -6232,20 +6235,20 @@ var Hl = 25, Ul = 5, Wl = {
|
|
|
6232
6235
|
type: "poll"
|
|
6233
6236
|
},
|
|
6234
6237
|
async poll(e) {
|
|
6235
|
-
let t =
|
|
6238
|
+
let t = Kl(e.config);
|
|
6236
6239
|
if (e.checkpoint === null) return {
|
|
6237
|
-
checkpoint: { historyId: await
|
|
6240
|
+
checkpoint: { historyId: await ql(e) },
|
|
6238
6241
|
events: []
|
|
6239
6242
|
};
|
|
6240
|
-
let n =
|
|
6243
|
+
let n = Jl(e.checkpoint), r = await Yl(e, t.labelNamesOrIds), { candidates: i, lastPage: a } = await Xl(e, n, r, t.maxMessagesPerPoll), o = Zl(n.historyId, a), s = [], c = 0;
|
|
6241
6244
|
for (let n of i) {
|
|
6242
|
-
let i = await
|
|
6245
|
+
let i = await Ql(e, n.id);
|
|
6243
6246
|
if (i != null) {
|
|
6244
|
-
if (!await
|
|
6247
|
+
if (!await $l(e, i, t, r)) {
|
|
6245
6248
|
c += 1;
|
|
6246
6249
|
continue;
|
|
6247
6250
|
}
|
|
6248
|
-
s.push(
|
|
6251
|
+
s.push(nu(i));
|
|
6249
6252
|
}
|
|
6250
6253
|
}
|
|
6251
6254
|
return {
|
|
@@ -6256,25 +6259,25 @@ var Hl = 25, Ul = 5, Wl = {
|
|
|
6256
6259
|
};
|
|
6257
6260
|
}
|
|
6258
6261
|
};
|
|
6259
|
-
function
|
|
6262
|
+
function Kl(e) {
|
|
6260
6263
|
return {
|
|
6261
6264
|
includeDrafts: e.includeDrafts ?? !1,
|
|
6262
6265
|
includeSpamAndTrash: e.includeSpamAndTrash ?? !1,
|
|
6263
6266
|
labelNamesOrIds: e.labelNamesOrIds ?? [],
|
|
6264
|
-
maxMessagesPerPoll: e.maxMessagesPerPoll ??
|
|
6267
|
+
maxMessagesPerPoll: e.maxMessagesPerPoll ?? Ul,
|
|
6265
6268
|
readStatus: e.readStatus ?? "All",
|
|
6266
6269
|
search: (e.search ?? "").trim(),
|
|
6267
6270
|
sender: (e.sender ?? "").trim()
|
|
6268
6271
|
};
|
|
6269
6272
|
}
|
|
6270
|
-
async function
|
|
6271
|
-
let t = await
|
|
6272
|
-
|
|
6273
|
+
async function ql(e) {
|
|
6274
|
+
let t = await ru(e, "/users/me/profile");
|
|
6275
|
+
iu(t, "profile fetch");
|
|
6273
6276
|
let n = X(t.data)?.historyId;
|
|
6274
6277
|
if (typeof n != "string" || n.length == 0) throw new a("Gmail profile historyId is missing.");
|
|
6275
6278
|
return n;
|
|
6276
6279
|
}
|
|
6277
|
-
function
|
|
6280
|
+
function Jl(e) {
|
|
6278
6281
|
let t = X(e);
|
|
6279
6282
|
if (typeof t?.historyId != "string" || t.historyId.length == 0) throw new r("Gmail checkpoint historyId is missing; recreate the Trigger.");
|
|
6280
6283
|
return {
|
|
@@ -6282,10 +6285,10 @@ function ql(e) {
|
|
|
6282
6285
|
...typeof t.pageToken == "string" ? { pageToken: t.pageToken } : {}
|
|
6283
6286
|
};
|
|
6284
6287
|
}
|
|
6285
|
-
async function
|
|
6288
|
+
async function Yl(e, t) {
|
|
6286
6289
|
if (t.length == 0) return [];
|
|
6287
|
-
let n = await
|
|
6288
|
-
|
|
6290
|
+
let n = await ru(e, "/users/me/labels");
|
|
6291
|
+
iu(n, "labels list");
|
|
6289
6292
|
let i = X(n.data)?.labels, a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
|
|
6290
6293
|
if (Array.isArray(i)) for (let e of i) {
|
|
6291
6294
|
let t = X(e);
|
|
@@ -6297,10 +6300,10 @@ async function Jl(e, t) {
|
|
|
6297
6300
|
return t;
|
|
6298
6301
|
}))];
|
|
6299
6302
|
}
|
|
6300
|
-
async function
|
|
6303
|
+
async function Xl(e, t, n, i) {
|
|
6301
6304
|
let a = /* @__PURE__ */ new Map(), o = t.pageToken, s = {};
|
|
6302
|
-
for (let c = 0; c <
|
|
6303
|
-
let c = await
|
|
6305
|
+
for (let c = 0; c < Wl; c += 1) {
|
|
6306
|
+
let c = await ru(e, "/users/me/history", {
|
|
6304
6307
|
historyTypes: "messageAdded",
|
|
6305
6308
|
labelId: n[0],
|
|
6306
6309
|
maxResults: i,
|
|
@@ -6308,7 +6311,7 @@ async function Yl(e, t, n, i) {
|
|
|
6308
6311
|
startHistoryId: t.historyId
|
|
6309
6312
|
});
|
|
6310
6313
|
if (c.status == 404) throw new r("Gmail history checkpoint expired; recreate the Trigger.");
|
|
6311
|
-
|
|
6314
|
+
iu(c, "history list"), s = X(c.data) ?? {};
|
|
6312
6315
|
for (let e of s.history ?? []) for (let t of e.messagesAdded ?? []) {
|
|
6313
6316
|
let e = t.message?.id;
|
|
6314
6317
|
e != null && e.length > 0 && !a.has(e) && a.set(e, { id: e });
|
|
@@ -6320,7 +6323,7 @@ async function Yl(e, t, n, i) {
|
|
|
6320
6323
|
lastPage: s
|
|
6321
6324
|
};
|
|
6322
6325
|
}
|
|
6323
|
-
function
|
|
6326
|
+
function Zl(e, t) {
|
|
6324
6327
|
if (t.nextPageToken) return {
|
|
6325
6328
|
checkpoint: {
|
|
6326
6329
|
historyId: e,
|
|
@@ -6334,32 +6337,32 @@ function Xl(e, t) {
|
|
|
6334
6337
|
hasMore: !1
|
|
6335
6338
|
};
|
|
6336
6339
|
}
|
|
6337
|
-
async function
|
|
6338
|
-
let n = await
|
|
6339
|
-
return n.status == 404 ? null : (
|
|
6340
|
+
async function Ql(e, t) {
|
|
6341
|
+
let n = await ru(e, `/users/me/messages/${encodeURIComponent(t)}`, { format: "metadata" });
|
|
6342
|
+
return n.status == 404 ? null : (iu(n, "message metadata fetch"), X(n.data) ?? null);
|
|
6340
6343
|
}
|
|
6341
|
-
async function
|
|
6344
|
+
async function $l(e, t, n, r) {
|
|
6342
6345
|
let i = t.labelIds ?? [];
|
|
6343
6346
|
if (!n.includeSpamAndTrash && (i.includes("SPAM") || i.includes("TRASH")) || !n.includeDrafts && i.includes("DRAFT") || n.readStatus == "Unread" && !i.includes("UNREAD") || n.readStatus == "Read" && i.includes("UNREAD") || !r.every((e) => i.includes(e))) return !1;
|
|
6344
|
-
let a =
|
|
6345
|
-
return a.length == 0 || await
|
|
6347
|
+
let a = eu(n);
|
|
6348
|
+
return a.length == 0 || await tu(e, t, a, n.includeSpamAndTrash);
|
|
6346
6349
|
}
|
|
6347
|
-
function
|
|
6350
|
+
function eu(e) {
|
|
6348
6351
|
let t = e.search.length == 0 ? [] : [e.search], n = e.sender.replaceAll("\"", "").trim();
|
|
6349
6352
|
return n.length > 0 && t.push(`from:${/\s/.test(n) ? `"${n}"` : n}`), t.join(" ");
|
|
6350
6353
|
}
|
|
6351
|
-
async function
|
|
6352
|
-
let i =
|
|
6354
|
+
async function tu(e, t, n, r) {
|
|
6355
|
+
let i = au(t.payload?.headers ?? [], "Message-ID").replace(/^</, "").replace(/>$/, "");
|
|
6353
6356
|
if (i.length == 0) return !1;
|
|
6354
|
-
let a = await
|
|
6357
|
+
let a = await ru(e, "/users/me/messages", {
|
|
6355
6358
|
includeSpamTrash: r ? "true" : void 0,
|
|
6356
6359
|
q: `${n} rfc822msgid:${i}`
|
|
6357
6360
|
});
|
|
6358
|
-
|
|
6361
|
+
iu(a, "query match");
|
|
6359
6362
|
let o = X(a.data)?.messages;
|
|
6360
6363
|
return Array.isArray(o) && o.some((e) => X(e)?.id === t.id);
|
|
6361
6364
|
}
|
|
6362
|
-
function
|
|
6365
|
+
function nu(e) {
|
|
6363
6366
|
let t = e.payload?.headers ?? [];
|
|
6364
6367
|
return {
|
|
6365
6368
|
dedupeKey: e.id,
|
|
@@ -6367,15 +6370,15 @@ function tu(e) {
|
|
|
6367
6370
|
historyId: e.historyId ?? null,
|
|
6368
6371
|
labelIds: e.labelIds ?? [],
|
|
6369
6372
|
messageId: e.id,
|
|
6370
|
-
messageTimestamp:
|
|
6371
|
-
sender:
|
|
6372
|
-
subject:
|
|
6373
|
+
messageTimestamp: ou(e.internalDate, au(t, "Date")),
|
|
6374
|
+
sender: au(t, "From"),
|
|
6375
|
+
subject: au(t, "Subject"),
|
|
6373
6376
|
threadId: e.threadId ?? "",
|
|
6374
|
-
to:
|
|
6377
|
+
to: au(t, "To")
|
|
6375
6378
|
}
|
|
6376
6379
|
};
|
|
6377
6380
|
}
|
|
6378
|
-
async function
|
|
6381
|
+
async function ru(e, t, n = {}) {
|
|
6379
6382
|
try {
|
|
6380
6383
|
return await e.connector.execute({
|
|
6381
6384
|
endpoint: t,
|
|
@@ -6386,13 +6389,13 @@ async function nu(e, t, n = {}) {
|
|
|
6386
6389
|
throw new a(`Gmail proxy request to ${t} failed.`, { cause: e });
|
|
6387
6390
|
}
|
|
6388
6391
|
}
|
|
6389
|
-
function
|
|
6392
|
+
function iu(e, t) {
|
|
6390
6393
|
if (!(e.status >= 200 && e.status < 300)) throw e.status == 401 || e.status == 403 ? new i(`Gmail ${t} rejected the Connection.`) : new a(`Gmail ${t} failed with status ${e.status}.`);
|
|
6391
6394
|
}
|
|
6392
|
-
function
|
|
6395
|
+
function au(e, t) {
|
|
6393
6396
|
return e.find((e) => e.name.toLowerCase() == t.toLowerCase())?.value ?? "";
|
|
6394
6397
|
}
|
|
6395
|
-
function
|
|
6398
|
+
function ou(e, t) {
|
|
6396
6399
|
let n = e == null ? NaN : Number(e);
|
|
6397
6400
|
if (Number.isFinite(n)) {
|
|
6398
6401
|
let e = new Date(n);
|
|
@@ -6406,16 +6409,16 @@ function X(e) {
|
|
|
6406
6409
|
}
|
|
6407
6410
|
//#endregion
|
|
6408
6411
|
//#region src/trigger/providers/google-calendar/on-event-changed.ts
|
|
6409
|
-
var
|
|
6412
|
+
var su = [
|
|
6410
6413
|
"created",
|
|
6411
6414
|
"updated",
|
|
6412
6415
|
"cancelled"
|
|
6413
|
-
],
|
|
6416
|
+
], cu = /* @__PURE__ */ new Set([
|
|
6414
6417
|
"rateLimitExceeded",
|
|
6415
6418
|
"userRateLimitExceeded",
|
|
6416
6419
|
"quotaExceeded",
|
|
6417
6420
|
"usageLimits"
|
|
6418
|
-
]),
|
|
6421
|
+
]), lu = {
|
|
6419
6422
|
snapshot: {
|
|
6420
6423
|
configSchema: {
|
|
6421
6424
|
additionalProperties: !1,
|
|
@@ -6426,9 +6429,9 @@ var ou = [
|
|
|
6426
6429
|
type: "string"
|
|
6427
6430
|
},
|
|
6428
6431
|
changes: {
|
|
6429
|
-
default:
|
|
6432
|
+
default: su,
|
|
6430
6433
|
items: {
|
|
6431
|
-
enum:
|
|
6434
|
+
enum: su,
|
|
6432
6435
|
type: "string"
|
|
6433
6436
|
},
|
|
6434
6437
|
minItems: 1,
|
|
@@ -6467,7 +6470,7 @@ var ou = [
|
|
|
6467
6470
|
},
|
|
6468
6471
|
calendarId: { type: "string" },
|
|
6469
6472
|
changeType: {
|
|
6470
|
-
enum:
|
|
6473
|
+
enum: su,
|
|
6471
6474
|
type: "string"
|
|
6472
6475
|
},
|
|
6473
6476
|
created: { type: ["string", "null"] },
|
|
@@ -6518,21 +6521,21 @@ var ou = [
|
|
|
6518
6521
|
type: "poll"
|
|
6519
6522
|
},
|
|
6520
6523
|
async poll(e) {
|
|
6521
|
-
let t =
|
|
6522
|
-
if (e.checkpoint === null) return
|
|
6523
|
-
let n =
|
|
6524
|
-
return n.calendarId === t.calendarId ? "seedTimeMin" in n ?
|
|
6524
|
+
let t = uu(e.config);
|
|
6525
|
+
if (e.checkpoint === null) return fu(e, t, e.now.toISOString());
|
|
6526
|
+
let n = du(e.checkpoint);
|
|
6527
|
+
return n.calendarId === t.calendarId ? "seedTimeMin" in n ? fu(e, t, n.seedTimeMin, n.pageToken) : pu(e, t, n) : fu(e, t, e.now.toISOString());
|
|
6525
6528
|
}
|
|
6526
6529
|
};
|
|
6527
|
-
function
|
|
6530
|
+
function uu(e) {
|
|
6528
6531
|
return {
|
|
6529
6532
|
calendarId: e.calendarId,
|
|
6530
|
-
changes: new Set(e.changes ??
|
|
6533
|
+
changes: new Set(e.changes ?? su),
|
|
6531
6534
|
matchTerm: (e.matchTerm ?? "").trim(),
|
|
6532
6535
|
maxEventsPerPoll: e.maxEventsPerPoll ?? 100
|
|
6533
6536
|
};
|
|
6534
6537
|
}
|
|
6535
|
-
function
|
|
6538
|
+
function du(e) {
|
|
6536
6539
|
let t = Z(e), n = typeof t?.pageToken == "string" ? t.pageToken : void 0, i = typeof t?.calendarId == "string" ? t.calendarId : void 0;
|
|
6537
6540
|
if (typeof t?.syncToken == "string" && t.syncToken.length > 0) return {
|
|
6538
6541
|
calendarId: i,
|
|
@@ -6546,24 +6549,24 @@ function uu(e) {
|
|
|
6546
6549
|
};
|
|
6547
6550
|
throw new r("Google Calendar checkpoint is invalid; recreate the Trigger.");
|
|
6548
6551
|
}
|
|
6549
|
-
async function
|
|
6552
|
+
async function fu(e, t, n, r) {
|
|
6550
6553
|
let i = r;
|
|
6551
6554
|
for (let r = 0; r < 2; r += 1) {
|
|
6552
|
-
let r = await
|
|
6555
|
+
let r = await _u(e, t.calendarId, {
|
|
6553
6556
|
maxResults: 2500,
|
|
6554
6557
|
pageToken: i,
|
|
6555
6558
|
showDeleted: "true",
|
|
6556
6559
|
singleEvents: "false",
|
|
6557
6560
|
timeMin: n
|
|
6558
6561
|
});
|
|
6559
|
-
if (i != null &&
|
|
6562
|
+
if (i != null && yu(r)) return {
|
|
6560
6563
|
checkpoint: {
|
|
6561
6564
|
calendarId: t.calendarId,
|
|
6562
6565
|
seedTimeMin: n
|
|
6563
6566
|
},
|
|
6564
6567
|
events: []
|
|
6565
6568
|
};
|
|
6566
|
-
|
|
6569
|
+
vu(e, r, "seed full sync");
|
|
6567
6570
|
let o = Z(r.data) ?? {};
|
|
6568
6571
|
if (o.nextSyncToken) return {
|
|
6569
6572
|
checkpoint: {
|
|
@@ -6585,17 +6588,17 @@ async function du(e, t, n, r) {
|
|
|
6585
6588
|
hasMore: !0
|
|
6586
6589
|
};
|
|
6587
6590
|
}
|
|
6588
|
-
async function
|
|
6591
|
+
async function pu(e, t, n) {
|
|
6589
6592
|
let r = [], i = 0, o = n.pageToken;
|
|
6590
6593
|
for (let s = 0; s < 5; s += 1) {
|
|
6591
|
-
let s = await
|
|
6594
|
+
let s = await _u(e, t.calendarId, {
|
|
6592
6595
|
maxResults: t.maxEventsPerPoll,
|
|
6593
6596
|
pageToken: o,
|
|
6594
6597
|
showDeleted: "true",
|
|
6595
6598
|
singleEvents: "false",
|
|
6596
6599
|
syncToken: n.syncToken
|
|
6597
6600
|
});
|
|
6598
|
-
if (o != null &&
|
|
6601
|
+
if (o != null && yu(s)) return {
|
|
6599
6602
|
checkpoint: {
|
|
6600
6603
|
calendarId: t.calendarId,
|
|
6601
6604
|
syncToken: n.syncToken
|
|
@@ -6603,16 +6606,16 @@ async function fu(e, t, n) {
|
|
|
6603
6606
|
events: r,
|
|
6604
6607
|
filtered: i
|
|
6605
6608
|
};
|
|
6606
|
-
|
|
6609
|
+
vu(e, s, "incremental sync");
|
|
6607
6610
|
let c = Z(s.data) ?? {};
|
|
6608
6611
|
for (let e of c.items ?? []) {
|
|
6609
6612
|
if (e.id == null || e.id.length == 0) continue;
|
|
6610
|
-
let n =
|
|
6611
|
-
if (!t.changes.has(n) || !
|
|
6613
|
+
let n = mu(e);
|
|
6614
|
+
if (!t.changes.has(n) || !hu(e, t.matchTerm)) {
|
|
6612
6615
|
i += 1;
|
|
6613
6616
|
continue;
|
|
6614
6617
|
}
|
|
6615
|
-
r.push(
|
|
6618
|
+
r.push(gu(e, e.id, n, t.calendarId));
|
|
6616
6619
|
}
|
|
6617
6620
|
if (c.nextSyncToken) return {
|
|
6618
6621
|
checkpoint: {
|
|
@@ -6636,12 +6639,12 @@ async function fu(e, t, n) {
|
|
|
6636
6639
|
hasMore: !0
|
|
6637
6640
|
};
|
|
6638
6641
|
}
|
|
6639
|
-
function
|
|
6642
|
+
function mu(e) {
|
|
6640
6643
|
if (e.status == "cancelled") return "cancelled";
|
|
6641
|
-
let t =
|
|
6644
|
+
let t = Cu(e.created), n = Cu(e.updated);
|
|
6642
6645
|
return t != null && t == n ? "created" : "updated";
|
|
6643
6646
|
}
|
|
6644
|
-
function
|
|
6647
|
+
function hu(e, t) {
|
|
6645
6648
|
if (t.length == 0) return !0;
|
|
6646
6649
|
let n = t.toLowerCase();
|
|
6647
6650
|
return [
|
|
@@ -6651,14 +6654,14 @@ function mu(e, t) {
|
|
|
6651
6654
|
...(e.attendees ?? []).map(({ email: e }) => e)
|
|
6652
6655
|
].some((e) => typeof e == "string" && e.toLowerCase().includes(n));
|
|
6653
6656
|
}
|
|
6654
|
-
function
|
|
6657
|
+
function gu(e, t, n, r) {
|
|
6655
6658
|
return {
|
|
6656
6659
|
dedupeKey: `${t}:${e.updated ?? e.etag ?? ""}`,
|
|
6657
6660
|
payload: {
|
|
6658
6661
|
attendeeEmails: (e.attendees ?? []).flatMap(({ email: e }) => e == null || e.length == 0 ? [] : [e]),
|
|
6659
6662
|
calendarId: r,
|
|
6660
6663
|
changeType: n,
|
|
6661
|
-
created:
|
|
6664
|
+
created: Su(e.created),
|
|
6662
6665
|
creatorEmail: e.creator?.email ?? null,
|
|
6663
6666
|
description: e.description ?? null,
|
|
6664
6667
|
end: e.end ?? null,
|
|
@@ -6672,11 +6675,11 @@ function hu(e, t, n, r) {
|
|
|
6672
6675
|
start: e.start ?? null,
|
|
6673
6676
|
status: e.status ?? "",
|
|
6674
6677
|
summary: e.summary ?? null,
|
|
6675
|
-
updated:
|
|
6678
|
+
updated: Su(e.updated)
|
|
6676
6679
|
}
|
|
6677
6680
|
};
|
|
6678
6681
|
}
|
|
6679
|
-
async function
|
|
6682
|
+
async function _u(e, t, n) {
|
|
6680
6683
|
let r = `/calendars/${encodeURIComponent(t)}/events`;
|
|
6681
6684
|
try {
|
|
6682
6685
|
return await e.connector.execute({
|
|
@@ -6688,30 +6691,30 @@ async function gu(e, t, n) {
|
|
|
6688
6691
|
throw new a(`Google Calendar proxy request to ${r} failed.`, { cause: e });
|
|
6689
6692
|
}
|
|
6690
6693
|
}
|
|
6691
|
-
function
|
|
6692
|
-
if (!(t.status >= 200 && t.status < 300)) throw t.status == 410 || t.status == 400 &&
|
|
6693
|
-
}
|
|
6694
|
-
function vu(e) {
|
|
6695
|
-
return e.status == 400 && !bu(e.data);
|
|
6694
|
+
function vu(e, t, n) {
|
|
6695
|
+
if (!(t.status >= 200 && t.status < 300)) throw t.status == 410 || t.status == 400 && xu(t.data) ? new r("Google Calendar sync token expired; recreate the Trigger.") : t.status == 400 || t.status == 404 && e.checkpoint === null ? new r(`Google Calendar ${n} rejected the configuration.`) : t.status == 401 ? new i(`Google Calendar ${n} rejected the Connection.`) : t.status == 403 ? bu(t.data).some((e) => cu.has(e)) ? new a(`Google Calendar ${n} was rate limited.`) : new i(`Google Calendar ${n} rejected the Connection.`) : new a(`Google Calendar ${n} failed with status ${t.status}.`);
|
|
6696
6696
|
}
|
|
6697
6697
|
function yu(e) {
|
|
6698
|
+
return e.status == 400 && !xu(e.data);
|
|
6699
|
+
}
|
|
6700
|
+
function bu(e) {
|
|
6698
6701
|
let t = Z(Z(e)?.error)?.errors;
|
|
6699
6702
|
return Array.isArray(t) ? t.flatMap((e) => {
|
|
6700
6703
|
let t = Z(e)?.reason;
|
|
6701
6704
|
return typeof t == "string" ? [t] : [];
|
|
6702
6705
|
}) : [];
|
|
6703
6706
|
}
|
|
6704
|
-
function
|
|
6705
|
-
if (
|
|
6707
|
+
function xu(e) {
|
|
6708
|
+
if (bu(e).includes("fullSyncRequired")) return !0;
|
|
6706
6709
|
let t = Z(Z(e)?.error)?.message;
|
|
6707
6710
|
return typeof t == "string" && t.includes("fullSyncRequired");
|
|
6708
6711
|
}
|
|
6709
|
-
function
|
|
6712
|
+
function Su(e) {
|
|
6710
6713
|
if (e == null || e.length == 0) return null;
|
|
6711
6714
|
let t = Date.parse(e);
|
|
6712
6715
|
return Number.isNaN(t) ? null : new Date(t).toISOString();
|
|
6713
6716
|
}
|
|
6714
|
-
function
|
|
6717
|
+
function Cu(e) {
|
|
6715
6718
|
if (e == null || e.length == 0) return null;
|
|
6716
6719
|
let t = Date.parse(e);
|
|
6717
6720
|
return Number.isNaN(t) ? null : Math.floor(t / 1e3);
|
|
@@ -6721,7 +6724,7 @@ function Z(e) {
|
|
|
6721
6724
|
}
|
|
6722
6725
|
//#endregion
|
|
6723
6726
|
//#region src/trigger/providers/google-drive/changes.ts
|
|
6724
|
-
var
|
|
6727
|
+
var wu = 6012e5, Tu = 36e5, Eu = 6e4, Du = 6e4, Ou = 2, ku = 100, Au = new TextEncoder(), ju = "nextPageToken,newStartPageToken,changes(fileId,kind,changeType,removed,time,driveId,file(id,name,mimeType,webViewLink,createdTime,modifiedTime,size,driveId,parents,shared,starred,trashed))", Mu = {
|
|
6725
6728
|
configSchema: {
|
|
6726
6729
|
additionalProperties: !1,
|
|
6727
6730
|
description: "Configuration for googledrive.changes_detected.",
|
|
@@ -6748,7 +6751,7 @@ var Cu = 6012e5, wu = 36e5, Tu = 6e4, Eu = 6e4, Du = 2, Ou = 100, ku = new TextE
|
|
|
6748
6751
|
type: "boolean"
|
|
6749
6752
|
},
|
|
6750
6753
|
pageSize: {
|
|
6751
|
-
default:
|
|
6754
|
+
default: ku,
|
|
6752
6755
|
description: "Maximum changes included in one Flow Run.",
|
|
6753
6756
|
maximum: 100,
|
|
6754
6757
|
minimum: 1,
|
|
@@ -6830,16 +6833,16 @@ var Cu = 6012e5, wu = 36e5, Tu = 6e4, Eu = 6e4, Du = 2, Ou = 100, ku = new TextE
|
|
|
6830
6833
|
},
|
|
6831
6834
|
provider: "googledrive",
|
|
6832
6835
|
type: "integration"
|
|
6833
|
-
},
|
|
6836
|
+
}, Nu = {
|
|
6834
6837
|
initialState: {
|
|
6835
6838
|
checkpoint: null,
|
|
6836
6839
|
subscription: { channels: [] }
|
|
6837
6840
|
},
|
|
6838
|
-
snapshot:
|
|
6841
|
+
snapshot: Mu,
|
|
6839
6842
|
async receive(e) {
|
|
6840
|
-
let t = await
|
|
6843
|
+
let t = await ed(e);
|
|
6841
6844
|
if (t.outcome != "wake") return t;
|
|
6842
|
-
let n =
|
|
6845
|
+
let n = Pu(e.state), r = e.header("x-goog-resource-state");
|
|
6843
6846
|
if (!e.admit) return e.current ? {
|
|
6844
6847
|
body: "",
|
|
6845
6848
|
contentType: "text/plain",
|
|
@@ -6853,12 +6856,12 @@ var Cu = 6012e5, wu = 36e5, Tu = 6e4, Eu = 6e4, Du = 2, Ou = 100, ku = new TextE
|
|
|
6853
6856
|
outcome: "ignored",
|
|
6854
6857
|
reason: "The Team cannot admit Trigger events."
|
|
6855
6858
|
};
|
|
6856
|
-
let i = await
|
|
6859
|
+
let i = await Hu(e, n.checkpoint), a = {
|
|
6857
6860
|
changedTypes: (e.header("x-goog-changed") ?? "").split(",").map((e) => e.trim()).filter((e) => e.length > 0),
|
|
6858
6861
|
messageNumber: e.header("x-goog-message-number") ?? null,
|
|
6859
6862
|
resourceState: r,
|
|
6860
6863
|
resourceUri: e.header("x-goog-resource-uri") ?? null
|
|
6861
|
-
}, o = i.changes.map((e) =>
|
|
6864
|
+
}, o = i.changes.map((e) => Ju(e, a)), s = {
|
|
6862
6865
|
checkpoint: i.checkpoint,
|
|
6863
6866
|
continue: i.hasMore,
|
|
6864
6867
|
dedupeKey: i.dedupeKey
|
|
@@ -6874,14 +6877,14 @@ var Cu = 6012e5, wu = 36e5, Tu = 6e4, Eu = 6e4, Du = 2, Ou = 100, ku = new TextE
|
|
|
6874
6877
|
};
|
|
6875
6878
|
},
|
|
6876
6879
|
async reconcile(e) {
|
|
6877
|
-
let t =
|
|
6878
|
-
if (i.length != n.length && (n = i, await Q(t, n, e.now)), !e.active) return await
|
|
6880
|
+
let t = Pu(e.state), n = Lu(t), r = e.now.getTime(), i = n.filter((e) => Date.parse(e.expiration) > r);
|
|
6881
|
+
if (i.length != n.length && (n = i, await Q(t, n, e.now)), !e.active) return await zu(e, n);
|
|
6879
6882
|
let a = n.filter((e) => e.state == "creating" && e.resourceId != null).toSorted((e, t) => Date.parse(t.createdAt) - Date.parse(e.createdAt))[0];
|
|
6880
6883
|
a != null && (n = n.map((e) => ({
|
|
6881
6884
|
...e,
|
|
6882
6885
|
state: e.id == a.id ? "active" : "retiring"
|
|
6883
6886
|
})), await Q(t, n, e.now));
|
|
6884
|
-
let o = n.find((e) => e.state == "active"), s = n.filter((e) => e.state == "creating").filter((e) => Date.parse(e.createdAt) +
|
|
6887
|
+
let o = n.find((e) => e.state == "active"), s = n.filter((e) => e.state == "creating").filter((e) => Date.parse(e.createdAt) + Eu <= r);
|
|
6885
6888
|
if (s.length > 0) {
|
|
6886
6889
|
let r = new Set(s.map((e) => e.id));
|
|
6887
6890
|
n = n.map((e) => r.has(e.id) ? {
|
|
@@ -6891,35 +6894,35 @@ var Cu = 6012e5, wu = 36e5, Tu = 6e4, Eu = 6e4, Du = 2, Ou = 100, ku = new TextE
|
|
|
6891
6894
|
}
|
|
6892
6895
|
if (o = n.find((e) => e.state == "active"), o != null) {
|
|
6893
6896
|
try {
|
|
6894
|
-
n = await
|
|
6897
|
+
n = await Bu(e, n);
|
|
6895
6898
|
} catch {
|
|
6896
6899
|
return { outcome: "ready" };
|
|
6897
6900
|
}
|
|
6898
|
-
if (o = n.find((e) => e.state == "active"), o != null && Date.parse(o.expiration) -
|
|
6901
|
+
if (o = n.find((e) => e.state == "active"), o != null && Date.parse(o.expiration) - Tu > r) return await Q(t, n, Yu(n, e.now)), { outcome: "ready" };
|
|
6899
6902
|
}
|
|
6900
|
-
return n.some((e) => e.state == "creating") || n.filter((e) => e.resourceId == null).length >=
|
|
6903
|
+
return n.some((e) => e.state == "creating") || n.filter((e) => e.resourceId == null).length >= Ou ? (await Q(t, n, Yu(n, e.now)), { outcome: o == null ? "pending" : "ready" }) : await Ru(e, n);
|
|
6901
6904
|
}
|
|
6902
6905
|
};
|
|
6903
|
-
function
|
|
6906
|
+
function Pu(e) {
|
|
6904
6907
|
if (e == null) throw new t("Google Drive Integration state is missing.");
|
|
6905
6908
|
return e;
|
|
6906
6909
|
}
|
|
6907
|
-
function
|
|
6910
|
+
function Fu(e) {
|
|
6908
6911
|
return {
|
|
6909
6912
|
...typeof e.driveId == "string" ? { driveId: e.driveId } : {},
|
|
6910
6913
|
includeCorpusRemovals: e.includeCorpusRemovals ?? !1,
|
|
6911
6914
|
includeItemsFromAllDrives: e.includeItemsFromAllDrives ?? !0,
|
|
6912
6915
|
includeRemoved: e.includeRemoved ?? !0,
|
|
6913
|
-
pageSize: e.pageSize ??
|
|
6916
|
+
pageSize: e.pageSize ?? ku,
|
|
6914
6917
|
restrictToMyDrive: e.restrictToMyDrive ?? !1
|
|
6915
6918
|
};
|
|
6916
6919
|
}
|
|
6917
|
-
function
|
|
6918
|
-
let n =
|
|
6920
|
+
function Iu(e) {
|
|
6921
|
+
let n = $u(e) ? $(e.pageToken) : void 0;
|
|
6919
6922
|
if (n == null) throw new t("Google Drive checkpoint pageToken is missing.");
|
|
6920
6923
|
return n;
|
|
6921
6924
|
}
|
|
6922
|
-
function
|
|
6925
|
+
function Lu(e) {
|
|
6923
6926
|
let n = e.subscription.channels;
|
|
6924
6927
|
if (!Array.isArray(n)) throw new t("Google Drive channel state is invalid.");
|
|
6925
6928
|
let r = n.map((e) => {
|
|
@@ -6942,24 +6945,24 @@ function Iu(e) {
|
|
|
6942
6945
|
if (new Set(r.map((e) => e.id)).size != r.length) throw new t("Google Drive channel IDs are duplicated.");
|
|
6943
6946
|
return r;
|
|
6944
6947
|
}
|
|
6945
|
-
async function
|
|
6946
|
-
let a =
|
|
6947
|
-
a.checkpoint === null ? (s = await
|
|
6948
|
+
async function Ru(r, i) {
|
|
6949
|
+
let a = Pu(r.state), o = Fu(r.config), s;
|
|
6950
|
+
a.checkpoint === null ? (s = await Vu(r), await a.saveCheckpoint({ pageToken: s })) : s = Iu(a.checkpoint);
|
|
6948
6951
|
let c = {
|
|
6949
6952
|
createdAt: r.now.toISOString(),
|
|
6950
|
-
expiration: new Date(r.now.getTime() +
|
|
6953
|
+
expiration: new Date(r.now.getTime() + wu).toISOString(),
|
|
6951
6954
|
id: crypto.randomUUID(),
|
|
6952
6955
|
state: "creating"
|
|
6953
6956
|
};
|
|
6954
|
-
i = [...i, c], await Q(a, i, new Date(r.now.getTime() +
|
|
6957
|
+
i = [...i, c], await Q(a, i, new Date(r.now.getTime() + Eu));
|
|
6955
6958
|
let l;
|
|
6956
6959
|
try {
|
|
6957
|
-
l = await
|
|
6960
|
+
l = await Wu(r, {
|
|
6958
6961
|
body: {
|
|
6959
6962
|
address: r.endpointUrl,
|
|
6960
6963
|
expiration: String(Date.parse(c.expiration)),
|
|
6961
6964
|
id: c.id,
|
|
6962
|
-
token: await
|
|
6965
|
+
token: await Xu(r.callbackSecret, c.id),
|
|
6963
6966
|
type: "web_hook"
|
|
6964
6967
|
},
|
|
6965
6968
|
endpoint: "/changes/watch",
|
|
@@ -6977,7 +6980,7 @@ async function Lu(r, i) {
|
|
|
6977
6980
|
}
|
|
6978
6981
|
let u = $(l.resourceId);
|
|
6979
6982
|
if (u == null) throw new n("Google Drive changes.watch response is missing resourceId.");
|
|
6980
|
-
let d =
|
|
6983
|
+
let d = Qu(l.expiration) ?? c.expiration;
|
|
6981
6984
|
i = i.map((e) => e.id == c.id ? {
|
|
6982
6985
|
...e,
|
|
6983
6986
|
expiration: d,
|
|
@@ -6986,52 +6989,52 @@ async function Lu(r, i) {
|
|
|
6986
6989
|
} : e.state == "active" ? {
|
|
6987
6990
|
...e,
|
|
6988
6991
|
state: "retiring"
|
|
6989
|
-
} : e), await Q(a, i,
|
|
6992
|
+
} : e), await Q(a, i, Yu(i, r.now));
|
|
6990
6993
|
try {
|
|
6991
|
-
i = await
|
|
6994
|
+
i = await Bu(r, i);
|
|
6992
6995
|
} catch {
|
|
6993
6996
|
return { outcome: "ready" };
|
|
6994
6997
|
}
|
|
6995
|
-
return await Q(a, i,
|
|
6998
|
+
return await Q(a, i, Yu(i, r.now)), { outcome: "ready" };
|
|
6996
6999
|
}
|
|
6997
|
-
async function
|
|
6998
|
-
let n =
|
|
7000
|
+
async function zu(e, t) {
|
|
7001
|
+
let n = Pu(e.state);
|
|
6999
7002
|
return t.some((e) => e.state == "active" || e.state == "creating") && (t = t.map((e) => ({
|
|
7000
7003
|
...e,
|
|
7001
7004
|
state: "retiring"
|
|
7002
|
-
})), await Q(n, t, e.now)), t = await
|
|
7005
|
+
})), await Q(n, t, e.now)), t = await Bu(e, t), t.length == 0 ? { outcome: "ready" } : (await Q(n, t, Yu(t, e.now)), { outcome: "pending" });
|
|
7003
7006
|
}
|
|
7004
|
-
async function
|
|
7005
|
-
let n =
|
|
7007
|
+
async function Bu(e, t) {
|
|
7008
|
+
let n = Pu(e.state);
|
|
7006
7009
|
for (let r of t) {
|
|
7007
7010
|
if (r.state != "retiring" && r.state != "stopping" || r.resourceId == null) continue;
|
|
7008
7011
|
let i = t.map((e) => e.id == r.id ? {
|
|
7009
7012
|
...e,
|
|
7010
7013
|
state: "stopping"
|
|
7011
7014
|
} : e);
|
|
7012
|
-
await Q(n, i, new Date(e.now.getTime() +
|
|
7015
|
+
await Q(n, i, new Date(e.now.getTime() + Du)), await Uu(e, r), t = i.filter((e) => e.id != r.id), await Q(n, t, e.now);
|
|
7013
7016
|
}
|
|
7014
7017
|
return t;
|
|
7015
7018
|
}
|
|
7016
|
-
async function
|
|
7017
|
-
let t =
|
|
7019
|
+
async function Vu(e) {
|
|
7020
|
+
let t = Fu(e.config), r = await Wu(e, {
|
|
7018
7021
|
endpoint: "/changes/startPageToken",
|
|
7019
7022
|
method: "GET",
|
|
7020
7023
|
query: {
|
|
7021
7024
|
...t.driveId == null ? {} : { driveId: t.driveId },
|
|
7022
7025
|
supportsAllDrives: !0
|
|
7023
7026
|
}
|
|
7024
|
-
}, "changes.getStartPageToken"), i =
|
|
7027
|
+
}, "changes.getStartPageToken"), i = $u(r) ? $(r.startPageToken) : void 0;
|
|
7025
7028
|
if (i == null) throw new n("Google Drive startPageToken response is invalid.");
|
|
7026
7029
|
return i;
|
|
7027
7030
|
}
|
|
7028
|
-
async function
|
|
7029
|
-
let r =
|
|
7031
|
+
async function Hu(e, t) {
|
|
7032
|
+
let r = Fu(e.config), i = Iu(t), a = await Wu(e, {
|
|
7030
7033
|
endpoint: "/changes",
|
|
7031
7034
|
method: "GET",
|
|
7032
7035
|
query: {
|
|
7033
7036
|
...r.driveId == null ? {} : { driveId: r.driveId },
|
|
7034
|
-
fields:
|
|
7037
|
+
fields: ju,
|
|
7035
7038
|
includeCorpusRemovals: r.includeCorpusRemovals,
|
|
7036
7039
|
includeItemsFromAllDrives: r.driveId != null || r.includeItemsFromAllDrives,
|
|
7037
7040
|
includeRemoved: r.includeCorpusRemovals || r.includeRemoved,
|
|
@@ -7044,7 +7047,7 @@ async function Vu(e, t) {
|
|
|
7044
7047
|
for (let e of ["nextPageToken", "newStartPageToken"]) if (a[e] !== void 0 && $(a[e]) == null) throw new n(`Google Drive changes response contains an invalid ${e}.`);
|
|
7045
7048
|
let o = $(a.nextPageToken), s = o ?? $(a.newStartPageToken);
|
|
7046
7049
|
if (s == null) throw new n("Google Drive changes response is missing its next checkpoint.");
|
|
7047
|
-
if (a.changes != null && (!Array.isArray(a.changes) || !a.changes.every(
|
|
7050
|
+
if (a.changes != null && (!Array.isArray(a.changes) || !a.changes.every($u))) throw new n("Google Drive changes response contains invalid changes.");
|
|
7048
7051
|
if (o === i) throw new n("Google Drive changes continuation did not advance.");
|
|
7049
7052
|
return {
|
|
7050
7053
|
changes: a.changes ?? [],
|
|
@@ -7053,8 +7056,8 @@ async function Vu(e, t) {
|
|
|
7053
7056
|
hasMore: o != null
|
|
7054
7057
|
};
|
|
7055
7058
|
}
|
|
7056
|
-
async function
|
|
7057
|
-
let n = await
|
|
7059
|
+
async function Uu(e, t) {
|
|
7060
|
+
let n = await Gu(e, {
|
|
7058
7061
|
body: {
|
|
7059
7062
|
id: t.id,
|
|
7060
7063
|
resourceId: t.resourceId
|
|
@@ -7062,30 +7065,30 @@ async function Hu(e, t) {
|
|
|
7062
7065
|
endpoint: "/channels/stop",
|
|
7063
7066
|
method: "POST"
|
|
7064
7067
|
});
|
|
7065
|
-
n.status >= 200 && n.status < 300 || n.status == 404 ||
|
|
7068
|
+
n.status >= 200 && n.status < 300 || n.status == 404 || Ku(n, "channels.stop");
|
|
7066
7069
|
}
|
|
7067
|
-
async function
|
|
7068
|
-
let r = await
|
|
7069
|
-
if (r.status >= 200 && r.status < 300 &&
|
|
7070
|
-
|
|
7070
|
+
async function Wu(e, t, n) {
|
|
7071
|
+
let r = await Gu(e, t);
|
|
7072
|
+
if (r.status >= 200 && r.status < 300 && $u(r.data)) return r.data;
|
|
7073
|
+
Ku(r, n);
|
|
7071
7074
|
}
|
|
7072
|
-
async function
|
|
7075
|
+
async function Gu(t, r) {
|
|
7073
7076
|
try {
|
|
7074
7077
|
return await t.connector.execute(r, t.signal);
|
|
7075
7078
|
} catch (t) {
|
|
7076
7079
|
throw t instanceof e ? t : new n("Google Drive proxy request failed.", { cause: t });
|
|
7077
7080
|
}
|
|
7078
7081
|
}
|
|
7079
|
-
function
|
|
7080
|
-
let a =
|
|
7082
|
+
function Ku(r, i) {
|
|
7083
|
+
let a = qu(r.data);
|
|
7081
7084
|
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}.`}`);
|
|
7082
7085
|
}
|
|
7083
|
-
function
|
|
7084
|
-
if (
|
|
7086
|
+
function qu(e) {
|
|
7087
|
+
if (!$u(e) || !$u(e.error)) return "";
|
|
7085
7088
|
let t = e.error.errors;
|
|
7086
|
-
return Array.isArray(t) &&
|
|
7089
|
+
return Array.isArray(t) && $u(t[0]) && typeof t[0].reason == "string" ? t[0].reason : typeof e.error.status == "string" ? e.error.status : "";
|
|
7087
7090
|
}
|
|
7088
|
-
function
|
|
7091
|
+
function Ju(e, t) {
|
|
7089
7092
|
let n = $(e.driveId), r = $(e.fileId), i = $(e.time), a = $(e.changeType), o = e.removed === !0;
|
|
7090
7093
|
return {
|
|
7091
7094
|
changeId: [
|
|
@@ -7097,7 +7100,7 @@ function qu(e, t) {
|
|
|
7097
7100
|
].join(":"),
|
|
7098
7101
|
changeType: a ?? null,
|
|
7099
7102
|
driveId: n ?? null,
|
|
7100
|
-
file:
|
|
7103
|
+
file: $u(e.file) ? e.file : null,
|
|
7101
7104
|
fileId: r ?? null,
|
|
7102
7105
|
notification: t,
|
|
7103
7106
|
removed: o,
|
|
@@ -7107,43 +7110,43 @@ function qu(e, t) {
|
|
|
7107
7110
|
async function Q(e, t, n) {
|
|
7108
7111
|
await e.saveSubscription({ channels: t }, n);
|
|
7109
7112
|
}
|
|
7110
|
-
function
|
|
7111
|
-
let n = e.map((e) => e.state == "active" ? Date.parse(e.expiration) -
|
|
7113
|
+
function Yu(e, t) {
|
|
7114
|
+
let n = e.map((e) => e.state == "active" ? Date.parse(e.expiration) - Tu : e.state == "creating" ? Date.parse(e.createdAt) + Eu : e.resourceId == null ? Date.parse(e.expiration) : t.getTime() + Du), r = n.length == 0 ? t.getTime() + Du : Math.min(...n);
|
|
7112
7115
|
return new Date(Math.max(t.getTime(), r));
|
|
7113
7116
|
}
|
|
7114
|
-
async function
|
|
7115
|
-
let n = await crypto.subtle.importKey("raw",
|
|
7117
|
+
async function Xu(e, t) {
|
|
7118
|
+
let n = await crypto.subtle.importKey("raw", Au.encode(e), {
|
|
7116
7119
|
hash: "SHA-256",
|
|
7117
7120
|
name: "HMAC"
|
|
7118
|
-
}, !1, ["sign"]), r = new Uint8Array(await crypto.subtle.sign("HMAC", n,
|
|
7121
|
+
}, !1, ["sign"]), r = new Uint8Array(await crypto.subtle.sign("HMAC", n, Au.encode(`google-drive-channel/v1/${t}`)));
|
|
7119
7122
|
return btoa(String.fromCharCode(...r)).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
7120
7123
|
}
|
|
7121
|
-
function
|
|
7124
|
+
function Zu(e, t) {
|
|
7122
7125
|
if (e.length != t.length) return !1;
|
|
7123
7126
|
let n = 0;
|
|
7124
7127
|
for (let r = 0; r < t.length; r += 1) n |= e.charCodeAt(r) ^ t.charCodeAt(r);
|
|
7125
7128
|
return n == 0;
|
|
7126
7129
|
}
|
|
7127
|
-
function
|
|
7130
|
+
function Qu(e) {
|
|
7128
7131
|
let t = typeof e == "string" || typeof e == "number" ? Number(e) : NaN;
|
|
7129
7132
|
return Number.isFinite(t) && t > 0 ? new Date(t).toISOString() : void 0;
|
|
7130
7133
|
}
|
|
7131
7134
|
function $(e) {
|
|
7132
7135
|
return typeof e == "string" && e.length > 0 ? e : void 0;
|
|
7133
7136
|
}
|
|
7134
|
-
function
|
|
7137
|
+
function $u(e) {
|
|
7135
7138
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
7136
7139
|
}
|
|
7137
|
-
async function
|
|
7138
|
-
let t =
|
|
7140
|
+
async function ed(e) {
|
|
7141
|
+
let t = Pu(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");
|
|
7139
7142
|
if (n == null || r == null || i == null || a == null) return {
|
|
7140
7143
|
body: "",
|
|
7141
7144
|
contentType: "text/plain",
|
|
7142
7145
|
outcome: "respond",
|
|
7143
7146
|
status: 404
|
|
7144
7147
|
};
|
|
7145
|
-
let o =
|
|
7146
|
-
return s == null || !
|
|
7148
|
+
let o = Lu(t), s = o.find((t) => t.id == n && Date.parse(t.expiration) > e.now.getTime());
|
|
7149
|
+
return s == null || !Zu(a, await Xu(e.callbackSecret, n)) || s.resourceId != null && s.resourceId != r ? {
|
|
7147
7150
|
body: "",
|
|
7148
7151
|
contentType: "text/plain",
|
|
7149
7152
|
outcome: "respond",
|
|
@@ -7156,14 +7159,14 @@ async function $u(e) {
|
|
|
7156
7159
|
reason: "Google Drive notification state is not actionable."
|
|
7157
7160
|
} : { outcome: "wake" });
|
|
7158
7161
|
}
|
|
7159
|
-
var
|
|
7160
|
-
initialState:
|
|
7161
|
-
reconcile:
|
|
7162
|
-
receive:
|
|
7162
|
+
var td = {
|
|
7163
|
+
initialState: Nu.initialState,
|
|
7164
|
+
reconcile: Nu.reconcile,
|
|
7165
|
+
receive: ed,
|
|
7163
7166
|
listener: {
|
|
7164
7167
|
intervalMs: 3e5,
|
|
7165
7168
|
async read(e) {
|
|
7166
|
-
let t = await
|
|
7169
|
+
let t = await Hu(e, e.checkpoint);
|
|
7167
7170
|
return {
|
|
7168
7171
|
checkpoint: t.checkpoint,
|
|
7169
7172
|
dedupeKey: t.dedupeKey,
|
|
@@ -7173,9 +7176,9 @@ var ed = {
|
|
|
7173
7176
|
}
|
|
7174
7177
|
},
|
|
7175
7178
|
snapshot: {
|
|
7176
|
-
...
|
|
7179
|
+
...Mu,
|
|
7177
7180
|
configSchema: {
|
|
7178
|
-
...
|
|
7181
|
+
...Mu.configSchema,
|
|
7179
7182
|
description: "Configuration for googledrive.watch_changes."
|
|
7180
7183
|
},
|
|
7181
7184
|
key: "googledrive.watch_changes",
|
|
@@ -7192,12 +7195,12 @@ var ed = {
|
|
|
7192
7195
|
required: ["events"]
|
|
7193
7196
|
}
|
|
7194
7197
|
}
|
|
7195
|
-
},
|
|
7198
|
+
}, nd = "application/vnd.google-apps.folder", rd = "nextPageToken,incompleteSearch,files(id,name,mimeType,createdTime,modifiedTime,parents,trashed,webViewLink,driveId,size,version,lastModifyingUser(displayName,emailAddress))", id = /* @__PURE__ */ new Set([
|
|
7196
7199
|
"rateLimitExceeded",
|
|
7197
7200
|
"userRateLimitExceeded",
|
|
7198
7201
|
"dailyLimitExceeded",
|
|
7199
7202
|
"sharingRateLimitExceeded"
|
|
7200
|
-
]),
|
|
7203
|
+
]), ad = /* @__PURE__ */ new Set(["insufficientFilePermissions", "appNotAuthorizedToFile"]), od = {
|
|
7201
7204
|
snapshot: {
|
|
7202
7205
|
configSchema: {
|
|
7203
7206
|
additionalProperties: !1,
|
|
@@ -7311,16 +7314,16 @@ var ed = {
|
|
|
7311
7314
|
type: "poll"
|
|
7312
7315
|
},
|
|
7313
7316
|
async poll(e) {
|
|
7314
|
-
let t =
|
|
7315
|
-
if (e.checkpoint === null) return
|
|
7316
|
-
let n =
|
|
7317
|
-
return n.changeType === t.changeType ?
|
|
7318
|
-
checkpoint:
|
|
7317
|
+
let t = sd(e.config);
|
|
7318
|
+
if (e.checkpoint === null) return ld(e, t);
|
|
7319
|
+
let n = cd(e.checkpoint);
|
|
7320
|
+
return n.changeType === t.changeType ? dd(e, t, n) : {
|
|
7321
|
+
checkpoint: ud(e.now, t.changeType),
|
|
7319
7322
|
events: []
|
|
7320
7323
|
};
|
|
7321
7324
|
}
|
|
7322
7325
|
};
|
|
7323
|
-
function
|
|
7326
|
+
function sd(e) {
|
|
7324
7327
|
return {
|
|
7325
7328
|
changeType: e.changeType,
|
|
7326
7329
|
driveId: e.driveId ?? "",
|
|
@@ -7331,8 +7334,8 @@ function od(e) {
|
|
|
7331
7334
|
namePrefix: e.namePrefix ?? ""
|
|
7332
7335
|
};
|
|
7333
7336
|
}
|
|
7334
|
-
function
|
|
7335
|
-
let t =
|
|
7337
|
+
function cd(e) {
|
|
7338
|
+
let t = Td(e);
|
|
7336
7339
|
if (typeof t?.since != "string" || Number.isNaN(Date.parse(t.since))) throw new r("Google Drive checkpoint is invalid; recreate the Trigger.");
|
|
7337
7340
|
let n = t.boundaryKeys;
|
|
7338
7341
|
return {
|
|
@@ -7345,23 +7348,23 @@ function sd(e) {
|
|
|
7345
7348
|
...Array.isArray(n) ? { boundaryKeys: n.filter((e) => typeof e == "string") } : {}
|
|
7346
7349
|
};
|
|
7347
7350
|
}
|
|
7348
|
-
async function
|
|
7349
|
-
let n = await
|
|
7351
|
+
async function ld(e, t) {
|
|
7352
|
+
let n = await yd(e, `/drive/v3/files/${encodeURIComponent(t.folderId)}`, {
|
|
7350
7353
|
fields: "id,name,mimeType,driveId,trashed",
|
|
7351
7354
|
supportsAllDrives: "true"
|
|
7352
7355
|
});
|
|
7353
|
-
|
|
7354
|
-
let i =
|
|
7356
|
+
bd(n, "folder probe");
|
|
7357
|
+
let i = Td(n.data);
|
|
7355
7358
|
if (i == null) throw new a("Google Drive folder probe returned no payload.");
|
|
7356
|
-
if (i.mimeType !==
|
|
7359
|
+
if (i.mimeType !== nd) throw new r("Google Drive folderId does not point to a folder.");
|
|
7357
7360
|
if (i.trashed === !0) throw new r("The Google Drive folder is in the trash.");
|
|
7358
7361
|
if (t.driveId.length > 0 && (i.driveId ?? "") !== t.driveId) throw new r("The configured Google Drive shared drive does not contain this folder.");
|
|
7359
7362
|
return {
|
|
7360
|
-
checkpoint:
|
|
7363
|
+
checkpoint: ud(e.now, t.changeType),
|
|
7361
7364
|
events: []
|
|
7362
7365
|
};
|
|
7363
7366
|
}
|
|
7364
|
-
function
|
|
7367
|
+
function ud(e, t) {
|
|
7365
7368
|
let n = e.toISOString();
|
|
7366
7369
|
return {
|
|
7367
7370
|
changeType: t,
|
|
@@ -7369,11 +7372,11 @@ function ld(e, t) {
|
|
|
7369
7372
|
since: n
|
|
7370
7373
|
};
|
|
7371
7374
|
}
|
|
7372
|
-
async function
|
|
7373
|
-
let r =
|
|
7375
|
+
async function dd(e, t, n) {
|
|
7376
|
+
let r = md(t, n.since, n.floor), i = `${t.driveId}|${r}`, a = n.pageQuery == i ? n.pageToken : void 0, o = await yd(e, "/drive/v3/files", {
|
|
7374
7377
|
corpora: t.driveId.length == 0 ? "allDrives" : "drive",
|
|
7375
7378
|
driveId: t.driveId.length == 0 ? void 0 : t.driveId,
|
|
7376
|
-
fields:
|
|
7379
|
+
fields: rd,
|
|
7377
7380
|
includeItemsFromAllDrives: "true",
|
|
7378
7381
|
pageSize: t.maxFilesPerPoll,
|
|
7379
7382
|
pageToken: a,
|
|
@@ -7381,74 +7384,74 @@ async function ud(e, t, n) {
|
|
|
7381
7384
|
spaces: "drive",
|
|
7382
7385
|
supportsAllDrives: "true"
|
|
7383
7386
|
});
|
|
7384
|
-
|
|
7385
|
-
let s =
|
|
7387
|
+
bd(o, "files list");
|
|
7388
|
+
let s = Td(o.data) ?? {}, c = new Set(n.boundaryKeys ?? []), l = [], u = [], d = a == null ? void 0 : n.maxSeen;
|
|
7386
7389
|
for (let e of s.files ?? []) {
|
|
7387
7390
|
if (e.id == null || e.id.length == 0) continue;
|
|
7388
|
-
let n =
|
|
7391
|
+
let n = _d(e, t.changeType);
|
|
7389
7392
|
if (n == null) continue;
|
|
7390
|
-
let r =
|
|
7391
|
-
u.push(r.dedupeKey),
|
|
7393
|
+
let r = vd(e, e.id, n, t.changeType);
|
|
7394
|
+
u.push(r.dedupeKey), wd(n, d) && (d = n), c.has(r.dedupeKey) || l.push(r);
|
|
7392
7395
|
}
|
|
7393
7396
|
if (s.incompleteSearch === !0) {
|
|
7394
|
-
let e = a == null ? {} :
|
|
7397
|
+
let e = a == null ? {} : fd(a, i, d);
|
|
7395
7398
|
return {
|
|
7396
|
-
checkpoint:
|
|
7399
|
+
checkpoint: pd(n, t.changeType, n.since, u, e),
|
|
7397
7400
|
events: l
|
|
7398
7401
|
};
|
|
7399
7402
|
}
|
|
7400
7403
|
if (s.nextPageToken) return {
|
|
7401
|
-
checkpoint:
|
|
7404
|
+
checkpoint: pd(n, t.changeType, n.since, u, fd(s.nextPageToken, i, d)),
|
|
7402
7405
|
events: l,
|
|
7403
7406
|
hasMore: !0
|
|
7404
7407
|
};
|
|
7405
7408
|
let f = d ?? n.since;
|
|
7406
7409
|
return {
|
|
7407
|
-
checkpoint:
|
|
7410
|
+
checkpoint: pd(n, t.changeType, f, u),
|
|
7408
7411
|
events: l
|
|
7409
7412
|
};
|
|
7410
7413
|
}
|
|
7411
|
-
function
|
|
7414
|
+
function fd(e, t, n) {
|
|
7412
7415
|
return {
|
|
7413
7416
|
pageQuery: t,
|
|
7414
7417
|
pageToken: e,
|
|
7415
7418
|
...n == null ? {} : { maxSeen: n }
|
|
7416
7419
|
};
|
|
7417
7420
|
}
|
|
7418
|
-
function
|
|
7421
|
+
function pd(e, t, n, r, i = {}) {
|
|
7419
7422
|
let a = [.../* @__PURE__ */ new Set([...e.boundaryKeys ?? [], ...r])].map((e) => ({
|
|
7420
7423
|
at: Date.parse(e.slice(e.indexOf(":") + 1)),
|
|
7421
7424
|
key: e
|
|
7422
|
-
})).filter(({ at: t }) => t >=
|
|
7425
|
+
})).filter(({ at: t }) => t >= hd(n, e.floor)).toSorted((e, t) => t.at - e.at).slice(0, 200).map(({ key: e }) => e);
|
|
7423
7426
|
return {
|
|
7424
7427
|
changeType: t,
|
|
7425
7428
|
since: n,
|
|
7426
|
-
...
|
|
7429
|
+
...gd(e.floor, n),
|
|
7427
7430
|
...i,
|
|
7428
7431
|
...a.length == 0 ? {} : { boundaryKeys: a }
|
|
7429
7432
|
};
|
|
7430
7433
|
}
|
|
7431
|
-
function
|
|
7434
|
+
function md(e, t, n) {
|
|
7432
7435
|
let r = e.changeType == "created" ? "createdTime" : "modifiedTime", i = [
|
|
7433
|
-
`'${
|
|
7436
|
+
`'${Cd(e.folderId)}' in parents`,
|
|
7434
7437
|
"trashed = false",
|
|
7435
|
-
`${r} >= '${new Date(
|
|
7438
|
+
`${r} >= '${new Date(hd(t, n)).toISOString()}'`
|
|
7436
7439
|
];
|
|
7437
|
-
return e.itemTypes.has("folder") ? e.itemTypes.has("file") || i.push(`mimeType = '${
|
|
7440
|
+
return e.itemTypes.has("folder") ? e.itemTypes.has("file") || i.push(`mimeType = '${nd}'`) : i.push(`mimeType != '${nd}'`), e.mimeTypes.length > 0 && i.push(`(${e.mimeTypes.map((e) => `mimeType = '${Cd(e)}'`).join(" or ")})`), e.namePrefix.length > 0 && i.push(`name contains '${Cd(e.namePrefix)}'`), i.join(" and ");
|
|
7438
7441
|
}
|
|
7439
|
-
function
|
|
7442
|
+
function hd(e, t) {
|
|
7440
7443
|
let n = Date.parse(e) - 6e4, r = t == null ? NaN : Date.parse(t);
|
|
7441
7444
|
return Number.isNaN(r) ? n : Math.max(n, r);
|
|
7442
7445
|
}
|
|
7443
|
-
function
|
|
7446
|
+
function gd(e, t) {
|
|
7444
7447
|
return e == null || Number.isNaN(Date.parse(e)) || Date.parse(t) - 6e4 >= Date.parse(e) ? {} : { floor: e };
|
|
7445
7448
|
}
|
|
7446
|
-
function
|
|
7449
|
+
function _d(e, t) {
|
|
7447
7450
|
let n = t == "created" ? e.createdTime : e.modifiedTime;
|
|
7448
7451
|
return n == null || n.length == 0 || Number.isNaN(Date.parse(n)) ? void 0 : n;
|
|
7449
7452
|
}
|
|
7450
|
-
function
|
|
7451
|
-
let i = e.mimeType ==
|
|
7453
|
+
function vd(e, t, n, r) {
|
|
7454
|
+
let i = e.mimeType == nd ? "folder" : "file", a = e.lastModifyingUser;
|
|
7452
7455
|
return {
|
|
7453
7456
|
dedupeKey: `${t}:${n}`,
|
|
7454
7457
|
payload: {
|
|
@@ -7470,7 +7473,7 @@ function _d(e, t, n, r) {
|
|
|
7470
7473
|
}
|
|
7471
7474
|
};
|
|
7472
7475
|
}
|
|
7473
|
-
async function
|
|
7476
|
+
async function yd(e, t, n) {
|
|
7474
7477
|
try {
|
|
7475
7478
|
return await e.connector.execute({
|
|
7476
7479
|
endpoint: t,
|
|
@@ -7481,48 +7484,48 @@ async function vd(e, t, n) {
|
|
|
7481
7484
|
throw new a(`Google Drive proxy request to ${t} failed.`, { cause: e });
|
|
7482
7485
|
}
|
|
7483
7486
|
}
|
|
7484
|
-
function
|
|
7487
|
+
function bd(e, t) {
|
|
7485
7488
|
if (!(e.status >= 200 && e.status < 300)) {
|
|
7486
7489
|
if (e.status == 400 || e.status == 404) throw new r(`Google Drive ${t} rejected the configuration.`);
|
|
7487
7490
|
if (e.status == 401) throw new i(`Google Drive ${t} rejected the Connection.`);
|
|
7488
7491
|
if (e.status == 403) {
|
|
7489
|
-
let n =
|
|
7490
|
-
if (n.some((e) =>
|
|
7491
|
-
if (n.some((e) =>
|
|
7492
|
-
if (
|
|
7492
|
+
let n = xd(e.data);
|
|
7493
|
+
if (n.some((e) => id.has(e))) throw new a(`Google Drive ${t} was rate limited.`);
|
|
7494
|
+
if (n.some((e) => ad.has(e))) throw new r(`Google Drive ${t} was rejected by an ACL.`);
|
|
7495
|
+
if (Sd(e.data)) throw new i(`Google Drive ${t} needs additional scopes.`);
|
|
7493
7496
|
}
|
|
7494
7497
|
throw new a(`Google Drive ${t} failed with status ${e.status}.`);
|
|
7495
7498
|
}
|
|
7496
7499
|
}
|
|
7497
|
-
function bd(e) {
|
|
7498
|
-
let t = wd(wd(e)?.error);
|
|
7499
|
-
return [...[t?.errors, t?.details].flatMap((e) => Array.isArray(e) ? e : []).map((e) => wd(e)?.reason), t?.status].filter((e) => typeof e == "string");
|
|
7500
|
-
}
|
|
7501
7500
|
function xd(e) {
|
|
7502
|
-
|
|
7503
|
-
|
|
7504
|
-
return typeof t == "string" && t.toLowerCase().includes("insufficient authentication scopes");
|
|
7501
|
+
let t = Td(Td(e)?.error);
|
|
7502
|
+
return [...[t?.errors, t?.details].flatMap((e) => Array.isArray(e) ? e : []).map((e) => Td(e)?.reason), t?.status].filter((e) => typeof e == "string");
|
|
7505
7503
|
}
|
|
7506
7504
|
function Sd(e) {
|
|
7505
|
+
if (xd(e).includes("ACCESS_TOKEN_SCOPE_INSUFFICIENT")) return !0;
|
|
7506
|
+
let t = Td(Td(e)?.error)?.message;
|
|
7507
|
+
return typeof t == "string" && t.toLowerCase().includes("insufficient authentication scopes");
|
|
7508
|
+
}
|
|
7509
|
+
function Cd(e) {
|
|
7507
7510
|
return e.replaceAll("\\", "\\\\").replaceAll("'", "\\'");
|
|
7508
7511
|
}
|
|
7509
|
-
function
|
|
7512
|
+
function wd(e, t) {
|
|
7510
7513
|
let n = Date.parse(e);
|
|
7511
7514
|
return Number.isNaN(n) ? !1 : t == null || Number.isNaN(Date.parse(t)) || n > Date.parse(t);
|
|
7512
7515
|
}
|
|
7513
|
-
function
|
|
7516
|
+
function Td(e) {
|
|
7514
7517
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
7515
7518
|
}
|
|
7516
7519
|
//#endregion
|
|
7517
7520
|
//#region src/trigger/providers/google-sheets/on-row-added.ts
|
|
7518
|
-
var
|
|
7521
|
+
var Ed = [
|
|
7519
7522
|
"permission_denied",
|
|
7520
7523
|
"accessnotconfigured",
|
|
7521
7524
|
"insufficientfilepermissions",
|
|
7522
7525
|
"appnotauthorizedtofile",
|
|
7523
7526
|
"the caller does not have permission",
|
|
7524
7527
|
"has not been used in project"
|
|
7525
|
-
],
|
|
7528
|
+
], Dd = ["ratelimitexceeded", "dailylimitexceeded"], Od = {
|
|
7526
7529
|
snapshot: {
|
|
7527
7530
|
configSchema: {
|
|
7528
7531
|
additionalProperties: !1,
|
|
@@ -7616,19 +7619,19 @@ var Td = [
|
|
|
7616
7619
|
type: "poll"
|
|
7617
7620
|
},
|
|
7618
7621
|
async poll(e) {
|
|
7619
|
-
let t =
|
|
7622
|
+
let t = kd(e.config);
|
|
7620
7623
|
if (e.checkpoint === null) return {
|
|
7621
|
-
checkpoint: await
|
|
7624
|
+
checkpoint: await Md(e, t, await jd(e, t)),
|
|
7622
7625
|
events: []
|
|
7623
7626
|
};
|
|
7624
|
-
let n =
|
|
7627
|
+
let n = Ad(e.checkpoint), r = await jd(e, t);
|
|
7625
7628
|
if (n.spreadsheetId !== t.spreadsheetId || n.sheetId !== r.sheetId || n.lastRowNumber > r.rowCount) return {
|
|
7626
|
-
checkpoint: await
|
|
7629
|
+
checkpoint: await Md(e, t, r),
|
|
7627
7630
|
events: []
|
|
7628
7631
|
};
|
|
7629
|
-
let i = await
|
|
7632
|
+
let i = await Pd(e, t, r), a = Math.min(Math.max(t.firstDataRow, n.lastRowNumber), r.rowCount), o = Math.min(a + t.maxRowsPerPoll, r.rowCount), s = await Fd(e, t, r, a, o, "row window fetch");
|
|
7630
7633
|
if (s.length == 0 && n.lastRowNumber >= t.firstDataRow) return {
|
|
7631
|
-
checkpoint: await
|
|
7634
|
+
checkpoint: await Md(e, t, r),
|
|
7632
7635
|
events: []
|
|
7633
7636
|
};
|
|
7634
7637
|
let c = a + s.length - 1;
|
|
@@ -7640,11 +7643,11 @@ var Td = [
|
|
|
7640
7643
|
for (let [e, o] of s.entries()) {
|
|
7641
7644
|
let s = a + e;
|
|
7642
7645
|
if (!(s <= n.lastRowNumber)) {
|
|
7643
|
-
if (s == t.headerRow ||
|
|
7646
|
+
if (s == t.headerRow || Ld(o)) {
|
|
7644
7647
|
u += 1;
|
|
7645
7648
|
continue;
|
|
7646
7649
|
}
|
|
7647
|
-
l.push(await
|
|
7650
|
+
l.push(await Rd(t, r, s, o, i));
|
|
7648
7651
|
}
|
|
7649
7652
|
}
|
|
7650
7653
|
let d = c == o && o < r.rowCount;
|
|
@@ -7660,7 +7663,7 @@ var Td = [
|
|
|
7660
7663
|
};
|
|
7661
7664
|
}
|
|
7662
7665
|
};
|
|
7663
|
-
function
|
|
7666
|
+
function kd(e) {
|
|
7664
7667
|
let t = (e.columnRange ?? "A:ZZZ").trim(), n = t.indexOf(":"), r = n < 0 ? t : t.slice(0, n), i = n < 0 ? t : t.slice(n + 1), a = e.spreadsheetId.trim();
|
|
7665
7668
|
return {
|
|
7666
7669
|
colEnd: i,
|
|
@@ -7674,8 +7677,8 @@ function Od(e) {
|
|
|
7674
7677
|
valueRender: e.valueRender ?? "UNFORMATTED_VALUE"
|
|
7675
7678
|
};
|
|
7676
7679
|
}
|
|
7677
|
-
function
|
|
7678
|
-
let t =
|
|
7680
|
+
function Ad(e) {
|
|
7681
|
+
let t = Wd(e);
|
|
7679
7682
|
if (typeof t?.spreadsheetId != "string" || !Number.isInteger(t.sheetId) || !Number.isInteger(t.lastRowNumber)) throw new r("Google Sheets checkpoint is invalid; recreate the Trigger.");
|
|
7680
7683
|
return {
|
|
7681
7684
|
lastRowNumber: t.lastRowNumber,
|
|
@@ -7683,11 +7686,11 @@ function kd(e) {
|
|
|
7683
7686
|
spreadsheetId: t.spreadsheetId
|
|
7684
7687
|
};
|
|
7685
7688
|
}
|
|
7686
|
-
async function
|
|
7687
|
-
let n = await
|
|
7689
|
+
async function jd(e, t) {
|
|
7690
|
+
let n = await Bd(e, `/spreadsheets/${encodeURIComponent(t.spreadsheetId)}`, { fields: "sheets.properties(sheetId,title,sheetType,gridProperties)" });
|
|
7688
7691
|
if (n.status == 404) throw new r("The Google Sheets spreadsheet was not found.");
|
|
7689
|
-
|
|
7690
|
-
let i =
|
|
7692
|
+
Vd(n, "spreadsheet metadata fetch");
|
|
7693
|
+
let i = Wd(n.data)?.sheets, o = (Array.isArray(i) ? i.map((e) => Wd(Wd(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);
|
|
7691
7694
|
if (s == null) throw new r(`Google Sheets tab "${t.sheet}" does not exist.`);
|
|
7692
7695
|
if (s.sheetType != null && s.sheetType !== "GRID") throw new r("The Google Sheets tab is not a grid sheet.");
|
|
7693
7696
|
let c = s.gridProperties?.rowCount;
|
|
@@ -7698,45 +7701,45 @@ async function Ad(e, t) {
|
|
|
7698
7701
|
title: s.title
|
|
7699
7702
|
};
|
|
7700
7703
|
}
|
|
7701
|
-
async function
|
|
7704
|
+
async function Md(e, t, n) {
|
|
7702
7705
|
return {
|
|
7703
|
-
lastRowNumber: await
|
|
7706
|
+
lastRowNumber: await Nd(e, t, n),
|
|
7704
7707
|
sheetId: n.sheetId,
|
|
7705
7708
|
spreadsheetId: t.spreadsheetId
|
|
7706
7709
|
};
|
|
7707
7710
|
}
|
|
7708
|
-
async function
|
|
7711
|
+
async function Nd(e, t, n) {
|
|
7709
7712
|
if (n.rowCount < t.firstDataRow) return t.firstDataRow - 1;
|
|
7710
|
-
let r = await
|
|
7713
|
+
let r = await Fd(e, t, n, t.firstDataRow, n.rowCount, "full-range scan");
|
|
7711
7714
|
return r.length == 0 ? t.firstDataRow - 1 : t.firstDataRow + r.length - 1;
|
|
7712
7715
|
}
|
|
7713
|
-
async function
|
|
7714
|
-
let r = await
|
|
7716
|
+
async function Pd(e, t, n) {
|
|
7717
|
+
let r = await Bd(e, zd(t, n, t.headerRow, t.headerRow), {
|
|
7715
7718
|
majorDimension: "ROWS",
|
|
7716
7719
|
valueRenderOption: "FORMATTED_VALUE"
|
|
7717
7720
|
});
|
|
7718
|
-
return
|
|
7721
|
+
return Vd(r, "header row fetch"), Id(r.data)[0] ?? [];
|
|
7719
7722
|
}
|
|
7720
|
-
async function
|
|
7721
|
-
let o = await
|
|
7723
|
+
async function Fd(e, t, n, r, i, a) {
|
|
7724
|
+
let o = await Bd(e, zd(t, n, r, i), {
|
|
7722
7725
|
dateTimeRenderOption: t.dateTimeRender,
|
|
7723
7726
|
majorDimension: "ROWS",
|
|
7724
7727
|
valueRenderOption: t.valueRender
|
|
7725
7728
|
});
|
|
7726
|
-
return
|
|
7729
|
+
return Vd(o, a), Id(o.data);
|
|
7727
7730
|
}
|
|
7728
|
-
function
|
|
7729
|
-
let t =
|
|
7731
|
+
function Id(e) {
|
|
7732
|
+
let t = Wd(e)?.values;
|
|
7730
7733
|
return Array.isArray(t) ? t : [];
|
|
7731
7734
|
}
|
|
7732
|
-
function
|
|
7735
|
+
function Ld(e) {
|
|
7733
7736
|
return e.every((e) => e === "" || e == null);
|
|
7734
7737
|
}
|
|
7735
|
-
async function
|
|
7736
|
-
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 =
|
|
7738
|
+
async function Rd(e, t, n, r, i) {
|
|
7739
|
+
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 = Hd(e.colStart);
|
|
7737
7740
|
for (let [e, t] of r.entries()) {
|
|
7738
7741
|
let n = i[e];
|
|
7739
|
-
s[typeof n == "string" && n.length > 0 ? n :
|
|
7742
|
+
s[typeof n == "string" && n.length > 0 ? n : Ud(c + e)] = t;
|
|
7740
7743
|
}
|
|
7741
7744
|
return {
|
|
7742
7745
|
dedupeKey: `${t.sheetId}:${n}:${o}`,
|
|
@@ -7750,11 +7753,11 @@ async function Ld(e, t, n, r, i) {
|
|
|
7750
7753
|
}
|
|
7751
7754
|
};
|
|
7752
7755
|
}
|
|
7753
|
-
function
|
|
7756
|
+
function zd(e, t, n, r) {
|
|
7754
7757
|
let i = encodeURIComponent(`'${t.title.replaceAll("'", "''")}'`);
|
|
7755
7758
|
return `/spreadsheets/${encodeURIComponent(e.spreadsheetId)}/values/${i}!${e.colStart}${n}:${e.colEnd}${r}`;
|
|
7756
7759
|
}
|
|
7757
|
-
async function
|
|
7760
|
+
async function Bd(e, t, n) {
|
|
7758
7761
|
try {
|
|
7759
7762
|
return await e.connector.execute({
|
|
7760
7763
|
endpoint: t,
|
|
@@ -7765,32 +7768,32 @@ async function zd(e, t, n) {
|
|
|
7765
7768
|
throw new a(`Google Sheets proxy request to ${t} failed.`, { cause: e });
|
|
7766
7769
|
}
|
|
7767
7770
|
}
|
|
7768
|
-
function
|
|
7771
|
+
function Vd(e, t) {
|
|
7769
7772
|
if (e.status >= 200 && e.status < 300) return;
|
|
7770
7773
|
if (e.status == 401) throw new i(`Google Sheets ${t} rejected the Connection.`);
|
|
7771
7774
|
let n = JSON.stringify(e.data ?? null).toLowerCase();
|
|
7772
7775
|
if (e.status == 403) {
|
|
7773
|
-
if (
|
|
7774
|
-
if (
|
|
7776
|
+
if (Dd.some((e) => n.includes(e))) throw new a(`Google Sheets ${t} was rate limited.`);
|
|
7777
|
+
if (Ed.some((e) => n.includes(e))) throw new i(`Google Sheets ${t} rejected the Connection.`);
|
|
7775
7778
|
}
|
|
7776
7779
|
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}.`);
|
|
7777
7780
|
}
|
|
7778
|
-
function
|
|
7781
|
+
function Hd(e) {
|
|
7779
7782
|
let t = 0;
|
|
7780
7783
|
for (let n of e.toUpperCase()) t = t * 26 + n.charCodeAt(0) - 64;
|
|
7781
7784
|
return t;
|
|
7782
7785
|
}
|
|
7783
|
-
function
|
|
7786
|
+
function Ud(e) {
|
|
7784
7787
|
let t = "";
|
|
7785
7788
|
for (let n = e; n > 0; n = Math.floor((n - 1) / 26)) t = String.fromCharCode(65 + (n - 1) % 26) + t;
|
|
7786
7789
|
return t;
|
|
7787
7790
|
}
|
|
7788
|
-
function
|
|
7791
|
+
function Wd(e) {
|
|
7789
7792
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
7790
7793
|
}
|
|
7791
7794
|
//#endregion
|
|
7792
7795
|
//#region src/trigger/providers/linear/on-issue-changed.ts
|
|
7793
|
-
var
|
|
7796
|
+
var Gd = "^[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}$", Kd = new RegExp(Gd), qd = 6e4, Jd = 50, Yd = {
|
|
7794
7797
|
snapshot: {
|
|
7795
7798
|
configSchema: {
|
|
7796
7799
|
type: "object",
|
|
@@ -7800,7 +7803,7 @@ var Wd = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
7800
7803
|
title: "Team ID",
|
|
7801
7804
|
description: "Linear Team UUID. Use Copy model UUID in Linear to find it.",
|
|
7802
7805
|
type: "string",
|
|
7803
|
-
pattern:
|
|
7806
|
+
pattern: Gd
|
|
7804
7807
|
},
|
|
7805
7808
|
stateIds: {
|
|
7806
7809
|
title: "Issue statuses",
|
|
@@ -7808,7 +7811,7 @@ var Wd = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
7808
7811
|
type: "array",
|
|
7809
7812
|
items: {
|
|
7810
7813
|
type: "string",
|
|
7811
|
-
pattern:
|
|
7814
|
+
pattern: Gd
|
|
7812
7815
|
},
|
|
7813
7816
|
uniqueItems: !0,
|
|
7814
7817
|
maxItems: 50,
|
|
@@ -7871,12 +7874,12 @@ var Wd = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
7871
7874
|
provider: "linear",
|
|
7872
7875
|
type: "poll"
|
|
7873
7876
|
},
|
|
7874
|
-
configOptions:
|
|
7877
|
+
configOptions: ef,
|
|
7875
7878
|
async poll(e) {
|
|
7876
7879
|
let t = typeof e.config.teamId == "string" ? e.config.teamId.toLowerCase() : e.config.teamId, n = e.config.stateIds ?? [];
|
|
7877
|
-
if (typeof t != "string" || !
|
|
7880
|
+
if (typeof t != "string" || !Kd.test(t) || !Array.isArray(n) || n.length > 50 || n.some((e) => typeof e != "string" || !Kd.test(e))) throw new r("Linear Issue configuration is invalid.");
|
|
7878
7881
|
if (e.checkpoint == null) {
|
|
7879
|
-
|
|
7882
|
+
Qd((await $d(e, "query LinearTeam($teamId: String!) { team(id: $teamId) { id } }", { teamId: t })).team, t);
|
|
7880
7883
|
let n = e.now.toISOString();
|
|
7881
7884
|
return {
|
|
7882
7885
|
checkpoint: {
|
|
@@ -7886,10 +7889,10 @@ var Wd = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
7886
7889
|
events: []
|
|
7887
7890
|
};
|
|
7888
7891
|
}
|
|
7889
|
-
let i =
|
|
7892
|
+
let i = Xd(e.checkpoint), o = i.until ?? new Date(Math.max(e.now.getTime(), Date.parse(i.since))).toISOString(), c = new Date(Math.max(Date.parse(i.startedAt), Date.parse(i.since) - qd)).toISOString(), l = Qd((await $d(e, `query LinearIssueChanges($teamId: String!, $filter: IssueFilter!, $after: String) {
|
|
7890
7893
|
team(id: $teamId) {
|
|
7891
7894
|
id
|
|
7892
|
-
issues(first: ${
|
|
7895
|
+
issues(first: ${Jd}, after: $after, orderBy: updatedAt, includeArchived: true, filter: $filter) {
|
|
7893
7896
|
nodes { id identifier title url createdAt updatedAt state { id name type } }
|
|
7894
7897
|
pageInfo { hasNextPage endCursor }
|
|
7895
7898
|
}
|
|
@@ -7905,11 +7908,11 @@ var Wd = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
7905
7908
|
...n.length == 0 ? {} : { state: { id: { in: n } } }
|
|
7906
7909
|
}
|
|
7907
7910
|
})).team, t).issues;
|
|
7908
|
-
if (!s(l) || !Array.isArray(l.nodes) || l.nodes.length >
|
|
7911
|
+
if (!s(l) || !Array.isArray(l.nodes) || l.nodes.length > Jd || !s(l.pageInfo) || typeof l.pageInfo.hasNextPage != "boolean") throw new a("Linear returned an invalid Issue page.");
|
|
7909
7912
|
let { hasNextPage: u, endCursor: d } = l.pageInfo;
|
|
7910
7913
|
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.");
|
|
7911
7914
|
let f = l.nodes.map((e) => {
|
|
7912
|
-
if (!s(e) || typeof e.id != "string" || !
|
|
7915
|
+
if (!s(e) || typeof e.id != "string" || !Kd.test(e.id) || typeof e.identifier != "string" || e.identifier.length == 0 || typeof e.title != "string" || typeof e.url != "string" || !Zd(e.createdAt) || !Zd(e.updatedAt) || Date.parse(e.createdAt) > Date.parse(e.updatedAt) || Date.parse(e.updatedAt) < Date.parse(c) || Date.parse(e.updatedAt) > Date.parse(o) || !s(e.state) || typeof e.state.id != "string" || !Kd.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.");
|
|
7913
7916
|
return {
|
|
7914
7917
|
dedupeKey: `${e.id}:${e.updatedAt}`,
|
|
7915
7918
|
payload: {
|
|
@@ -7942,8 +7945,8 @@ var Wd = "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-
|
|
|
7942
7945
|
};
|
|
7943
7946
|
}
|
|
7944
7947
|
};
|
|
7945
|
-
function
|
|
7946
|
-
if (!s(e) || !
|
|
7948
|
+
function Xd(e) {
|
|
7949
|
+
if (!s(e) || !Zd(e.startedAt) || !Zd(e.since) || Date.parse(e.since) < Date.parse(e.startedAt) || e.until != null && (!Zd(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.");
|
|
7947
7950
|
return {
|
|
7948
7951
|
startedAt: e.startedAt,
|
|
7949
7952
|
since: e.since,
|
|
@@ -7951,15 +7954,15 @@ function Yd(e) {
|
|
|
7951
7954
|
...typeof e.after == "string" ? { after: e.after } : {}
|
|
7952
7955
|
};
|
|
7953
7956
|
}
|
|
7954
|
-
function
|
|
7957
|
+
function Zd(e) {
|
|
7955
7958
|
return typeof e == "string" && e.length <= 40 && /^\d{4}-\d{2}-\d{2}T/.test(e) && Number.isFinite(Date.parse(e));
|
|
7956
7959
|
}
|
|
7957
|
-
function
|
|
7960
|
+
function Qd(e, t) {
|
|
7958
7961
|
if (e === null) throw new r("The Linear team is unavailable or not accessible to this Connection.");
|
|
7959
7962
|
if (!s(e) || e.id !== t) throw new a("Linear returned an invalid Team.");
|
|
7960
7963
|
return e;
|
|
7961
7964
|
}
|
|
7962
|
-
async function
|
|
7965
|
+
async function $d(e, t, n) {
|
|
7963
7966
|
e.signal?.throwIfAborted();
|
|
7964
7967
|
let o = await e.connector.execute({
|
|
7965
7968
|
endpoint: "/graphql",
|
|
@@ -7979,19 +7982,19 @@ async function Qd(e, t, n) {
|
|
|
7979
7982
|
if (o.status != 200 || !s(c) || !s(c.data) || c.errors != null && !Array.isArray(c.errors)) throw new a(`Linear returned an invalid query response (HTTP ${o.status}).`);
|
|
7980
7983
|
return c.data;
|
|
7981
7984
|
}
|
|
7982
|
-
async function
|
|
7985
|
+
async function ef(e) {
|
|
7983
7986
|
let { field: t, config: n } = e;
|
|
7984
7987
|
if (t != "teamId" && t != "stateIds") throw new r("Unknown Linear configuration field.");
|
|
7985
|
-
if (t == "stateIds" && (typeof n.teamId != "string" || !
|
|
7988
|
+
if (t == "stateIds" && (typeof n.teamId != "string" || !Kd.test(n.teamId))) throw new r("Select a Linear Team first.");
|
|
7986
7989
|
let i = [], o = /* @__PURE__ */ new Set(), c = null;
|
|
7987
7990
|
for (let r = 0; r < 10; r++) {
|
|
7988
|
-
let r = await
|
|
7991
|
+
let r = await $d(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 } } } }", {
|
|
7989
7992
|
after: c,
|
|
7990
7993
|
...t == "teamId" ? {} : { teamId: n.teamId }
|
|
7991
|
-
}), l = t == "teamId" ? r.teams :
|
|
7994
|
+
}), l = t == "teamId" ? r.teams : Qd(r.team, String(n.teamId)).states;
|
|
7992
7995
|
if (!s(l) || !Array.isArray(l.nodes) || l.nodes.length > 100 || !s(l.pageInfo) || typeof l.pageInfo.hasNextPage != "boolean") throw new a("Linear returned invalid configuration options.");
|
|
7993
7996
|
for (let e of l.nodes) {
|
|
7994
|
-
if (!s(e) || typeof e.id != "string" || !
|
|
7997
|
+
if (!s(e) || typeof e.id != "string" || !Kd.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.");
|
|
7995
7998
|
i.push({
|
|
7996
7999
|
value: e.id,
|
|
7997
8000
|
label: t == "teamId" ? `${e.name} (${e.key})` : e.name,
|
|
@@ -8005,7 +8008,7 @@ async function $d(e) {
|
|
|
8005
8008
|
}
|
|
8006
8009
|
throw new r("The Linear options list exceeds the supported limit of 1000 entries.");
|
|
8007
8010
|
}
|
|
8008
|
-
var
|
|
8011
|
+
var tf = {
|
|
8009
8012
|
snapshot: {
|
|
8010
8013
|
configSchema: {
|
|
8011
8014
|
additionalProperties: !1,
|
|
@@ -8094,13 +8097,13 @@ var ef = {
|
|
|
8094
8097
|
type: "poll"
|
|
8095
8098
|
},
|
|
8096
8099
|
async poll(e) {
|
|
8097
|
-
let t =
|
|
8098
|
-
if (e.checkpoint === null) return
|
|
8099
|
-
let n =
|
|
8100
|
-
return n.target ===
|
|
8100
|
+
let t = nf(e.config);
|
|
8101
|
+
if (e.checkpoint === null) return rf(e, t);
|
|
8102
|
+
let n = of(e.checkpoint);
|
|
8103
|
+
return n.target === vf(t) ? lf(e, t, cf(n, sf(t.events))) : rf(e, t);
|
|
8101
8104
|
}
|
|
8102
8105
|
};
|
|
8103
|
-
function
|
|
8106
|
+
function nf(e) {
|
|
8104
8107
|
return {
|
|
8105
8108
|
dataSourceId: e.dataSourceId ?? "",
|
|
8106
8109
|
databaseId: e.databaseId,
|
|
@@ -8109,9 +8112,9 @@ function tf(e) {
|
|
|
8109
8112
|
maxItemsPerPoll: e.maxItemsPerPoll ?? 25
|
|
8110
8113
|
};
|
|
8111
8114
|
}
|
|
8112
|
-
async function
|
|
8113
|
-
let n = await
|
|
8114
|
-
return
|
|
8115
|
+
async function rf(e, t) {
|
|
8116
|
+
let n = await af(e, t), r = sf(t.events);
|
|
8117
|
+
return _f(await gf(e, {
|
|
8115
8118
|
body: {
|
|
8116
8119
|
page_size: 1,
|
|
8117
8120
|
sorts: [{
|
|
@@ -8126,31 +8129,31 @@ async function nf(e, t) {
|
|
|
8126
8129
|
cursorField: r,
|
|
8127
8130
|
dataSourceId: n,
|
|
8128
8131
|
since: (/* @__PURE__ */ new Date(Math.ceil(e.now.getTime() / 6e4) * 6e4)).toISOString(),
|
|
8129
|
-
target:
|
|
8132
|
+
target: vf(t)
|
|
8130
8133
|
},
|
|
8131
8134
|
events: []
|
|
8132
8135
|
};
|
|
8133
8136
|
}
|
|
8134
|
-
async function
|
|
8135
|
-
let n = await
|
|
8137
|
+
async function af(e, t) {
|
|
8138
|
+
let n = await gf(e, {
|
|
8136
8139
|
endpoint: `/databases/${encodeURIComponent(t.databaseId)}`,
|
|
8137
8140
|
method: "GET"
|
|
8138
8141
|
});
|
|
8139
|
-
|
|
8140
|
-
let i =
|
|
8141
|
-
let t =
|
|
8142
|
+
_f(n, "database resolve");
|
|
8143
|
+
let i = wf(n.data)?.data_sources, a = Array.isArray(i) ? i.flatMap((e) => {
|
|
8144
|
+
let t = wf(e)?.id;
|
|
8142
8145
|
return typeof t == "string" && t.length > 0 ? [t] : [];
|
|
8143
8146
|
}) : [];
|
|
8144
8147
|
if (t.dataSourceId.length > 0) {
|
|
8145
|
-
let e =
|
|
8148
|
+
let e = yf(t.dataSourceId), n = a.find((t) => yf(t) == e);
|
|
8146
8149
|
if (n == null) throw new r("The Notion data source does not belong to the configured database.");
|
|
8147
8150
|
return n;
|
|
8148
8151
|
}
|
|
8149
8152
|
if (a.length == 1) return a[0];
|
|
8150
8153
|
throw a.length == 0 ? new r("The Notion database has no data sources.") : new r("The Notion database has multiple data sources; configure dataSourceId.");
|
|
8151
8154
|
}
|
|
8152
|
-
function
|
|
8153
|
-
let t =
|
|
8155
|
+
function of(e) {
|
|
8156
|
+
let t = wf(e), n = t?.cursorField;
|
|
8154
8157
|
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.");
|
|
8155
8158
|
return {
|
|
8156
8159
|
cursorField: n,
|
|
@@ -8162,10 +8165,10 @@ function af(e) {
|
|
|
8162
8165
|
...t.sinceOnly === !0 ? { sinceOnly: !0 } : {}
|
|
8163
8166
|
};
|
|
8164
8167
|
}
|
|
8165
|
-
function
|
|
8168
|
+
function sf(e) {
|
|
8166
8169
|
return e.length == 1 && e[0] == "page_added" ? "created_time" : "last_edited_time";
|
|
8167
8170
|
}
|
|
8168
|
-
function
|
|
8171
|
+
function cf(e, t) {
|
|
8169
8172
|
return e.cursorField == t ? e : {
|
|
8170
8173
|
cursorField: t,
|
|
8171
8174
|
dataSourceId: e.dataSourceId,
|
|
@@ -8173,11 +8176,11 @@ function sf(e, t) {
|
|
|
8173
8176
|
target: e.target
|
|
8174
8177
|
};
|
|
8175
8178
|
}
|
|
8176
|
-
async function
|
|
8179
|
+
async function lf(e, t, n) {
|
|
8177
8180
|
let r = [], i = 0, a = 0, o = null, s = n.startCursor, c = null;
|
|
8178
8181
|
for (let l = 0; l < 5; l += 1) {
|
|
8179
|
-
let l = await
|
|
8180
|
-
body:
|
|
8182
|
+
let l = await gf(e, {
|
|
8183
|
+
body: ff(n, t.maxItemsPerPoll - a, s),
|
|
8181
8184
|
endpoint: `/data_sources/${encodeURIComponent(n.dataSourceId)}/query`,
|
|
8182
8185
|
method: "POST"
|
|
8183
8186
|
});
|
|
@@ -8185,14 +8188,14 @@ async function cf(e, t, n) {
|
|
|
8185
8188
|
c = "restarted";
|
|
8186
8189
|
break;
|
|
8187
8190
|
}
|
|
8188
|
-
|
|
8189
|
-
let u =
|
|
8191
|
+
_f(l, "data source query");
|
|
8192
|
+
let u = wf(l.data) ?? {};
|
|
8190
8193
|
for (let e of u.results ?? []) {
|
|
8191
8194
|
a += 1;
|
|
8192
8195
|
let s = n.cursorField == "created_time" ? e.created_time : e.last_edited_time;
|
|
8193
|
-
s != null && s.length > 0 && (o =
|
|
8194
|
-
let c =
|
|
8195
|
-
t.events.includes(c) ? r.push(
|
|
8196
|
+
s != null && s.length > 0 && (o = xf(o, s));
|
|
8197
|
+
let c = pf(e);
|
|
8198
|
+
t.events.includes(c) ? r.push(mf(e, c, t, n)) : i += 1;
|
|
8196
8199
|
}
|
|
8197
8200
|
if (u.request_status?.type == "incomplete") {
|
|
8198
8201
|
c = "truncated";
|
|
@@ -8218,36 +8221,36 @@ async function cf(e, t, n) {
|
|
|
8218
8221
|
...l,
|
|
8219
8222
|
since: n.since,
|
|
8220
8223
|
startCursor: c.nextCursor,
|
|
8221
|
-
...
|
|
8224
|
+
...df(n)
|
|
8222
8225
|
} : {
|
|
8223
8226
|
...l,
|
|
8224
|
-
...
|
|
8227
|
+
...uf(n, c, o, e.now)
|
|
8225
8228
|
},
|
|
8226
8229
|
events: r,
|
|
8227
8230
|
filtered: i,
|
|
8228
8231
|
...c == "complete" ? {} : { hasMore: !0 }
|
|
8229
8232
|
};
|
|
8230
8233
|
}
|
|
8231
|
-
function
|
|
8234
|
+
function uf(e, t, n, r) {
|
|
8232
8235
|
let i = {
|
|
8233
8236
|
since: e.since,
|
|
8234
|
-
...
|
|
8237
|
+
...df(e)
|
|
8235
8238
|
}, a = Date.parse(e.since) + 6e4 <= r.getTime() ? {
|
|
8236
8239
|
since: e.since,
|
|
8237
8240
|
sinceExclusive: !0
|
|
8238
8241
|
} : i;
|
|
8239
|
-
return n != null &&
|
|
8242
|
+
return n != null && Sf(n, e.since) ? { since: n } : t == "restarted" ? i : t == "complete" ? e.sinceOnly === !0 || n != null ? a : i : n == null ? i : e.sinceOnly === !0 ? a : {
|
|
8240
8243
|
since: e.since,
|
|
8241
8244
|
sinceOnly: !0
|
|
8242
8245
|
};
|
|
8243
8246
|
}
|
|
8244
|
-
function
|
|
8247
|
+
function df(e) {
|
|
8245
8248
|
return {
|
|
8246
8249
|
...e.sinceExclusive === !0 ? { sinceExclusive: !0 } : {},
|
|
8247
8250
|
...e.sinceOnly === !0 ? { sinceOnly: !0 } : {}
|
|
8248
8251
|
};
|
|
8249
8252
|
}
|
|
8250
|
-
function
|
|
8253
|
+
function ff(e, t, n) {
|
|
8251
8254
|
let r = e.cursorField;
|
|
8252
8255
|
return {
|
|
8253
8256
|
filter: e.sinceOnly === !0 ? { and: [{
|
|
@@ -8268,70 +8271,70 @@ function df(e, t, n) {
|
|
|
8268
8271
|
...n == null ? {} : { start_cursor: n }
|
|
8269
8272
|
};
|
|
8270
8273
|
}
|
|
8271
|
-
function
|
|
8272
|
-
return
|
|
8274
|
+
function pf(e) {
|
|
8275
|
+
return Cf(e.created_time) === Cf(e.last_edited_time) ? "page_added" : "page_updated";
|
|
8273
8276
|
}
|
|
8274
|
-
function
|
|
8277
|
+
function mf(e, t, n, r) {
|
|
8275
8278
|
return {
|
|
8276
|
-
dedupeKey: t == "page_added" ? `added:${e.id}` : `updated:${e.id}:${
|
|
8279
|
+
dedupeKey: t == "page_added" ? `added:${e.id}` : `updated:${e.id}:${Cf(e.last_edited_time) ?? e.last_edited_time ?? ""}`,
|
|
8277
8280
|
payload: {
|
|
8278
8281
|
createdBy: { id: e.created_by?.id ?? "" },
|
|
8279
8282
|
createdTime: e.created_time ?? "",
|
|
8280
8283
|
dataSourceId: r.dataSourceId,
|
|
8281
|
-
databaseId:
|
|
8284
|
+
databaseId: bf(n.databaseId),
|
|
8282
8285
|
event: t,
|
|
8283
8286
|
lastEditedBy: { id: e.last_edited_by?.id ?? "" },
|
|
8284
8287
|
lastEditedTime: e.last_edited_time ?? "",
|
|
8285
8288
|
pageId: e.id,
|
|
8286
8289
|
...n.includeProperties ? { properties: e.properties ?? {} } : {},
|
|
8287
|
-
title:
|
|
8290
|
+
title: hf(e.properties ?? {}),
|
|
8288
8291
|
url: e.url ?? ""
|
|
8289
8292
|
}
|
|
8290
8293
|
};
|
|
8291
8294
|
}
|
|
8292
|
-
function
|
|
8295
|
+
function hf(e) {
|
|
8293
8296
|
for (let t of Object.values(e)) {
|
|
8294
|
-
let e =
|
|
8295
|
-
if (!(e?.type !== "title" || !Array.isArray(e.title))) return e.title.map((e) => typeof
|
|
8297
|
+
let e = wf(t);
|
|
8298
|
+
if (!(e?.type !== "title" || !Array.isArray(e.title))) return e.title.map((e) => typeof wf(e)?.plain_text == "string" ? wf(e).plain_text : "").join("");
|
|
8296
8299
|
}
|
|
8297
8300
|
return "";
|
|
8298
8301
|
}
|
|
8299
|
-
async function
|
|
8302
|
+
async function gf(e, t) {
|
|
8300
8303
|
try {
|
|
8301
8304
|
return await e.connector.execute(t, e.signal);
|
|
8302
8305
|
} catch (e) {
|
|
8303
8306
|
throw new a(`Notion proxy request to ${t.endpoint} failed.`, { cause: e });
|
|
8304
8307
|
}
|
|
8305
8308
|
}
|
|
8306
|
-
function
|
|
8309
|
+
function _f(e, t) {
|
|
8307
8310
|
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}.`);
|
|
8308
8311
|
}
|
|
8309
|
-
function
|
|
8312
|
+
function vf(e) {
|
|
8310
8313
|
return `${e.databaseId}|${e.dataSourceId}`;
|
|
8311
8314
|
}
|
|
8312
|
-
function
|
|
8315
|
+
function yf(e) {
|
|
8313
8316
|
return e.replaceAll("-", "").toLowerCase();
|
|
8314
8317
|
}
|
|
8315
|
-
function
|
|
8316
|
-
let t =
|
|
8318
|
+
function bf(e) {
|
|
8319
|
+
let t = yf(e);
|
|
8317
8320
|
return `${t.slice(0, 8)}-${t.slice(8, 12)}-${t.slice(12, 16)}-${t.slice(16, 20)}-${t.slice(20)}`;
|
|
8318
8321
|
}
|
|
8319
|
-
function
|
|
8322
|
+
function xf(e, t) {
|
|
8320
8323
|
let n = Date.parse(t);
|
|
8321
8324
|
return Number.isNaN(n) || e != null && n < Date.parse(e) ? e : t;
|
|
8322
8325
|
}
|
|
8323
|
-
function
|
|
8326
|
+
function Sf(e, t) {
|
|
8324
8327
|
return !Number.isNaN(Date.parse(e)) && !Number.isNaN(Date.parse(t)) && Date.parse(e) > Date.parse(t);
|
|
8325
8328
|
}
|
|
8326
|
-
function
|
|
8329
|
+
function Cf(e) {
|
|
8327
8330
|
if (e == null || e.length == 0) return null;
|
|
8328
8331
|
let t = Date.parse(e);
|
|
8329
8332
|
return Number.isNaN(t) ? null : new Date(t).toISOString();
|
|
8330
8333
|
}
|
|
8331
|
-
function
|
|
8334
|
+
function wf(e) {
|
|
8332
8335
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
8333
8336
|
}
|
|
8334
|
-
var
|
|
8337
|
+
var Tf = {
|
|
8335
8338
|
snapshot: {
|
|
8336
8339
|
configSchema: {
|
|
8337
8340
|
additionalProperties: !1,
|
|
@@ -8438,14 +8441,14 @@ var wf = {
|
|
|
8438
8441
|
type: "poll"
|
|
8439
8442
|
},
|
|
8440
8443
|
async poll(e) {
|
|
8441
|
-
let t =
|
|
8444
|
+
let t = Ef(e.config);
|
|
8442
8445
|
if (e.checkpoint === null) return {
|
|
8443
|
-
checkpoint: await
|
|
8446
|
+
checkpoint: await Df(e, t),
|
|
8444
8447
|
events: []
|
|
8445
8448
|
};
|
|
8446
|
-
let n =
|
|
8449
|
+
let n = kf(e.checkpoint), { items: r, next: i } = await Af(e, n, t.maxItemsPerPoll), a = [], o = 0;
|
|
8447
8450
|
for (let [e, i] of r) {
|
|
8448
|
-
let r = await
|
|
8451
|
+
let r = await jf(e, i, t, n);
|
|
8449
8452
|
r != "structural" && (r == "filtered" ? o += 1 : a.push(r));
|
|
8450
8453
|
}
|
|
8451
8454
|
return {
|
|
@@ -8456,7 +8459,7 @@ var wf = {
|
|
|
8456
8459
|
};
|
|
8457
8460
|
}
|
|
8458
8461
|
};
|
|
8459
|
-
function
|
|
8462
|
+
function Ef(e) {
|
|
8460
8463
|
return {
|
|
8461
8464
|
events: e.events ?? ["created", "updated"],
|
|
8462
8465
|
itemId: (e.itemId ?? "").trim(),
|
|
@@ -8465,25 +8468,25 @@ function Tf(e) {
|
|
|
8465
8468
|
parentFolderId: (e.parentFolderId ?? "").trim()
|
|
8466
8469
|
};
|
|
8467
8470
|
}
|
|
8468
|
-
async function
|
|
8469
|
-
let n = await
|
|
8471
|
+
async function Df(e, t) {
|
|
8472
|
+
let n = await Pf(e, "/me/drive/root/delta", { token: "latest" });
|
|
8470
8473
|
if (n.status == 404) throw new r("OneDrive is not provisioned for this account.");
|
|
8471
|
-
|
|
8472
|
-
let i =
|
|
8474
|
+
If(n, "delta seeding");
|
|
8475
|
+
let i = Vf(n.data)?.["@odata.deltaLink"], o = i == null ? null : zf(i);
|
|
8473
8476
|
if (o == null) throw new a("OneDrive delta seeding response has no delta token.");
|
|
8474
|
-
return await
|
|
8477
|
+
return await Of(e, "parentFolderId", t.parentFolderId), await Of(e, "itemId", t.itemId), {
|
|
8475
8478
|
deltaToken: o,
|
|
8476
8479
|
lastPolledAt: e.now.toISOString()
|
|
8477
8480
|
};
|
|
8478
8481
|
}
|
|
8479
|
-
async function
|
|
8482
|
+
async function Of(e, t, n) {
|
|
8480
8483
|
if (n.length == 0) return;
|
|
8481
|
-
let i = await
|
|
8484
|
+
let i = await Pf(e, `/me/drive/items/${encodeURIComponent(n)}`, {});
|
|
8482
8485
|
if (i.status == 400 || i.status == 404) throw new r(`OneDrive ${t} does not identify an item in this drive.`);
|
|
8483
|
-
|
|
8486
|
+
If(i, `${t} validation`);
|
|
8484
8487
|
}
|
|
8485
|
-
function
|
|
8486
|
-
let t =
|
|
8488
|
+
function kf(e) {
|
|
8489
|
+
let t = Vf(e);
|
|
8487
8490
|
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.");
|
|
8488
8491
|
return {
|
|
8489
8492
|
deltaToken: t.deltaToken,
|
|
@@ -8491,28 +8494,28 @@ function Of(e) {
|
|
|
8491
8494
|
...typeof t.pageToken == "string" && t.pageToken.length > 0 ? { pageToken: t.pageToken } : {}
|
|
8492
8495
|
};
|
|
8493
8496
|
}
|
|
8494
|
-
async function
|
|
8497
|
+
async function Af(e, t, n) {
|
|
8495
8498
|
let r = /* @__PURE__ */ new Map(), i = t.pageToken ?? t.deltaToken;
|
|
8496
8499
|
for (let t = 0; t < 5; t += 1) {
|
|
8497
|
-
let t = await
|
|
8500
|
+
let t = await Pf(e, "/me/drive/root/delta", {
|
|
8498
8501
|
$top: n,
|
|
8499
8502
|
token: i
|
|
8500
8503
|
});
|
|
8501
|
-
|
|
8502
|
-
let o =
|
|
8504
|
+
Ff(t);
|
|
8505
|
+
let o = Vf(t.data) ?? {};
|
|
8503
8506
|
for (let e of o.value ?? []) e.id != null && e.id.length > 0 && r.set(e.id, e);
|
|
8504
8507
|
if (o["@odata.deltaLink"]) return {
|
|
8505
8508
|
items: r,
|
|
8506
8509
|
next: {
|
|
8507
8510
|
checkpoint: {
|
|
8508
|
-
deltaToken:
|
|
8511
|
+
deltaToken: Rf(o["@odata.deltaLink"]),
|
|
8509
8512
|
lastPolledAt: e.now.toISOString()
|
|
8510
8513
|
},
|
|
8511
8514
|
hasMore: !1
|
|
8512
8515
|
}
|
|
8513
8516
|
};
|
|
8514
8517
|
if (!o["@odata.nextLink"]) throw new a("OneDrive delta response has no continuation link.");
|
|
8515
|
-
i =
|
|
8518
|
+
i = Rf(o["@odata.nextLink"]);
|
|
8516
8519
|
}
|
|
8517
8520
|
return {
|
|
8518
8521
|
items: r,
|
|
@@ -8526,19 +8529,19 @@ async function kf(e, t, n) {
|
|
|
8526
8529
|
}
|
|
8527
8530
|
};
|
|
8528
8531
|
}
|
|
8529
|
-
async function
|
|
8532
|
+
async function jf(e, t, n, r) {
|
|
8530
8533
|
if (t.root != null) return "structural";
|
|
8531
|
-
let i =
|
|
8534
|
+
let i = Mf(t);
|
|
8532
8535
|
if (i == null) return "structural";
|
|
8533
|
-
let a = t.deleted == null ?
|
|
8534
|
-
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
|
|
8536
|
+
let a = t.deleted == null ? Bf(t.createdDateTime, new Date(r.lastPolledAt)) ? "created" : "updated" : "deleted";
|
|
8537
|
+
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 Nf(e, t, a, i, r.deltaToken);
|
|
8535
8538
|
}
|
|
8536
|
-
function
|
|
8539
|
+
function Mf(e) {
|
|
8537
8540
|
return e.file == null ? e.folder == null ? e.deleted == null ? null : "file" : "folder" : "file";
|
|
8538
8541
|
}
|
|
8539
|
-
async function
|
|
8542
|
+
async function Nf(e, t, n, r, i) {
|
|
8540
8543
|
return {
|
|
8541
|
-
dedupeKey: t.deleted == null ? `${e}:${t.eTag ?? t.lastModifiedDateTime}` : await gl(
|
|
8544
|
+
dedupeKey: t.deleted == null ? `${e}:${t.eTag ?? t.lastModifiedDateTime}` : await _l(gl([
|
|
8542
8545
|
"one-drive-deleted",
|
|
8543
8546
|
i,
|
|
8544
8547
|
e
|
|
@@ -8559,7 +8562,7 @@ async function Mf(e, t, n, r, i) {
|
|
|
8559
8562
|
}
|
|
8560
8563
|
};
|
|
8561
8564
|
}
|
|
8562
|
-
async function
|
|
8565
|
+
async function Pf(e, t, n) {
|
|
8563
8566
|
try {
|
|
8564
8567
|
return await e.connector.execute({
|
|
8565
8568
|
endpoint: t,
|
|
@@ -8570,31 +8573,31 @@ async function Nf(e, t, n) {
|
|
|
8570
8573
|
throw new a(`OneDrive proxy request to ${t} failed.`, { cause: e });
|
|
8571
8574
|
}
|
|
8572
8575
|
}
|
|
8573
|
-
function
|
|
8574
|
-
if (e.status == 410 &&
|
|
8576
|
+
function Ff(e) {
|
|
8577
|
+
if (e.status == 410 && Lf(e.data)) throw new r("OneDrive delta token expired; recreate the Trigger.");
|
|
8575
8578
|
if (e.status == 404) throw new r("OneDrive is not provisioned for this account.");
|
|
8576
8579
|
if (e.status == 400) throw new r("OneDrive rejected the delta token; recreate the Trigger.");
|
|
8577
|
-
|
|
8580
|
+
If(e, "delta list");
|
|
8578
8581
|
}
|
|
8579
|
-
function
|
|
8582
|
+
function If(e, t) {
|
|
8580
8583
|
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}.`);
|
|
8581
8584
|
}
|
|
8582
|
-
function
|
|
8583
|
-
let t =
|
|
8585
|
+
function Lf(e) {
|
|
8586
|
+
let t = Vf(e)?.error;
|
|
8584
8587
|
for (; t != null;) {
|
|
8585
|
-
let e =
|
|
8588
|
+
let e = Vf(t);
|
|
8586
8589
|
if (e == null) break;
|
|
8587
8590
|
if (e.code == "resyncChangesApplyDifferences" || e.code == "resyncChangesUploadDifferences") return !0;
|
|
8588
8591
|
t = e.innerError ?? e.innererror;
|
|
8589
8592
|
}
|
|
8590
8593
|
return !1;
|
|
8591
8594
|
}
|
|
8592
|
-
function
|
|
8593
|
-
let t =
|
|
8595
|
+
function Rf(e) {
|
|
8596
|
+
let t = zf(e);
|
|
8594
8597
|
if (t == null) throw new a("OneDrive delta link has no token.");
|
|
8595
8598
|
return t;
|
|
8596
8599
|
}
|
|
8597
|
-
function
|
|
8600
|
+
function zf(e) {
|
|
8598
8601
|
let t = /[?&]token=([^&#]+)/.exec(e)?.[1] ?? /\(token='([^']+)'\)/.exec(e)?.[1];
|
|
8599
8602
|
if (t == null) return null;
|
|
8600
8603
|
try {
|
|
@@ -8603,24 +8606,24 @@ function Rf(e) {
|
|
|
8603
8606
|
return t;
|
|
8604
8607
|
}
|
|
8605
8608
|
}
|
|
8606
|
-
function
|
|
8609
|
+
function Bf(e, t) {
|
|
8607
8610
|
if (e == null || e.length == 0) return !1;
|
|
8608
8611
|
let n = new Date(e);
|
|
8609
8612
|
return !Number.isNaN(n.getTime()) && n >= t;
|
|
8610
8613
|
}
|
|
8611
|
-
function
|
|
8614
|
+
function Vf(e) {
|
|
8612
8615
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
8613
8616
|
}
|
|
8614
8617
|
//#endregion
|
|
8615
8618
|
//#region src/trigger/providers/outlook/on-message-received.ts
|
|
8616
|
-
var
|
|
8619
|
+
var Hf = "inbox", Uf = 25, Wf = 100, Gf = "1970-01-01T00:00:00Z", Kf = "id,internetMessageId,conversationId,subject,bodyPreview,from,toRecipients,receivedDateTime,hasAttachments,isRead,isDraft,importance,categories,parentFolderId,webLink", qf = {
|
|
8617
8620
|
snapshot: {
|
|
8618
8621
|
configSchema: {
|
|
8619
8622
|
additionalProperties: !1,
|
|
8620
8623
|
description: "Configuration for outlook.on_message_received. Every configured matching field must match.",
|
|
8621
8624
|
properties: {
|
|
8622
8625
|
folder: {
|
|
8623
|
-
default:
|
|
8626
|
+
default: Hf,
|
|
8624
8627
|
description: "A well-known mail folder name, folder ID, or an empty string for the whole mailbox.",
|
|
8625
8628
|
pattern: "^[A-Za-z0-9_=-]*$",
|
|
8626
8629
|
type: "string"
|
|
@@ -8630,7 +8633,7 @@ var Vf = "inbox", Hf = 25, Uf = 100, Wf = "1970-01-01T00:00:00Z", Gf = "id,inter
|
|
|
8630
8633
|
type: "boolean"
|
|
8631
8634
|
},
|
|
8632
8635
|
maxMessagesPerPoll: {
|
|
8633
|
-
default:
|
|
8636
|
+
default: Uf,
|
|
8634
8637
|
maximum: 100,
|
|
8635
8638
|
minimum: 1,
|
|
8636
8639
|
type: "integer"
|
|
@@ -8726,37 +8729,37 @@ var Vf = "inbox", Hf = 25, Uf = 100, Wf = "1970-01-01T00:00:00Z", Gf = "id,inter
|
|
|
8726
8729
|
type: "poll"
|
|
8727
8730
|
},
|
|
8728
8731
|
async poll(e) {
|
|
8729
|
-
let t =
|
|
8732
|
+
let t = Jf(e.config);
|
|
8730
8733
|
if (e.checkpoint === null) return {
|
|
8731
|
-
checkpoint: await
|
|
8734
|
+
checkpoint: await Yf(e, t),
|
|
8732
8735
|
events: []
|
|
8733
8736
|
};
|
|
8734
|
-
let n =
|
|
8735
|
-
$filter:
|
|
8737
|
+
let n = Xf(e.checkpoint), i = await tp(e, Zf(t.folder), {
|
|
8738
|
+
$filter: Qf(t, n.lastReceivedDateTime),
|
|
8736
8739
|
$orderby: "receivedDateTime asc",
|
|
8737
|
-
$select:
|
|
8740
|
+
$select: Kf,
|
|
8738
8741
|
$top: t.maxMessagesPerPoll
|
|
8739
8742
|
});
|
|
8740
|
-
|
|
8741
|
-
let a =
|
|
8743
|
+
np(i, "message list");
|
|
8744
|
+
let a = ip(i.data);
|
|
8742
8745
|
if (a.length == 0) return {
|
|
8743
8746
|
checkpoint: n,
|
|
8744
8747
|
events: []
|
|
8745
8748
|
};
|
|
8746
8749
|
let o = Date.parse(n.lastReceivedDateTime), s = o, c = n.lastReceivedDateTime;
|
|
8747
8750
|
for (let e of a) {
|
|
8748
|
-
let t =
|
|
8751
|
+
let t = op(e.receivedDateTime);
|
|
8749
8752
|
e.receivedDateTime != null && t != null && t > s && (s = t, c = e.receivedDateTime);
|
|
8750
8753
|
}
|
|
8751
8754
|
let l = s > o, u = new Set(n.boundaryMessageIds), d = a.length >= t.maxMessagesPerPoll;
|
|
8752
8755
|
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.");
|
|
8753
8756
|
let f = new Set(l ? [] : n.boundaryMessageIds), p = [], m = 0;
|
|
8754
|
-
for (let e of a) if (e.id != null && e.id.length != 0 && (
|
|
8755
|
-
if (
|
|
8757
|
+
for (let e of a) if (e.id != null && e.id.length != 0 && (op(e.receivedDateTime) == s && f.add(e.id), !u.has(e.id))) {
|
|
8758
|
+
if (!$f(e, t)) {
|
|
8756
8759
|
m += 1;
|
|
8757
8760
|
continue;
|
|
8758
8761
|
}
|
|
8759
|
-
p.push(
|
|
8762
|
+
p.push(ep(e, e.id));
|
|
8760
8763
|
}
|
|
8761
8764
|
let ee = d && (l || p.length > 0);
|
|
8762
8765
|
return {
|
|
@@ -8770,34 +8773,34 @@ var Vf = "inbox", Hf = 25, Uf = 100, Wf = "1970-01-01T00:00:00Z", Gf = "id,inter
|
|
|
8770
8773
|
};
|
|
8771
8774
|
}
|
|
8772
8775
|
};
|
|
8773
|
-
function
|
|
8776
|
+
function Jf(e) {
|
|
8774
8777
|
return {
|
|
8775
|
-
folder: e.folder ??
|
|
8778
|
+
folder: e.folder ?? Hf,
|
|
8776
8779
|
includeDrafts: e.includeDrafts ?? !1,
|
|
8777
|
-
maxMessagesPerPoll: e.maxMessagesPerPoll ??
|
|
8780
|
+
maxMessagesPerPoll: e.maxMessagesPerPoll ?? Uf,
|
|
8778
8781
|
readStatus: e.readStatus ?? "All",
|
|
8779
8782
|
senderAddress: (e.senderAddress ?? "").trim(),
|
|
8780
8783
|
subjectContains: (e.subjectContains ?? "").trim(),
|
|
8781
8784
|
withAttachmentsOnly: e.withAttachmentsOnly ?? !1
|
|
8782
8785
|
};
|
|
8783
8786
|
}
|
|
8784
|
-
async function
|
|
8785
|
-
let n = await
|
|
8787
|
+
async function Yf(e, t) {
|
|
8788
|
+
let n = await tp(e, Zf(t.folder), {
|
|
8786
8789
|
$orderby: "receivedDateTime desc",
|
|
8787
8790
|
$select: "id,receivedDateTime",
|
|
8788
|
-
$top:
|
|
8791
|
+
$top: Wf
|
|
8789
8792
|
});
|
|
8790
|
-
|
|
8791
|
-
$filter:
|
|
8793
|
+
np(n, "seed marker fetch"), np(await tp(e, Zf(t.folder), {
|
|
8794
|
+
$filter: Qf(t, Gf),
|
|
8792
8795
|
$orderby: "receivedDateTime desc",
|
|
8793
8796
|
$top: 1
|
|
8794
8797
|
}), "seed filter shape check");
|
|
8795
|
-
let r = ip(
|
|
8798
|
+
let r = ap(ip(n.data));
|
|
8796
8799
|
if (r == null) return {
|
|
8797
8800
|
boundaryMessageIds: [],
|
|
8798
8801
|
lastReceivedDateTime: e.now.toISOString()
|
|
8799
8802
|
};
|
|
8800
|
-
let i =
|
|
8803
|
+
let i = ip(n.data).filter((e) => op(e.receivedDateTime) == r.ms);
|
|
8801
8804
|
return i.length >= t.maxMessagesPerPoll ? {
|
|
8802
8805
|
boundaryMessageIds: [],
|
|
8803
8806
|
lastReceivedDateTime: new Date(r.ms + 1e3).toISOString()
|
|
@@ -8806,26 +8809,26 @@ async function Jf(e, t) {
|
|
|
8806
8809
|
lastReceivedDateTime: r.iso
|
|
8807
8810
|
};
|
|
8808
8811
|
}
|
|
8809
|
-
function
|
|
8810
|
-
let t =
|
|
8811
|
-
if (typeof n != "string" ||
|
|
8812
|
+
function Xf(e) {
|
|
8813
|
+
let t = sp(e), n = t?.lastReceivedDateTime;
|
|
8814
|
+
if (typeof n != "string" || op(n) == null) throw new r("Outlook checkpoint is invalid; recreate the Trigger.");
|
|
8812
8815
|
let i = t?.boundaryMessageIds;
|
|
8813
8816
|
return {
|
|
8814
8817
|
boundaryMessageIds: Array.isArray(i) ? i.filter((e) => typeof e == "string" && e.length > 0) : [],
|
|
8815
8818
|
lastReceivedDateTime: n
|
|
8816
8819
|
};
|
|
8817
8820
|
}
|
|
8818
|
-
function
|
|
8821
|
+
function Zf(e) {
|
|
8819
8822
|
return e.length == 0 ? "/me/messages" : `/me/mailFolders/${encodeURIComponent(e)}/messages`;
|
|
8820
8823
|
}
|
|
8821
|
-
function
|
|
8824
|
+
function Qf(e, t) {
|
|
8822
8825
|
let n = [`receivedDateTime ge ${t}`];
|
|
8823
8826
|
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 ");
|
|
8824
8827
|
}
|
|
8825
|
-
function
|
|
8828
|
+
function $f(e, t) {
|
|
8826
8829
|
return e.isDraft === !0 && !t.includeDrafts ? !1 : t.subjectContains.length == 0 || (e.subject ?? "").toLowerCase().includes(t.subjectContains.toLowerCase());
|
|
8827
8830
|
}
|
|
8828
|
-
function
|
|
8831
|
+
function ep(e, t) {
|
|
8829
8832
|
return {
|
|
8830
8833
|
dedupeKey: t,
|
|
8831
8834
|
payload: {
|
|
@@ -8848,7 +8851,7 @@ function $f(e, t) {
|
|
|
8848
8851
|
}
|
|
8849
8852
|
};
|
|
8850
8853
|
}
|
|
8851
|
-
async function
|
|
8854
|
+
async function tp(e, t, n) {
|
|
8852
8855
|
try {
|
|
8853
8856
|
return await e.connector.execute({
|
|
8854
8857
|
endpoint: t,
|
|
@@ -8860,28 +8863,28 @@ async function ep(e, t, n) {
|
|
|
8860
8863
|
throw new a(`Outlook proxy request to ${t} failed.`, { cause: e });
|
|
8861
8864
|
}
|
|
8862
8865
|
}
|
|
8863
|
-
function
|
|
8866
|
+
function np(e, t) {
|
|
8864
8867
|
if (e.status >= 200 && e.status < 300) return;
|
|
8865
|
-
let n =
|
|
8868
|
+
let n = rp(e.data);
|
|
8866
8869
|
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}.`);
|
|
8867
8870
|
}
|
|
8868
|
-
function
|
|
8869
|
-
let t = /* @__PURE__ */ new Set(), n =
|
|
8871
|
+
function rp(e) {
|
|
8872
|
+
let t = /* @__PURE__ */ new Set(), n = sp(e)?.error;
|
|
8870
8873
|
for (let e = 0; e < 4; e += 1) {
|
|
8871
|
-
let e =
|
|
8874
|
+
let e = sp(n);
|
|
8872
8875
|
if (e == null) break;
|
|
8873
8876
|
typeof e.code == "string" && e.code.length > 0 && t.add(e.code.toLowerCase()), n = e.innerError ?? e.innererror;
|
|
8874
8877
|
}
|
|
8875
8878
|
return t;
|
|
8876
8879
|
}
|
|
8877
|
-
function
|
|
8878
|
-
let t =
|
|
8880
|
+
function ip(e) {
|
|
8881
|
+
let t = sp(e)?.value;
|
|
8879
8882
|
return Array.isArray(t) ? t : [];
|
|
8880
8883
|
}
|
|
8881
|
-
function
|
|
8884
|
+
function ap(e) {
|
|
8882
8885
|
let t = null;
|
|
8883
8886
|
for (let n of e) {
|
|
8884
|
-
let e =
|
|
8887
|
+
let e = op(n.receivedDateTime);
|
|
8885
8888
|
n.receivedDateTime != null && e != null && (t == null || e > t.ms) && (t = {
|
|
8886
8889
|
iso: n.receivedDateTime,
|
|
8887
8890
|
ms: e
|
|
@@ -8889,15 +8892,15 @@ function ip(e) {
|
|
|
8889
8892
|
}
|
|
8890
8893
|
return t;
|
|
8891
8894
|
}
|
|
8892
|
-
function
|
|
8895
|
+
function op(e) {
|
|
8893
8896
|
if (e == null || e.length == 0) return null;
|
|
8894
8897
|
let t = Date.parse(e);
|
|
8895
8898
|
return Number.isNaN(t) ? null : t;
|
|
8896
8899
|
}
|
|
8897
|
-
function
|
|
8900
|
+
function sp(e) {
|
|
8898
8901
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
8899
8902
|
}
|
|
8900
|
-
var
|
|
8903
|
+
var cp = {
|
|
8901
8904
|
initialState: {
|
|
8902
8905
|
checkpoint: null,
|
|
8903
8906
|
subscription: {}
|
|
@@ -8971,7 +8974,7 @@ var sp = {
|
|
|
8971
8974
|
outcome: "ignored",
|
|
8972
8975
|
reason: "Shopify topic header is missing."
|
|
8973
8976
|
};
|
|
8974
|
-
if (!
|
|
8977
|
+
if (!lp(e.config).includes(t)) return {
|
|
8975
8978
|
outcome: "ignored",
|
|
8976
8979
|
reason: "Shopify topic is not subscribed."
|
|
8977
8980
|
};
|
|
@@ -8991,39 +8994,39 @@ var sp = {
|
|
|
8991
8994
|
};
|
|
8992
8995
|
},
|
|
8993
8996
|
async reconcile(e) {
|
|
8994
|
-
let n =
|
|
8997
|
+
let n = _p(e.state), r = await dp(e);
|
|
8995
8998
|
if (r == null) {
|
|
8996
8999
|
if (!e.active) return { outcome: "ready" };
|
|
8997
9000
|
throw new t("The Shopify store or webhook resource is unavailable.");
|
|
8998
9001
|
}
|
|
8999
9002
|
if (!e.active) {
|
|
9000
|
-
for (let t of r.values()) await
|
|
9001
|
-
return await n.saveSubscription({},
|
|
9003
|
+
for (let t of r.values()) await pp(e, t);
|
|
9004
|
+
return await n.saveSubscription({}, vp(e.now)), { outcome: "ready" };
|
|
9002
9005
|
}
|
|
9003
|
-
let i =
|
|
9006
|
+
let i = lp(e.config), a = [], o = [];
|
|
9004
9007
|
try {
|
|
9005
9008
|
for (let t of i) {
|
|
9006
9009
|
let n = r.get(t);
|
|
9007
9010
|
if (n != null) a.push(n);
|
|
9008
9011
|
else {
|
|
9009
|
-
let n = await
|
|
9012
|
+
let n = await up(e, t);
|
|
9010
9013
|
a.push(n.id), n.created && o.push(n.id);
|
|
9011
9014
|
}
|
|
9012
9015
|
}
|
|
9013
9016
|
} catch (t) {
|
|
9014
|
-
throw await Promise.allSettled(o.map((t) =>
|
|
9017
|
+
throw await Promise.allSettled(o.map((t) => pp(e, t))), t;
|
|
9015
9018
|
}
|
|
9016
|
-
for (let [t, n] of r) i.includes(t) || await
|
|
9017
|
-
return await n.saveSubscription({ webhookIds: a },
|
|
9019
|
+
for (let [t, n] of r) i.includes(t) || await pp(e, n);
|
|
9020
|
+
return await n.saveSubscription({ webhookIds: a }, vp(e.now)), { outcome: "ready" };
|
|
9018
9021
|
}
|
|
9019
9022
|
};
|
|
9020
|
-
function
|
|
9023
|
+
function lp(e) {
|
|
9021
9024
|
return [...new Set(e.topics)];
|
|
9022
9025
|
}
|
|
9023
|
-
async function
|
|
9024
|
-
let r = await
|
|
9026
|
+
async function up(e, t) {
|
|
9027
|
+
let r = await mp(e, "subscription create", {
|
|
9025
9028
|
body: { webhook: {
|
|
9026
|
-
address:
|
|
9029
|
+
address: fp(e),
|
|
9027
9030
|
format: "json",
|
|
9028
9031
|
topic: t
|
|
9029
9032
|
} },
|
|
@@ -9031,22 +9034,22 @@ async function lp(e, t) {
|
|
|
9031
9034
|
method: "POST"
|
|
9032
9035
|
});
|
|
9033
9036
|
if (r.status == 422) {
|
|
9034
|
-
let n = (await
|
|
9037
|
+
let n = (await dp(e))?.get(t);
|
|
9035
9038
|
if (n != null) return {
|
|
9036
9039
|
created: !1,
|
|
9037
9040
|
id: n
|
|
9038
9041
|
};
|
|
9039
9042
|
}
|
|
9040
|
-
|
|
9041
|
-
let i =
|
|
9043
|
+
hp(r, "subscription create");
|
|
9044
|
+
let i = gp(yp(yp(r.data)?.webhook)?.id);
|
|
9042
9045
|
if (i == null) throw new n("Shopify subscription response is missing its ID.");
|
|
9043
9046
|
return {
|
|
9044
9047
|
created: !0,
|
|
9045
9048
|
id: i
|
|
9046
9049
|
};
|
|
9047
9050
|
}
|
|
9048
|
-
async function
|
|
9049
|
-
let t =
|
|
9051
|
+
async function dp(e) {
|
|
9052
|
+
let t = fp(e), n = await mp(e, "subscription list", {
|
|
9050
9053
|
endpoint: "/webhooks.json",
|
|
9051
9054
|
method: "GET",
|
|
9052
9055
|
query: {
|
|
@@ -9055,34 +9058,34 @@ async function up(e) {
|
|
|
9055
9058
|
}
|
|
9056
9059
|
});
|
|
9057
9060
|
if (n.status == 404) return null;
|
|
9058
|
-
|
|
9059
|
-
let r =
|
|
9061
|
+
hp(n, "subscription list");
|
|
9062
|
+
let r = yp(n.data)?.webhooks, i = /* @__PURE__ */ new Map();
|
|
9060
9063
|
if (!Array.isArray(r)) return i;
|
|
9061
9064
|
for (let e of r) {
|
|
9062
|
-
let n =
|
|
9065
|
+
let n = yp(e), r = gp(n?.id);
|
|
9063
9066
|
n?.address === t && typeof n.topic == "string" && r != null && i.set(n.topic, r);
|
|
9064
9067
|
}
|
|
9065
9068
|
return i;
|
|
9066
9069
|
}
|
|
9067
|
-
function
|
|
9070
|
+
function fp(e) {
|
|
9068
9071
|
let t = new URL(e.endpointUrl);
|
|
9069
9072
|
return t.searchParams.set("open_flow_callback", e.callbackSecret), t.href;
|
|
9070
9073
|
}
|
|
9071
|
-
async function
|
|
9072
|
-
let n = await
|
|
9074
|
+
async function pp(e, t) {
|
|
9075
|
+
let n = await mp(e, "subscription delete", {
|
|
9073
9076
|
endpoint: `/webhooks/${encodeURIComponent(t)}.json`,
|
|
9074
9077
|
method: "DELETE"
|
|
9075
9078
|
});
|
|
9076
|
-
n.status != 404 &&
|
|
9079
|
+
n.status != 404 && hp(n, "subscription delete");
|
|
9077
9080
|
}
|
|
9078
|
-
async function
|
|
9081
|
+
async function mp(t, r, i) {
|
|
9079
9082
|
try {
|
|
9080
9083
|
return await t.connector.execute(i, t.signal);
|
|
9081
9084
|
} catch (t) {
|
|
9082
9085
|
throw t instanceof e ? t : new n(`Shopify ${r} request failed.`, { cause: t });
|
|
9083
9086
|
}
|
|
9084
9087
|
}
|
|
9085
|
-
function
|
|
9088
|
+
function hp(r, i) {
|
|
9086
9089
|
if (!(r.status >= 200 && r.status < 300)) throw r.status == 401 || r.status == 403 ? new e(`Shopify ${i} rejected the Connection.`) : [
|
|
9087
9090
|
402,
|
|
9088
9091
|
404,
|
|
@@ -9091,34 +9094,34 @@ function mp(r, i) {
|
|
|
9091
9094
|
501
|
|
9092
9095
|
].includes(r.status) ? new t(`Shopify ${i} rejected the subscription.`) : new n(`Shopify ${i} failed with status ${r.status}.`);
|
|
9093
9096
|
}
|
|
9094
|
-
function
|
|
9097
|
+
function gp(e) {
|
|
9095
9098
|
return typeof e == "string" ? e.trim().length == 0 ? null : e : typeof e == "number" && Number.isFinite(e) ? String(e) : null;
|
|
9096
9099
|
}
|
|
9097
|
-
function
|
|
9100
|
+
function _p(e) {
|
|
9098
9101
|
if (e == null) throw new t("Shopify Integration state is missing.");
|
|
9099
9102
|
return e;
|
|
9100
9103
|
}
|
|
9101
|
-
function
|
|
9104
|
+
function vp(e) {
|
|
9102
9105
|
return new Date(e.getTime() + 2592e6);
|
|
9103
9106
|
}
|
|
9104
|
-
function
|
|
9107
|
+
function yp(e) {
|
|
9105
9108
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
9106
9109
|
}
|
|
9107
9110
|
//#endregion
|
|
9108
9111
|
//#region src/trigger/providers/slack/on-message-posted.ts
|
|
9109
|
-
var
|
|
9112
|
+
var bp = 15, xp = 6e4, Sp = /* @__PURE__ */ new Set([
|
|
9110
9113
|
"file_share",
|
|
9111
9114
|
"thread_broadcast",
|
|
9112
9115
|
"me_message",
|
|
9113
9116
|
"bot_message"
|
|
9114
|
-
]),
|
|
9117
|
+
]), Cp = /* @__PURE__ */ new Set([
|
|
9115
9118
|
"invalid_auth",
|
|
9116
9119
|
"not_authed",
|
|
9117
9120
|
"token_revoked",
|
|
9118
9121
|
"token_expired",
|
|
9119
9122
|
"account_inactive",
|
|
9120
9123
|
"two_factor_setup_required"
|
|
9121
|
-
]),
|
|
9124
|
+
]), wp = /* @__PURE__ */ new Set([
|
|
9122
9125
|
"channel_not_found",
|
|
9123
9126
|
"not_in_channel",
|
|
9124
9127
|
"missing_scope",
|
|
@@ -9134,7 +9137,7 @@ var yp = 15, bp = 6e4, xp = /* @__PURE__ */ new Set([
|
|
|
9134
9137
|
"method_deprecated",
|
|
9135
9138
|
"deprecated_endpoint",
|
|
9136
9139
|
"accesslimited"
|
|
9137
|
-
]),
|
|
9140
|
+
]), Tp = {
|
|
9138
9141
|
snapshot: {
|
|
9139
9142
|
configSchema: {
|
|
9140
9143
|
additionalProperties: !1,
|
|
@@ -9174,7 +9177,7 @@ var yp = 15, bp = 6e4, xp = /* @__PURE__ */ new Set([
|
|
|
9174
9177
|
type: "boolean"
|
|
9175
9178
|
},
|
|
9176
9179
|
maxMessagesPerPoll: {
|
|
9177
|
-
default:
|
|
9180
|
+
default: bp,
|
|
9178
9181
|
description: "Maximum number of messages processed per poll.",
|
|
9179
9182
|
maximum: 100,
|
|
9180
9183
|
minimum: 1,
|
|
@@ -9248,47 +9251,47 @@ var yp = 15, bp = 6e4, xp = /* @__PURE__ */ new Set([
|
|
|
9248
9251
|
type: "poll"
|
|
9249
9252
|
},
|
|
9250
9253
|
async poll(e) {
|
|
9251
|
-
let t =
|
|
9254
|
+
let t = Ep(e.config);
|
|
9252
9255
|
if (e.checkpoint === null) return {
|
|
9253
|
-
checkpoint: { lastTs: await
|
|
9256
|
+
checkpoint: { lastTs: await Dp(e, t.channelId) },
|
|
9254
9257
|
events: []
|
|
9255
9258
|
};
|
|
9256
|
-
let n =
|
|
9259
|
+
let n = Op(e.checkpoint), r = await kp(e, t, n), i = Mp(r), a = [], o = 0;
|
|
9257
9260
|
for (let e of i.toReversed()) {
|
|
9258
|
-
if (!
|
|
9261
|
+
if (!Pp(e.message, t)) {
|
|
9259
9262
|
o += 1;
|
|
9260
9263
|
continue;
|
|
9261
9264
|
}
|
|
9262
|
-
a.push(
|
|
9265
|
+
a.push(Fp(e, t.channelId));
|
|
9263
9266
|
}
|
|
9264
9267
|
return {
|
|
9265
|
-
checkpoint:
|
|
9268
|
+
checkpoint: Np(n, r, i),
|
|
9266
9269
|
events: a,
|
|
9267
9270
|
filtered: o
|
|
9268
9271
|
};
|
|
9269
9272
|
}
|
|
9270
9273
|
};
|
|
9271
|
-
function
|
|
9274
|
+
function Ep(e) {
|
|
9272
9275
|
return {
|
|
9273
9276
|
channelId: e.channelId,
|
|
9274
9277
|
fromUserIds: e.fromUserIds ?? [],
|
|
9275
9278
|
ignoreUserIds: e.ignoreUserIds ?? [],
|
|
9276
9279
|
includeBotMessages: e.includeBotMessages ?? !1,
|
|
9277
9280
|
includeSystemMessages: e.includeSystemMessages ?? !1,
|
|
9278
|
-
maxMessagesPerPoll: e.maxMessagesPerPoll ??
|
|
9281
|
+
maxMessagesPerPoll: e.maxMessagesPerPoll ?? bp,
|
|
9279
9282
|
textContains: e.textContains ?? ""
|
|
9280
9283
|
};
|
|
9281
9284
|
}
|
|
9282
|
-
async function
|
|
9283
|
-
let n = await
|
|
9285
|
+
async function Dp(e, t) {
|
|
9286
|
+
let n = await Ap(e, {
|
|
9284
9287
|
channel: t,
|
|
9285
9288
|
limit: 1
|
|
9286
9289
|
});
|
|
9287
|
-
|
|
9290
|
+
jp(n, "baseline history fetch");
|
|
9288
9291
|
let r = n.data.messages?.[0]?.ts;
|
|
9289
|
-
return r != null &&
|
|
9292
|
+
return r != null && Ip(r) ? r : `${Math.floor((e.now.getTime() - xp) / 1e3)}.000000`;
|
|
9290
9293
|
}
|
|
9291
|
-
function
|
|
9294
|
+
function Op(e) {
|
|
9292
9295
|
let t = e;
|
|
9293
9296
|
if (typeof t.lastTs != "string" || t.lastTs.length == 0) throw new r("Slack checkpoint lastTs is missing.");
|
|
9294
9297
|
let n = t.drainLatest, i = t.pendingHighTs;
|
|
@@ -9300,17 +9303,17 @@ function Dp(e) {
|
|
|
9300
9303
|
pendingHighTs: i
|
|
9301
9304
|
};
|
|
9302
9305
|
}
|
|
9303
|
-
async function
|
|
9304
|
-
let r = await
|
|
9306
|
+
async function kp(e, t, n) {
|
|
9307
|
+
let r = await Ap(e, {
|
|
9305
9308
|
channel: t.channelId,
|
|
9306
9309
|
inclusive: "false",
|
|
9307
9310
|
latest: n.drainLatest,
|
|
9308
9311
|
limit: t.maxMessagesPerPoll,
|
|
9309
9312
|
oldest: n.lastTs
|
|
9310
9313
|
});
|
|
9311
|
-
return
|
|
9314
|
+
return jp(r, "history list"), r.data;
|
|
9312
9315
|
}
|
|
9313
|
-
async function
|
|
9316
|
+
async function Ap(e, t) {
|
|
9314
9317
|
try {
|
|
9315
9318
|
return await e.connector.execute({
|
|
9316
9319
|
endpoint: "/conversations.history",
|
|
@@ -9321,19 +9324,19 @@ async function kp(e, t) {
|
|
|
9321
9324
|
throw new a("Slack proxy request failed.", { cause: e });
|
|
9322
9325
|
}
|
|
9323
9326
|
}
|
|
9324
|
-
function
|
|
9327
|
+
function jp(e, t) {
|
|
9325
9328
|
let n = e.data;
|
|
9326
9329
|
if (e.status >= 200 && e.status < 300 && n.ok === !0) return;
|
|
9327
9330
|
let o = typeof n.error == "string" ? n.error : "";
|
|
9328
|
-
throw
|
|
9331
|
+
throw Cp.has(o) ? new i(`Slack ${t} rejected with ${o}.`) : wp.has(o) ? new r(`Slack ${t} rejected with ${o}.`) : new a(`Slack ${t} failed with ${o || `status ${e.status}`}.`);
|
|
9329
9332
|
}
|
|
9330
|
-
function
|
|
9331
|
-
return (e.messages ?? []).flatMap((e) => e.ts != null &&
|
|
9333
|
+
function Mp(e) {
|
|
9334
|
+
return (e.messages ?? []).flatMap((e) => e.ts != null && Ip(e.ts) ? [{
|
|
9332
9335
|
message: e,
|
|
9333
9336
|
ts: e.ts
|
|
9334
9337
|
}] : []);
|
|
9335
9338
|
}
|
|
9336
|
-
function
|
|
9339
|
+
function Np(e, t, n) {
|
|
9337
9340
|
let r = n[0]?.ts, i = n.at(-1)?.ts;
|
|
9338
9341
|
if (t.has_more === !0) {
|
|
9339
9342
|
if (r == null || i == null) throw new a("Slack history reports has_more without a usable timestamp.");
|
|
@@ -9345,10 +9348,10 @@ function Mp(e, t, n) {
|
|
|
9345
9348
|
}
|
|
9346
9349
|
return e.pendingHighTs == null ? { lastTs: r ?? e.lastTs } : { lastTs: e.pendingHighTs };
|
|
9347
9350
|
}
|
|
9348
|
-
function Np(e, t) {
|
|
9349
|
-
return !t.includeBotMessages && (e.bot_id != null || e.subtype == "bot_message") || !t.includeSystemMessages && e.subtype != null && !xp.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());
|
|
9350
|
-
}
|
|
9351
9351
|
function Pp(e, t) {
|
|
9352
|
+
return !t.includeBotMessages && (e.bot_id != null || e.subtype == "bot_message") || !t.includeSystemMessages && e.subtype != null && !Sp.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());
|
|
9353
|
+
}
|
|
9354
|
+
function Fp(e, t) {
|
|
9352
9355
|
return {
|
|
9353
9356
|
dedupeKey: `${t}:${e.ts}`,
|
|
9354
9357
|
payload: {
|
|
@@ -9367,12 +9370,12 @@ function Pp(e, t) {
|
|
|
9367
9370
|
}
|
|
9368
9371
|
};
|
|
9369
9372
|
}
|
|
9370
|
-
function
|
|
9373
|
+
function Ip(e) {
|
|
9371
9374
|
return /^\d+(?:\.\d+)?$/.test(e) && !Number.isNaN(new Date(Math.round(Number(e) * 1e3)).getTime());
|
|
9372
9375
|
}
|
|
9373
9376
|
//#endregion
|
|
9374
9377
|
//#region src/trigger/providers/stripe/on-event.ts
|
|
9375
|
-
var
|
|
9378
|
+
var Lp = 300, Rp = "/v1/webhook_endpoints", zp = { "Content-Type": "application/x-www-form-urlencoded" }, Bp = {
|
|
9376
9379
|
initialState: {
|
|
9377
9380
|
checkpoint: null,
|
|
9378
9381
|
subscription: {}
|
|
@@ -9440,8 +9443,8 @@ var Ip = 300, Lp = "/v1/webhook_endpoints", Rp = { "Content-Type": "application/
|
|
|
9440
9443
|
type: "integration"
|
|
9441
9444
|
},
|
|
9442
9445
|
async receive(e) {
|
|
9443
|
-
let t =
|
|
9444
|
-
if (t == null || !await
|
|
9446
|
+
let t = Xp(e.state);
|
|
9447
|
+
if (t == null || !await Zp(e.header("stripe-signature"), t, e.rawBody, e.now)) return {
|
|
9445
9448
|
body: "",
|
|
9446
9449
|
contentType: "text/plain",
|
|
9447
9450
|
outcome: "respond",
|
|
@@ -9456,7 +9459,7 @@ var Ip = 300, Lp = "/v1/webhook_endpoints", Rp = { "Content-Type": "application/
|
|
|
9456
9459
|
outcome: "ignored",
|
|
9457
9460
|
reason: "Stripe event identity is missing."
|
|
9458
9461
|
};
|
|
9459
|
-
let a =
|
|
9462
|
+
let a = Vp(e.config);
|
|
9460
9463
|
return !a.events.includes("*") && !a.events.includes(r) ? {
|
|
9461
9464
|
outcome: "ignored",
|
|
9462
9465
|
reason: "Stripe event is not subscribed."
|
|
@@ -9472,156 +9475,156 @@ var Ip = 300, Lp = "/v1/webhook_endpoints", Rp = { "Content-Type": "application/
|
|
|
9472
9475
|
};
|
|
9473
9476
|
},
|
|
9474
9477
|
async reconcile(e) {
|
|
9475
|
-
let t =
|
|
9478
|
+
let t = Jp(e.state), n = Vp(e.config), r = Yp(t), i = Xp(t);
|
|
9476
9479
|
if (!e.active) {
|
|
9477
|
-
if (r ??= await
|
|
9478
|
-
let t = await
|
|
9479
|
-
endpoint: `${
|
|
9480
|
+
if (r ??= await Wp(e), r != null) {
|
|
9481
|
+
let t = await Gp(e, "endpoint delete", {
|
|
9482
|
+
endpoint: `${Rp}/${r}`,
|
|
9480
9483
|
method: "DELETE"
|
|
9481
9484
|
});
|
|
9482
|
-
t.status != 404 &&
|
|
9485
|
+
t.status != 404 && Kp(t, "endpoint delete");
|
|
9483
9486
|
}
|
|
9484
|
-
return await t.saveSubscription({},
|
|
9487
|
+
return await t.saveSubscription({}, Qp(e.now)), { outcome: "ready" };
|
|
9485
9488
|
}
|
|
9486
|
-
if (r ??= await
|
|
9487
|
-
let t = await
|
|
9488
|
-
endpoint: `${
|
|
9489
|
+
if (r ??= await Wp(e), r != null && i == null) {
|
|
9490
|
+
let t = await Gp(e, "endpoint delete", {
|
|
9491
|
+
endpoint: `${Rp}/${r}`,
|
|
9489
9492
|
method: "DELETE"
|
|
9490
9493
|
});
|
|
9491
|
-
t.status != 404 &&
|
|
9494
|
+
t.status != 404 && Kp(t, "endpoint delete"), r = null;
|
|
9492
9495
|
}
|
|
9493
9496
|
if (r == null) {
|
|
9494
|
-
let t = await
|
|
9495
|
-
body:
|
|
9496
|
-
endpoint:
|
|
9497
|
+
let t = await Gp(e, "endpoint create", {
|
|
9498
|
+
body: Hp(e.endpointUrl, n),
|
|
9499
|
+
endpoint: Rp,
|
|
9497
9500
|
headers: {
|
|
9498
|
-
...
|
|
9501
|
+
...zp,
|
|
9499
9502
|
"Idempotency-Key": e.idempotencyKey
|
|
9500
9503
|
},
|
|
9501
9504
|
method: "POST"
|
|
9502
9505
|
});
|
|
9503
|
-
|
|
9504
|
-
let a =
|
|
9506
|
+
Kp(t, "endpoint create");
|
|
9507
|
+
let a = qp(t.data);
|
|
9505
9508
|
r = a.id, i = a.secret;
|
|
9506
9509
|
}
|
|
9507
|
-
let a = await
|
|
9508
|
-
body:
|
|
9510
|
+
let a = await Gp(e, "endpoint update", {
|
|
9511
|
+
body: Up([
|
|
9509
9512
|
...n.events.map((e, t) => [`enabled_events[${t}]`, e]),
|
|
9510
9513
|
["disabled", "false"],
|
|
9511
9514
|
["description", "Managed by Open Flow."]
|
|
9512
9515
|
]),
|
|
9513
|
-
endpoint: `${
|
|
9514
|
-
headers:
|
|
9516
|
+
endpoint: `${Rp}/${r}`,
|
|
9517
|
+
headers: zp,
|
|
9515
9518
|
method: "POST"
|
|
9516
9519
|
});
|
|
9517
|
-
return a.status == 404 ? (await t.saveSubscription({}, e.now), { outcome: "pending" }) : (
|
|
9520
|
+
return a.status == 404 ? (await t.saveSubscription({}, e.now), { outcome: "pending" }) : (Kp(a, "endpoint update"), await t.saveSubscription({
|
|
9518
9521
|
endpointId: r,
|
|
9519
9522
|
signingSecret: i
|
|
9520
|
-
},
|
|
9523
|
+
}, Qp(e.now)), { outcome: "ready" });
|
|
9521
9524
|
}
|
|
9522
9525
|
};
|
|
9523
|
-
function
|
|
9526
|
+
function Vp(e) {
|
|
9524
9527
|
return {
|
|
9525
9528
|
apiVersion: e.apiVersion ?? "",
|
|
9526
9529
|
events: [...new Set(e.events)],
|
|
9527
9530
|
includeConnectedAccounts: e.includeConnectedAccounts ?? !1
|
|
9528
9531
|
};
|
|
9529
9532
|
}
|
|
9530
|
-
function
|
|
9533
|
+
function Hp(e, t) {
|
|
9531
9534
|
let n = [
|
|
9532
9535
|
["url", e],
|
|
9533
9536
|
...t.events.map((e, t) => [`enabled_events[${t}]`, e]),
|
|
9534
9537
|
["description", "Managed by Open Flow."]
|
|
9535
9538
|
];
|
|
9536
|
-
return t.includeConnectedAccounts && n.push(["connect", "true"]), t.apiVersion.length > 0 && n.push(["api_version", t.apiVersion]),
|
|
9539
|
+
return t.includeConnectedAccounts && n.push(["connect", "true"]), t.apiVersion.length > 0 && n.push(["api_version", t.apiVersion]), Up(n);
|
|
9537
9540
|
}
|
|
9538
|
-
function
|
|
9541
|
+
function Up(e) {
|
|
9539
9542
|
let t = new URLSearchParams();
|
|
9540
9543
|
for (let [n, r] of e) t.append(n, r);
|
|
9541
9544
|
return t.toString();
|
|
9542
9545
|
}
|
|
9543
|
-
async function
|
|
9546
|
+
async function Wp(e) {
|
|
9544
9547
|
let t;
|
|
9545
9548
|
for (let n = 0; n < 10; n += 1) {
|
|
9546
|
-
let n = await
|
|
9547
|
-
endpoint:
|
|
9549
|
+
let n = await Gp(e, "endpoint list", {
|
|
9550
|
+
endpoint: Rp,
|
|
9548
9551
|
method: "GET",
|
|
9549
9552
|
query: {
|
|
9550
9553
|
limit: 100,
|
|
9551
9554
|
...t == null ? {} : { starting_after: t }
|
|
9552
9555
|
}
|
|
9553
9556
|
});
|
|
9554
|
-
|
|
9555
|
-
let r =
|
|
9557
|
+
Kp(n, "endpoint list");
|
|
9558
|
+
let r = $p(n.data), i = Array.isArray(r?.data) ? r.data : [];
|
|
9556
9559
|
for (let t of i) {
|
|
9557
|
-
let n =
|
|
9560
|
+
let n = $p(t);
|
|
9558
9561
|
if (n?.url === e.endpointUrl && typeof n.id == "string") return n.id;
|
|
9559
9562
|
}
|
|
9560
|
-
let a =
|
|
9563
|
+
let a = $p(i.at(-1))?.id;
|
|
9561
9564
|
if (r?.has_more !== !0 || typeof a != "string") return null;
|
|
9562
9565
|
t = a;
|
|
9563
9566
|
}
|
|
9564
9567
|
return null;
|
|
9565
9568
|
}
|
|
9566
|
-
async function
|
|
9569
|
+
async function Gp(t, r, i) {
|
|
9567
9570
|
try {
|
|
9568
9571
|
return await t.connector.execute(i, t.signal);
|
|
9569
9572
|
} catch (t) {
|
|
9570
9573
|
throw t instanceof e ? t : new n(`Stripe ${r} request failed.`, { cause: t });
|
|
9571
9574
|
}
|
|
9572
9575
|
}
|
|
9573
|
-
function
|
|
9576
|
+
function Kp(r, i) {
|
|
9574
9577
|
if (!(r.status >= 200 && r.status < 300)) {
|
|
9575
9578
|
if (r.status == 401 || r.status == 403) throw new e(`Stripe ${i} rejected the Connection.`);
|
|
9576
9579
|
if (r.status == 400 || r.status == 404) {
|
|
9577
|
-
let e =
|
|
9580
|
+
let e = $p($p(r.data)?.error)?.message;
|
|
9578
9581
|
throw new t(`Stripe ${i} rejected the subscription${typeof e == "string" ? `: ${e}` : "."}`);
|
|
9579
9582
|
}
|
|
9580
9583
|
throw new n(`Stripe ${i} failed with status ${r.status}.`);
|
|
9581
9584
|
}
|
|
9582
9585
|
}
|
|
9583
|
-
function
|
|
9584
|
-
let t =
|
|
9586
|
+
function qp(e) {
|
|
9587
|
+
let t = $p(e);
|
|
9585
9588
|
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.");
|
|
9586
9589
|
return {
|
|
9587
9590
|
id: t.id,
|
|
9588
9591
|
secret: t.secret
|
|
9589
9592
|
};
|
|
9590
9593
|
}
|
|
9591
|
-
function
|
|
9594
|
+
function Jp(e) {
|
|
9592
9595
|
if (e == null) throw new t("Stripe Integration state is missing.");
|
|
9593
9596
|
return e;
|
|
9594
9597
|
}
|
|
9595
|
-
function
|
|
9598
|
+
function Yp(e) {
|
|
9596
9599
|
let t = e.subscription.endpointId;
|
|
9597
9600
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
9598
9601
|
}
|
|
9599
|
-
function
|
|
9602
|
+
function Xp(e) {
|
|
9600
9603
|
let t = e?.subscription.signingSecret;
|
|
9601
9604
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
9602
9605
|
}
|
|
9603
|
-
async function
|
|
9606
|
+
async function Zp(e, t, n, r) {
|
|
9604
9607
|
if (e == null) return !1;
|
|
9605
9608
|
let i = e.split(",").map((e) => e.trim().split("=", 2)), a = i.find(([e]) => e == "t")?.[1];
|
|
9606
9609
|
if (a == null || !/^\d+$/.test(a)) return !1;
|
|
9607
9610
|
let o = Number(a);
|
|
9608
|
-
if (!Number.isSafeInteger(o) || Math.abs(Math.floor(r.getTime() / 1e3) - o) >
|
|
9611
|
+
if (!Number.isSafeInteger(o) || Math.abs(Math.floor(r.getTime() / 1e3) - o) > Lp) return !1;
|
|
9609
9612
|
let s = i.filter(([e, t]) => e == "v1" && t != null).map(([, e]) => e), c = [we(`${a}.`), n];
|
|
9610
9613
|
return (await Promise.all(s.map((e) => De(t, c, e)))).some(Boolean);
|
|
9611
9614
|
}
|
|
9612
|
-
function
|
|
9615
|
+
function Qp(e) {
|
|
9613
9616
|
return new Date(e.getTime() + 2592e6);
|
|
9614
9617
|
}
|
|
9615
|
-
function
|
|
9618
|
+
function $p(e) {
|
|
9616
9619
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
9617
9620
|
}
|
|
9618
9621
|
//#endregion
|
|
9619
9622
|
//#region src/trigger/providers/telegram/on-update.ts
|
|
9620
|
-
var
|
|
9623
|
+
var em = /* @__PURE__ */ new Set([
|
|
9621
9624
|
"chat_member",
|
|
9622
9625
|
"message_reaction",
|
|
9623
9626
|
"message_reaction_count"
|
|
9624
|
-
]),
|
|
9627
|
+
]), tm = /* @__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("."), nm = tm.filter((e) => e != "*" && !em.has(e)), rm = {
|
|
9625
9628
|
snapshot: {
|
|
9626
9629
|
configSchema: {
|
|
9627
9630
|
additionalProperties: !1,
|
|
@@ -9645,7 +9648,7 @@ var $p = /* @__PURE__ */ new Set([
|
|
|
9645
9648
|
},
|
|
9646
9649
|
updates: {
|
|
9647
9650
|
description: "Telegram update types that trigger a Run. Use * for the Telegram default set.",
|
|
9648
|
-
items: { enum:
|
|
9651
|
+
items: { enum: tm },
|
|
9649
9652
|
minItems: 1,
|
|
9650
9653
|
type: "array",
|
|
9651
9654
|
uniqueItems: !0
|
|
@@ -9699,13 +9702,13 @@ var $p = /* @__PURE__ */ new Set([
|
|
|
9699
9702
|
type: "integration"
|
|
9700
9703
|
},
|
|
9701
9704
|
receive(e) {
|
|
9702
|
-
if (!
|
|
9705
|
+
if (!om(e.header("x-telegram-bot-api-secret-token"), e.callbackSecret)) return {
|
|
9703
9706
|
body: "",
|
|
9704
9707
|
contentType: "text/plain",
|
|
9705
9708
|
outcome: "respond",
|
|
9706
9709
|
status: 404
|
|
9707
9710
|
};
|
|
9708
|
-
if (!
|
|
9711
|
+
if (!sm(e.payload) || !Number.isSafeInteger(e.payload.update_id)) return {
|
|
9709
9712
|
outcome: "ignored",
|
|
9710
9713
|
reason: "Telegram update_id is missing."
|
|
9711
9714
|
};
|
|
@@ -9714,21 +9717,21 @@ var $p = /* @__PURE__ */ new Set([
|
|
|
9714
9717
|
outcome: "ignored",
|
|
9715
9718
|
reason: "Telegram update body is missing."
|
|
9716
9719
|
};
|
|
9717
|
-
let n =
|
|
9718
|
-
if (!(
|
|
9720
|
+
let n = im(e.config);
|
|
9721
|
+
if (!(am(n) ?? nm).includes(t)) return {
|
|
9719
9722
|
outcome: "ignored",
|
|
9720
9723
|
reason: "Telegram update type is not subscribed."
|
|
9721
9724
|
};
|
|
9722
9725
|
let r = e.payload[t];
|
|
9723
9726
|
if (n.chatIds.length > 0) {
|
|
9724
|
-
let e =
|
|
9727
|
+
let e = lm(r);
|
|
9725
9728
|
if (e == null || !n.chatIds.includes(e)) return {
|
|
9726
9729
|
outcome: "ignored",
|
|
9727
9730
|
reason: "Telegram chat does not match."
|
|
9728
9731
|
};
|
|
9729
9732
|
}
|
|
9730
9733
|
if (n.userIds.length > 0) {
|
|
9731
|
-
let e =
|
|
9734
|
+
let e = um(r);
|
|
9732
9735
|
if (e == null || !n.userIds.includes(e)) return {
|
|
9733
9736
|
outcome: "ignored",
|
|
9734
9737
|
reason: "Telegram user does not match."
|
|
@@ -9746,19 +9749,19 @@ var $p = /* @__PURE__ */ new Set([
|
|
|
9746
9749
|
};
|
|
9747
9750
|
},
|
|
9748
9751
|
async reconcile(e) {
|
|
9749
|
-
let n = await
|
|
9750
|
-
if (!e.active) return n == e.endpointUrl && await
|
|
9751
|
-
if (n != "" && n != e.endpointUrl) throw new t(`The Telegram bot already sends updates to ${
|
|
9752
|
-
let r =
|
|
9753
|
-
return await
|
|
9754
|
-
allowed_updates:
|
|
9752
|
+
let n = await dm(e);
|
|
9753
|
+
if (!e.active) return n == e.endpointUrl && await fm(e), { outcome: "ready" };
|
|
9754
|
+
if (n != "" && n != e.endpointUrl) throw new t(`The Telegram bot already sends updates to ${mm(n)}.`);
|
|
9755
|
+
let r = im(e.config);
|
|
9756
|
+
return await pm(e, "setWebhook", {
|
|
9757
|
+
allowed_updates: am(r) ?? [],
|
|
9755
9758
|
drop_pending_updates: n == "" && r.dropPendingUpdates,
|
|
9756
9759
|
secret_token: e.callbackSecret,
|
|
9757
9760
|
url: e.endpointUrl
|
|
9758
9761
|
}), { outcome: "ready" };
|
|
9759
9762
|
}
|
|
9760
9763
|
};
|
|
9761
|
-
function
|
|
9764
|
+
function im(e) {
|
|
9762
9765
|
return {
|
|
9763
9766
|
chatIds: e.chatIds ?? [],
|
|
9764
9767
|
dropPendingUpdates: e.dropPendingUpdates ?? !0,
|
|
@@ -9766,38 +9769,38 @@ function rm(e) {
|
|
|
9766
9769
|
userIds: e.userIds ?? []
|
|
9767
9770
|
};
|
|
9768
9771
|
}
|
|
9769
|
-
function
|
|
9772
|
+
function am(e) {
|
|
9770
9773
|
if (!e.updates.includes("*")) return e.updates;
|
|
9771
9774
|
let t = e.updates.filter((e) => e != "*");
|
|
9772
|
-
return t.length == 0 ? null : [.../* @__PURE__ */ new Set([...
|
|
9775
|
+
return t.length == 0 ? null : [.../* @__PURE__ */ new Set([...nm, ...t])];
|
|
9773
9776
|
}
|
|
9774
|
-
function
|
|
9777
|
+
function om(e, t) {
|
|
9775
9778
|
if (e == null || e.length != t.length) return !1;
|
|
9776
9779
|
let n = 0;
|
|
9777
9780
|
for (let r = 0; r < t.length; r += 1) n |= e.charCodeAt(r) ^ t.charCodeAt(r);
|
|
9778
9781
|
return n == 0;
|
|
9779
9782
|
}
|
|
9780
|
-
function om(e) {
|
|
9781
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
9782
|
-
}
|
|
9783
9783
|
function sm(e) {
|
|
9784
|
-
|
|
9784
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
9785
9785
|
}
|
|
9786
9786
|
function cm(e) {
|
|
9787
|
-
if (
|
|
9787
|
+
if (sm(e)) return typeof e.id == "string" || typeof e.id == "number" ? String(e.id) : void 0;
|
|
9788
9788
|
}
|
|
9789
9789
|
function lm(e) {
|
|
9790
|
-
if (
|
|
9790
|
+
if (sm(e)) return cm(e.chat) ?? (sm(e.message) ? cm(e.message.chat) : void 0);
|
|
9791
9791
|
}
|
|
9792
|
-
|
|
9793
|
-
|
|
9792
|
+
function um(e) {
|
|
9793
|
+
if (sm(e)) return cm(e.from) ?? cm(e.user);
|
|
9794
|
+
}
|
|
9795
|
+
async function dm(e) {
|
|
9796
|
+
let t = await pm(e, "getWebhookInfo"), r = sm(t.result) ? t.result.url : void 0;
|
|
9794
9797
|
if (typeof r != "string") throw new n("Telegram getWebhookInfo response is missing result.url.");
|
|
9795
9798
|
return r;
|
|
9796
9799
|
}
|
|
9797
|
-
async function
|
|
9798
|
-
await
|
|
9800
|
+
async function fm(e) {
|
|
9801
|
+
await pm(e, "deleteWebhook", { drop_pending_updates: !1 });
|
|
9799
9802
|
}
|
|
9800
|
-
async function
|
|
9803
|
+
async function pm(r, i, a) {
|
|
9801
9804
|
let o;
|
|
9802
9805
|
try {
|
|
9803
9806
|
o = await r.connector.execute({
|
|
@@ -9808,19 +9811,19 @@ async function fm(r, i, a) {
|
|
|
9808
9811
|
} catch (t) {
|
|
9809
9812
|
throw t instanceof e ? t : new n(`Telegram ${i} request failed.`, { cause: t });
|
|
9810
9813
|
}
|
|
9811
|
-
let s =
|
|
9814
|
+
let s = sm(o.data) ? o.data : {};
|
|
9812
9815
|
if (o.status >= 200 && o.status < 300 && s.ok === !0) return s;
|
|
9813
9816
|
let c = typeof s.description == "string" ? s.description : `HTTP ${o.status}`;
|
|
9814
9817
|
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}`);
|
|
9815
9818
|
}
|
|
9816
|
-
function
|
|
9819
|
+
function mm(e) {
|
|
9817
9820
|
try {
|
|
9818
9821
|
return new URL(e).host;
|
|
9819
9822
|
} catch {
|
|
9820
9823
|
return "an invalid URL";
|
|
9821
9824
|
}
|
|
9822
9825
|
}
|
|
9823
|
-
var
|
|
9826
|
+
var hm = {
|
|
9824
9827
|
initialState: {
|
|
9825
9828
|
checkpoint: null,
|
|
9826
9829
|
subscription: {}
|
|
@@ -9919,7 +9922,7 @@ var mm = {
|
|
|
9919
9922
|
outcome: "ignored",
|
|
9920
9923
|
reason: "WooCommerce topic header is missing."
|
|
9921
9924
|
};
|
|
9922
|
-
if (!
|
|
9925
|
+
if (!gm(e.config).events.includes(t)) return {
|
|
9923
9926
|
outcome: "ignored",
|
|
9924
9927
|
reason: "WooCommerce topic is not subscribed."
|
|
9925
9928
|
};
|
|
@@ -9939,31 +9942,31 @@ var mm = {
|
|
|
9939
9942
|
};
|
|
9940
9943
|
},
|
|
9941
9944
|
async reconcile(e) {
|
|
9942
|
-
let t =
|
|
9945
|
+
let t = Dm(e.state), n = gm(e.config), r = await ym(e);
|
|
9943
9946
|
if (!e.active) {
|
|
9944
|
-
for (let t of r) await
|
|
9945
|
-
return await t.saveSubscription({},
|
|
9947
|
+
for (let t of r) await bm(e, t.id);
|
|
9948
|
+
return await t.saveSubscription({}, Om(e.now)), { outcome: "ready" };
|
|
9946
9949
|
}
|
|
9947
9950
|
let i = /* @__PURE__ */ new Map();
|
|
9948
9951
|
for (let e of r) n.events.includes(e.topic) && !i.has(e.topic) && i.set(e.topic, e.id);
|
|
9949
9952
|
let a = new Set(i.values());
|
|
9950
|
-
for (let t of r) a.has(t.id) || await
|
|
9953
|
+
for (let t of r) a.has(t.id) || await bm(e, t.id);
|
|
9951
9954
|
let o = [];
|
|
9952
9955
|
for (let t of n.events) {
|
|
9953
9956
|
let r = i.get(t);
|
|
9954
|
-
o.push(r == null ? await
|
|
9957
|
+
o.push(r == null ? await _m(e, n, t) : await vm(e, r, t));
|
|
9955
9958
|
}
|
|
9956
|
-
return await t.saveSubscription({ webhookIds: o },
|
|
9959
|
+
return await t.saveSubscription({ webhookIds: o }, Om(e.now)), { outcome: "ready" };
|
|
9957
9960
|
}
|
|
9958
9961
|
};
|
|
9959
|
-
function
|
|
9962
|
+
function gm(e) {
|
|
9960
9963
|
return {
|
|
9961
9964
|
events: [...new Set(e.events)],
|
|
9962
9965
|
webhookName: e.webhookName ?? "OOMOL Trigger"
|
|
9963
9966
|
};
|
|
9964
9967
|
}
|
|
9965
|
-
async function
|
|
9966
|
-
let r = await
|
|
9968
|
+
async function _m(e, t, n) {
|
|
9969
|
+
let r = await xm(e, `webhook create (${n})`, {
|
|
9967
9970
|
body: {
|
|
9968
9971
|
delivery_url: e.endpointUrl,
|
|
9969
9972
|
name: `${t.webhookName} - ${n}`,
|
|
@@ -9973,10 +9976,10 @@ async function gm(e, t, n) {
|
|
|
9973
9976
|
endpoint: "/webhooks",
|
|
9974
9977
|
method: "POST"
|
|
9975
9978
|
});
|
|
9976
|
-
return
|
|
9979
|
+
return Sm(r, `webhook create (${n})`), Tm(r.data);
|
|
9977
9980
|
}
|
|
9978
|
-
async function
|
|
9979
|
-
let r = await
|
|
9981
|
+
async function vm(e, t, n) {
|
|
9982
|
+
let r = await xm(e, `webhook update (${n})`, {
|
|
9980
9983
|
body: {
|
|
9981
9984
|
delivery_url: e.endpointUrl,
|
|
9982
9985
|
secret: e.callbackSecret,
|
|
@@ -9986,12 +9989,12 @@ async function _m(e, t, n) {
|
|
|
9986
9989
|
endpoint: `/webhooks/${t}`,
|
|
9987
9990
|
method: "PUT"
|
|
9988
9991
|
});
|
|
9989
|
-
return
|
|
9992
|
+
return Cm(r) ? _m(e, gm(e.config), n) : (Sm(r, `webhook update (${n})`), t);
|
|
9990
9993
|
}
|
|
9991
|
-
async function
|
|
9994
|
+
async function ym(e) {
|
|
9992
9995
|
let t = [];
|
|
9993
9996
|
for (let n = 1; n <= 10; n += 1) {
|
|
9994
|
-
let r = await
|
|
9997
|
+
let r = await xm(e, "webhook list", {
|
|
9995
9998
|
endpoint: "/webhooks",
|
|
9996
9999
|
method: "GET",
|
|
9997
10000
|
query: {
|
|
@@ -10001,12 +10004,12 @@ async function vm(e) {
|
|
|
10001
10004
|
status: "all"
|
|
10002
10005
|
}
|
|
10003
10006
|
});
|
|
10004
|
-
|
|
10007
|
+
Sm(r, "webhook list");
|
|
10005
10008
|
let i = Array.isArray(r.data) ? r.data : [];
|
|
10006
10009
|
for (let n of i) {
|
|
10007
|
-
let r =
|
|
10010
|
+
let r = km(n);
|
|
10008
10011
|
if (r?.delivery_url !== e.endpointUrl || typeof r.topic != "string") continue;
|
|
10009
|
-
let i =
|
|
10012
|
+
let i = Em(r.id);
|
|
10010
10013
|
i != null && t.push({
|
|
10011
10014
|
id: i,
|
|
10012
10015
|
topic: r.topic
|
|
@@ -10016,54 +10019,54 @@ async function vm(e) {
|
|
|
10016
10019
|
}
|
|
10017
10020
|
throw new n("WooCommerce webhook list did not finish within ten pages.");
|
|
10018
10021
|
}
|
|
10019
|
-
async function
|
|
10020
|
-
let n = await
|
|
10022
|
+
async function bm(e, t) {
|
|
10023
|
+
let n = await xm(e, "webhook delete", {
|
|
10021
10024
|
endpoint: `/webhooks/${t}`,
|
|
10022
10025
|
method: "DELETE",
|
|
10023
10026
|
query: { force: "true" }
|
|
10024
10027
|
});
|
|
10025
|
-
n.status != 404 &&
|
|
10028
|
+
n.status != 404 && Sm(n, "webhook delete");
|
|
10026
10029
|
}
|
|
10027
|
-
async function
|
|
10030
|
+
async function xm(t, r, i) {
|
|
10028
10031
|
try {
|
|
10029
10032
|
return await t.connector.execute(i, t.signal);
|
|
10030
10033
|
} catch (t) {
|
|
10031
10034
|
throw t instanceof e ? t : new n(`WooCommerce ${r} request failed.`, { cause: t });
|
|
10032
10035
|
}
|
|
10033
10036
|
}
|
|
10034
|
-
function
|
|
10037
|
+
function Sm(r, i) {
|
|
10035
10038
|
if (r.status >= 200 && r.status < 300) return;
|
|
10036
|
-
let a =
|
|
10039
|
+
let a = wm(r.data);
|
|
10037
10040
|
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}.`);
|
|
10038
10041
|
}
|
|
10039
|
-
function Sm(e) {
|
|
10040
|
-
return e.status == 400 && Cm(e.data) == "woocommerce_rest_webhook_invalid_id";
|
|
10041
|
-
}
|
|
10042
10042
|
function Cm(e) {
|
|
10043
|
-
|
|
10044
|
-
return typeof t == "string" ? t : "";
|
|
10043
|
+
return e.status == 400 && wm(e.data) == "woocommerce_rest_webhook_invalid_id";
|
|
10045
10044
|
}
|
|
10046
10045
|
function wm(e) {
|
|
10047
|
-
let t =
|
|
10046
|
+
let t = km(e)?.code;
|
|
10047
|
+
return typeof t == "string" ? t : "";
|
|
10048
|
+
}
|
|
10049
|
+
function Tm(e) {
|
|
10050
|
+
let t = Em(km(e)?.id);
|
|
10048
10051
|
if (t == null) throw new n("WooCommerce webhook response is missing its ID.");
|
|
10049
10052
|
return t;
|
|
10050
10053
|
}
|
|
10051
|
-
function
|
|
10054
|
+
function Em(e) {
|
|
10052
10055
|
return typeof e == "string" && e.length > 0 ? e : typeof e == "number" && Number.isFinite(e) ? String(e) : null;
|
|
10053
10056
|
}
|
|
10054
|
-
function
|
|
10057
|
+
function Dm(e) {
|
|
10055
10058
|
if (e == null) throw new t("WooCommerce Integration state is missing.");
|
|
10056
10059
|
return e;
|
|
10057
10060
|
}
|
|
10058
|
-
function
|
|
10061
|
+
function Om(e) {
|
|
10059
10062
|
return new Date(e.getTime() + 2592e6);
|
|
10060
10063
|
}
|
|
10061
|
-
function
|
|
10064
|
+
function km(e) {
|
|
10062
10065
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
10063
10066
|
}
|
|
10064
10067
|
//#endregion
|
|
10065
10068
|
//#region src/trigger/providers/zendesk/on-event.ts
|
|
10066
|
-
var
|
|
10069
|
+
var Am = 3e5, jm = /* @__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(","), Mm = "/api/v2/webhooks", Nm = {
|
|
10067
10070
|
initialState: {
|
|
10068
10071
|
checkpoint: null,
|
|
10069
10072
|
subscription: {}
|
|
@@ -10073,7 +10076,7 @@ var km = 3e5, Am = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_chang
|
|
|
10073
10076
|
additionalProperties: !1,
|
|
10074
10077
|
properties: { events: {
|
|
10075
10078
|
items: {
|
|
10076
|
-
enum:
|
|
10079
|
+
enum: jm,
|
|
10077
10080
|
type: "string"
|
|
10078
10081
|
},
|
|
10079
10082
|
minItems: 1,
|
|
@@ -10118,8 +10121,8 @@ var km = 3e5, Am = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_chang
|
|
|
10118
10121
|
type: "integration"
|
|
10119
10122
|
},
|
|
10120
10123
|
async receive(e) {
|
|
10121
|
-
let t =
|
|
10122
|
-
if (t == null || n == null || !Number.isFinite(r) || Math.abs(e.now.getTime() - r) >
|
|
10124
|
+
let t = Um(e.state), n = e.header("x-zendesk-webhook-signature-timestamp"), r = n == null ? NaN : Date.parse(n);
|
|
10125
|
+
if (t == null || n == null || !Number.isFinite(r) || Math.abs(e.now.getTime() - r) > Am || !await Ee(t, [we(n), e.rawBody], e.header("x-zendesk-webhook-signature"))) return {
|
|
10123
10126
|
body: "",
|
|
10124
10127
|
contentType: "text/plain",
|
|
10125
10128
|
outcome: "respond",
|
|
@@ -10151,148 +10154,148 @@ var km = 3e5, Am = /* @__PURE__ */ "zen:event-type:ticket.agent_assignment_chang
|
|
|
10151
10154
|
};
|
|
10152
10155
|
},
|
|
10153
10156
|
async reconcile(e) {
|
|
10154
|
-
let t =
|
|
10157
|
+
let t = Vm(e.state), n = await Fm(e), r = Hm(t);
|
|
10155
10158
|
if (!e.active) {
|
|
10156
|
-
for (let t of r == null ? n : [.../* @__PURE__ */ new Set([r, ...n])]) await
|
|
10157
|
-
return await t.saveSubscription({},
|
|
10159
|
+
for (let t of r == null ? n : [.../* @__PURE__ */ new Set([r, ...n])]) await Im(e, t);
|
|
10160
|
+
return await t.saveSubscription({}, Gm(e.now)), { outcome: "ready" };
|
|
10158
10161
|
}
|
|
10159
10162
|
let i = r ?? n[0];
|
|
10160
10163
|
if (i == null) {
|
|
10161
|
-
let t = await
|
|
10162
|
-
body:
|
|
10163
|
-
endpoint:
|
|
10164
|
+
let t = await Lm(e, "webhook create", {
|
|
10165
|
+
body: Pm(e),
|
|
10166
|
+
endpoint: Mm,
|
|
10164
10167
|
method: "POST"
|
|
10165
10168
|
});
|
|
10166
|
-
|
|
10169
|
+
Rm(t, "webhook create"), i = Bm(Km(t.data)?.webhook);
|
|
10167
10170
|
} else {
|
|
10168
|
-
let n = await
|
|
10169
|
-
body:
|
|
10170
|
-
endpoint: `${
|
|
10171
|
+
let n = await Lm(e, "webhook update", {
|
|
10172
|
+
body: Pm(e),
|
|
10173
|
+
endpoint: `${Mm}/${i}`,
|
|
10171
10174
|
method: "PUT"
|
|
10172
10175
|
});
|
|
10173
10176
|
if (n.status == 404) return await t.saveSubscription({}, e.now), { outcome: "pending" };
|
|
10174
|
-
|
|
10177
|
+
Rm(n, "webhook update");
|
|
10175
10178
|
}
|
|
10176
|
-
for (let t of n.filter((e) => e != i)) await
|
|
10179
|
+
for (let t of n.filter((e) => e != i)) await Im(e, t);
|
|
10177
10180
|
return await t.saveSubscription({
|
|
10178
|
-
signingSecret: await
|
|
10181
|
+
signingSecret: await Wm(e, i),
|
|
10179
10182
|
webhookId: i
|
|
10180
|
-
},
|
|
10183
|
+
}, Gm(e.now)), { outcome: "ready" };
|
|
10181
10184
|
}
|
|
10182
10185
|
};
|
|
10183
|
-
function
|
|
10186
|
+
function Pm(e) {
|
|
10184
10187
|
return { webhook: {
|
|
10185
10188
|
description: "Managed by Open Flow. Do not edit.",
|
|
10186
10189
|
endpoint: e.endpointUrl,
|
|
10187
10190
|
http_method: "POST",
|
|
10188
|
-
name:
|
|
10191
|
+
name: zm(e.endpointUrl),
|
|
10189
10192
|
request_format: "json",
|
|
10190
10193
|
status: "active",
|
|
10191
10194
|
subscriptions: [...new Set(e.config.events)]
|
|
10192
10195
|
} };
|
|
10193
10196
|
}
|
|
10194
|
-
async function
|
|
10197
|
+
async function Fm(e) {
|
|
10195
10198
|
let t = [], n;
|
|
10196
10199
|
for (let r = 0; r < 10; r += 1) {
|
|
10197
|
-
let r = await
|
|
10198
|
-
endpoint:
|
|
10200
|
+
let r = await Lm(e, "webhook list", {
|
|
10201
|
+
endpoint: Mm,
|
|
10199
10202
|
method: "GET",
|
|
10200
10203
|
query: {
|
|
10201
|
-
"filter[name_contains]":
|
|
10204
|
+
"filter[name_contains]": zm(e.endpointUrl),
|
|
10202
10205
|
"page[size]": "100",
|
|
10203
10206
|
...n == null ? {} : { "page[after]": n }
|
|
10204
10207
|
}
|
|
10205
10208
|
});
|
|
10206
|
-
|
|
10207
|
-
let i =
|
|
10209
|
+
Rm(r, "webhook list");
|
|
10210
|
+
let i = Km(r.data), a = Array.isArray(i?.webhooks) ? i.webhooks : [];
|
|
10208
10211
|
for (let n of a) {
|
|
10209
|
-
let r =
|
|
10212
|
+
let r = Km(n);
|
|
10210
10213
|
r?.endpoint === e.endpointUrl && typeof r.id == "string" && t.push(r.id);
|
|
10211
10214
|
}
|
|
10212
|
-
let o =
|
|
10215
|
+
let o = Km(i?.meta);
|
|
10213
10216
|
if (o?.has_more !== !0 || typeof o.after_cursor != "string") return t;
|
|
10214
10217
|
n = o.after_cursor;
|
|
10215
10218
|
}
|
|
10216
10219
|
return t;
|
|
10217
10220
|
}
|
|
10218
|
-
async function
|
|
10219
|
-
let n = await
|
|
10220
|
-
endpoint: `${
|
|
10221
|
+
async function Im(e, t) {
|
|
10222
|
+
let n = await Lm(e, "webhook delete", {
|
|
10223
|
+
endpoint: `${Mm}/${t}`,
|
|
10221
10224
|
method: "DELETE"
|
|
10222
10225
|
});
|
|
10223
|
-
n.status != 404 &&
|
|
10226
|
+
n.status != 404 && Rm(n, "webhook delete");
|
|
10224
10227
|
}
|
|
10225
|
-
async function
|
|
10228
|
+
async function Lm(t, r, i) {
|
|
10226
10229
|
try {
|
|
10227
10230
|
return await t.connector.execute(i, t.signal);
|
|
10228
10231
|
} catch (t) {
|
|
10229
10232
|
throw t instanceof e ? t : new n(`Zendesk ${r} request failed.`, { cause: t });
|
|
10230
10233
|
}
|
|
10231
10234
|
}
|
|
10232
|
-
function
|
|
10235
|
+
function Rm(r, i) {
|
|
10233
10236
|
if (!(r.status >= 200 && r.status < 300)) throw r.status == 401 || r.status == 403 ? new e(`Zendesk ${i} rejected the Connection.`) : [
|
|
10234
10237
|
400,
|
|
10235
10238
|
404,
|
|
10236
10239
|
422
|
|
10237
10240
|
].includes(r.status) ? new t(`Zendesk ${i} rejected the subscription.`) : new n(`Zendesk ${i} failed with status ${r.status}.`);
|
|
10238
10241
|
}
|
|
10239
|
-
function
|
|
10242
|
+
function zm(e) {
|
|
10240
10243
|
return `open-flow-${e.slice(e.lastIndexOf("/") + 1)}`;
|
|
10241
10244
|
}
|
|
10242
|
-
function
|
|
10243
|
-
let t =
|
|
10245
|
+
function Bm(e) {
|
|
10246
|
+
let t = Km(e)?.id;
|
|
10244
10247
|
if (typeof t != "string") throw new n("Zendesk webhook response is missing its ID.");
|
|
10245
10248
|
return t;
|
|
10246
10249
|
}
|
|
10247
|
-
function
|
|
10250
|
+
function Vm(e) {
|
|
10248
10251
|
if (e == null) throw new t("Zendesk Integration state is missing.");
|
|
10249
10252
|
return e;
|
|
10250
10253
|
}
|
|
10251
|
-
function
|
|
10254
|
+
function Hm(e) {
|
|
10252
10255
|
let t = e.subscription.webhookId;
|
|
10253
10256
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
10254
10257
|
}
|
|
10255
|
-
function
|
|
10258
|
+
function Um(e) {
|
|
10256
10259
|
let t = e?.subscription.signingSecret;
|
|
10257
10260
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
10258
10261
|
}
|
|
10259
|
-
async function
|
|
10260
|
-
let r = await
|
|
10261
|
-
endpoint: `${
|
|
10262
|
+
async function Wm(e, t) {
|
|
10263
|
+
let r = await Lm(e, "webhook signing secret", {
|
|
10264
|
+
endpoint: `${Mm}/${t}/signing_secret`,
|
|
10262
10265
|
method: "GET"
|
|
10263
10266
|
});
|
|
10264
|
-
|
|
10265
|
-
let i =
|
|
10267
|
+
Rm(r, "webhook signing secret");
|
|
10268
|
+
let i = Km(Km(r.data)?.signing_secret)?.secret;
|
|
10266
10269
|
if (typeof i != "string" || i.length == 0) throw new n("Zendesk webhook signing secret response is invalid.");
|
|
10267
10270
|
return i;
|
|
10268
10271
|
}
|
|
10269
|
-
function
|
|
10272
|
+
function Gm(e) {
|
|
10270
10273
|
return new Date(e.getTime() + 2592e6);
|
|
10271
10274
|
}
|
|
10272
|
-
function
|
|
10275
|
+
function Km(e) {
|
|
10273
10276
|
return typeof e == "object" && e && !Array.isArray(e) ? e : void 0;
|
|
10274
10277
|
}
|
|
10275
10278
|
//#endregion
|
|
10276
10279
|
//#region src/trigger/providers/localization.ts
|
|
10277
|
-
var
|
|
10280
|
+
var qm = {
|
|
10278
10281
|
"zh-CN": () => import("./zh-CN-ByQ6nYam.js"),
|
|
10279
10282
|
"zh-TW": () => import("./zh-TW-QjIarvX9.js"),
|
|
10280
10283
|
ja: () => import("./ja-Bq-ZDOD4.js"),
|
|
10281
10284
|
ko: () => import("./ko-Z-k9R2c6.js"),
|
|
10282
10285
|
ru: () => import("./ru-B4gFecYZ.js"),
|
|
10283
10286
|
fr: () => import("./fr-iv1541dF.js")
|
|
10284
|
-
},
|
|
10285
|
-
function
|
|
10286
|
-
if (e == "en") return
|
|
10287
|
-
let t =
|
|
10287
|
+
}, Jm = /* @__PURE__ */ new Map(), Ym = Promise.resolve({});
|
|
10288
|
+
function Xm(e) {
|
|
10289
|
+
if (e == "en") return Ym;
|
|
10290
|
+
let t = Jm.get(e);
|
|
10288
10291
|
if (t != null) return t;
|
|
10289
|
-
let n =
|
|
10290
|
-
return
|
|
10291
|
-
|
|
10292
|
+
let n = qm[e]().then((e) => e.default);
|
|
10293
|
+
return Jm.set(e, n), n.catch(() => {
|
|
10294
|
+
Jm.get(e) == n && Jm.delete(e);
|
|
10292
10295
|
}), n;
|
|
10293
10296
|
}
|
|
10294
|
-
async function
|
|
10295
|
-
let n = (await
|
|
10297
|
+
async function Zm(e, t) {
|
|
10298
|
+
let n = (await Xm(t))[e.key];
|
|
10296
10299
|
return {
|
|
10297
10300
|
displayName: n?.displayName ?? e.displayName,
|
|
10298
10301
|
description: n?.description ?? e.description
|
|
@@ -10300,28 +10303,28 @@ async function Xm(e, t) {
|
|
|
10300
10303
|
}
|
|
10301
10304
|
//#endregion
|
|
10302
10305
|
//#region src/trigger/providers/definitions.ts
|
|
10303
|
-
var
|
|
10306
|
+
var Qm = [
|
|
10304
10307
|
...d,
|
|
10305
10308
|
re,
|
|
10306
|
-
|
|
10309
|
+
Gl,
|
|
10307
10310
|
Me,
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10315
|
-
|
|
10316
|
-
|
|
10317
|
-
|
|
10318
|
-
|
|
10319
|
-
|
|
10320
|
-
|
|
10321
|
-
|
|
10322
|
-
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
],
|
|
10311
|
+
El,
|
|
10312
|
+
Al,
|
|
10313
|
+
lu,
|
|
10314
|
+
Nu,
|
|
10315
|
+
td,
|
|
10316
|
+
od,
|
|
10317
|
+
Od,
|
|
10318
|
+
Yd,
|
|
10319
|
+
tf,
|
|
10320
|
+
Tf,
|
|
10321
|
+
qf,
|
|
10322
|
+
cp,
|
|
10323
|
+
Tp,
|
|
10324
|
+
Bp,
|
|
10325
|
+
rm,
|
|
10326
|
+
hm,
|
|
10327
|
+
Nm
|
|
10328
|
+
], $m = Qm.filter((e) => e.snapshot.type == "poll"), eh = Qm.filter((e) => e.snapshot.type == "integration");
|
|
10326
10329
|
//#endregion
|
|
10327
|
-
export { u as feishuResponse, l as feishuSubscriptions,
|
|
10330
|
+
export { u as feishuResponse, l as feishuSubscriptions, eh as integrationDefinitions, Zm as localizeTrigger, te as matchesFeishuEvent, $m as pollDefinitions, m as receiveFeishuEvent, Qm as triggerDefinitions };
|