@ancha-labs/cli 0.4.28 → 0.4.29
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/lib/ancha.mjs +3051 -2494
- package/lib/assets/docs/cloud.md +4 -2
- package/lib/assets/docs/company.md +41 -0
- package/lib/assets/docs/run.md +3 -1
- package/lib/assets/docs/setup.md +1 -1
- package/lib/assets/docs/traces.md +5 -1
- package/lib/assets/harbor/companion.mjs +777 -762
- package/lib/mcp-entry.mjs +105 -90
- package/lib/worker.mjs +922 -871
- package/lib/world-server.mjs +772 -757
- package/package.json +1 -1
package/lib/world-server.mjs
CHANGED
|
@@ -1006,14 +1006,14 @@ var require_foldFlowLines = __commonJS({
|
|
|
1006
1006
|
var FOLD_FLOW = "flow";
|
|
1007
1007
|
var FOLD_BLOCK = "block";
|
|
1008
1008
|
var FOLD_QUOTED = "quoted";
|
|
1009
|
-
function foldFlowLines(
|
|
1009
|
+
function foldFlowLines(text25, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
|
|
1010
1010
|
if (!lineWidth || lineWidth < 0)
|
|
1011
|
-
return
|
|
1011
|
+
return text25;
|
|
1012
1012
|
if (lineWidth < minContentWidth)
|
|
1013
1013
|
minContentWidth = 0;
|
|
1014
1014
|
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
1015
|
-
if (
|
|
1016
|
-
return
|
|
1015
|
+
if (text25.length <= endStep)
|
|
1016
|
+
return text25;
|
|
1017
1017
|
const folds = [];
|
|
1018
1018
|
const escapedFolds = {};
|
|
1019
1019
|
let end = lineWidth - indent.length;
|
|
@@ -1030,14 +1030,14 @@ var require_foldFlowLines = __commonJS({
|
|
|
1030
1030
|
let escStart = -1;
|
|
1031
1031
|
let escEnd = -1;
|
|
1032
1032
|
if (mode === FOLD_BLOCK) {
|
|
1033
|
-
i = consumeMoreIndentedLines(
|
|
1033
|
+
i = consumeMoreIndentedLines(text25, i, indent.length);
|
|
1034
1034
|
if (i !== -1)
|
|
1035
1035
|
end = i + endStep;
|
|
1036
1036
|
}
|
|
1037
|
-
for (let ch; ch =
|
|
1037
|
+
for (let ch; ch = text25[i += 1]; ) {
|
|
1038
1038
|
if (mode === FOLD_QUOTED && ch === "\\") {
|
|
1039
1039
|
escStart = i;
|
|
1040
|
-
switch (
|
|
1040
|
+
switch (text25[i + 1]) {
|
|
1041
1041
|
case "x":
|
|
1042
1042
|
i += 3;
|
|
1043
1043
|
break;
|
|
@@ -1054,12 +1054,12 @@ var require_foldFlowLines = __commonJS({
|
|
|
1054
1054
|
}
|
|
1055
1055
|
if (ch === "\n") {
|
|
1056
1056
|
if (mode === FOLD_BLOCK)
|
|
1057
|
-
i = consumeMoreIndentedLines(
|
|
1057
|
+
i = consumeMoreIndentedLines(text25, i, indent.length);
|
|
1058
1058
|
end = i + indent.length + endStep;
|
|
1059
1059
|
split = void 0;
|
|
1060
1060
|
} else {
|
|
1061
1061
|
if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
|
|
1062
|
-
const next2 =
|
|
1062
|
+
const next2 = text25[i + 1];
|
|
1063
1063
|
if (next2 && next2 !== " " && next2 !== "\n" && next2 !== " ")
|
|
1064
1064
|
split = i;
|
|
1065
1065
|
}
|
|
@@ -1071,12 +1071,12 @@ var require_foldFlowLines = __commonJS({
|
|
|
1071
1071
|
} else if (mode === FOLD_QUOTED) {
|
|
1072
1072
|
while (prev === " " || prev === " ") {
|
|
1073
1073
|
prev = ch;
|
|
1074
|
-
ch =
|
|
1074
|
+
ch = text25[i += 1];
|
|
1075
1075
|
overflow = true;
|
|
1076
1076
|
}
|
|
1077
1077
|
const j = i > escEnd + 1 ? i - 2 : escStart - 1;
|
|
1078
1078
|
if (escapedFolds[j])
|
|
1079
|
-
return
|
|
1079
|
+
return text25;
|
|
1080
1080
|
folds.push(j);
|
|
1081
1081
|
escapedFolds[j] = true;
|
|
1082
1082
|
end = j + endStep;
|
|
@@ -1091,39 +1091,39 @@ var require_foldFlowLines = __commonJS({
|
|
|
1091
1091
|
if (overflow && onOverflow)
|
|
1092
1092
|
onOverflow();
|
|
1093
1093
|
if (folds.length === 0)
|
|
1094
|
-
return
|
|
1094
|
+
return text25;
|
|
1095
1095
|
if (onFold)
|
|
1096
1096
|
onFold();
|
|
1097
|
-
let res =
|
|
1097
|
+
let res = text25.slice(0, folds[0]);
|
|
1098
1098
|
for (let i2 = 0; i2 < folds.length; ++i2) {
|
|
1099
1099
|
const fold2 = folds[i2];
|
|
1100
|
-
const end2 = folds[i2 + 1] ||
|
|
1100
|
+
const end2 = folds[i2 + 1] || text25.length;
|
|
1101
1101
|
if (fold2 === 0)
|
|
1102
1102
|
res = `
|
|
1103
|
-
${indent}${
|
|
1103
|
+
${indent}${text25.slice(0, end2)}`;
|
|
1104
1104
|
else {
|
|
1105
1105
|
if (mode === FOLD_QUOTED && escapedFolds[fold2])
|
|
1106
|
-
res += `${
|
|
1106
|
+
res += `${text25[fold2]}\\`;
|
|
1107
1107
|
res += `
|
|
1108
|
-
${indent}${
|
|
1108
|
+
${indent}${text25.slice(fold2 + 1, end2)}`;
|
|
1109
1109
|
}
|
|
1110
1110
|
}
|
|
1111
1111
|
return res;
|
|
1112
1112
|
}
|
|
1113
|
-
function consumeMoreIndentedLines(
|
|
1113
|
+
function consumeMoreIndentedLines(text25, i, indent) {
|
|
1114
1114
|
let end = i;
|
|
1115
1115
|
let start2 = i + 1;
|
|
1116
|
-
let ch =
|
|
1116
|
+
let ch = text25[start2];
|
|
1117
1117
|
while (ch === " " || ch === " ") {
|
|
1118
1118
|
if (i < start2 + indent) {
|
|
1119
|
-
ch =
|
|
1119
|
+
ch = text25[++i];
|
|
1120
1120
|
} else {
|
|
1121
1121
|
do {
|
|
1122
|
-
ch =
|
|
1122
|
+
ch = text25[++i];
|
|
1123
1123
|
} while (ch && ch !== "\n");
|
|
1124
1124
|
end = i;
|
|
1125
1125
|
start2 = i + 1;
|
|
1126
|
-
ch =
|
|
1126
|
+
ch = text25[start2];
|
|
1127
1127
|
}
|
|
1128
1128
|
}
|
|
1129
1129
|
return end;
|
|
@@ -37377,9 +37377,9 @@ var require_logging = __commonJS({
|
|
|
37377
37377
|
}
|
|
37378
37378
|
var allEnabled = enabledTracers.has("all");
|
|
37379
37379
|
var anyTracerEnabled = allEnabled || enabledTracers.size > 0;
|
|
37380
|
-
function trace(severity, tracer,
|
|
37380
|
+
function trace(severity, tracer, text25) {
|
|
37381
37381
|
if (isTracerEnabled(tracer)) {
|
|
37382
|
-
(0, exports.log)(severity, (/* @__PURE__ */ new Date()).toISOString() + " | v" + clientVersion + " " + process_1.pid + " | " + tracer + " | " +
|
|
37382
|
+
(0, exports.log)(severity, (/* @__PURE__ */ new Date()).toISOString() + " | v" + clientVersion + " " + process_1.pid + " | " + tracer + " | " + text25);
|
|
37383
37383
|
}
|
|
37384
37384
|
}
|
|
37385
37385
|
function isTracerEnabled(tracer) {
|
|
@@ -38962,9 +38962,9 @@ var require_backoff_timeout = __commonJS({
|
|
|
38962
38962
|
get traceEnabled() {
|
|
38963
38963
|
return logging.isTracerEnabled(TRACER_NAME);
|
|
38964
38964
|
}
|
|
38965
|
-
trace(
|
|
38965
|
+
trace(text25) {
|
|
38966
38966
|
if (this.traceEnabled) {
|
|
38967
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "{" + this.id + "} " +
|
|
38967
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "{" + this.id + "} " + text25);
|
|
38968
38968
|
}
|
|
38969
38969
|
}
|
|
38970
38970
|
runTimer(delay) {
|
|
@@ -39213,8 +39213,8 @@ var require_resolving_load_balancer = __commonJS({
|
|
|
39213
39213
|
var uri_parser_1 = require_uri_parser();
|
|
39214
39214
|
var load_balancer_child_handler_1 = require_load_balancer_child_handler();
|
|
39215
39215
|
var TRACER_NAME = "resolving_load_balancer";
|
|
39216
|
-
function trace(
|
|
39217
|
-
logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME,
|
|
39216
|
+
function trace(text25) {
|
|
39217
|
+
logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
39218
39218
|
}
|
|
39219
39219
|
var NAME_MATCH_LEVEL_ORDER = [
|
|
39220
39220
|
"SERVICE_AND_METHOD",
|
|
@@ -42929,14 +42929,14 @@ var require_subchannel = __commonJS({
|
|
|
42929
42929
|
get refTraceEnabled() {
|
|
42930
42930
|
return logging.isTracerEnabled("subchannel_refcount");
|
|
42931
42931
|
}
|
|
42932
|
-
trace(
|
|
42932
|
+
trace(text25) {
|
|
42933
42933
|
if (this.traceEnabled) {
|
|
42934
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " +
|
|
42934
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text25);
|
|
42935
42935
|
}
|
|
42936
42936
|
}
|
|
42937
|
-
refTrace(
|
|
42937
|
+
refTrace(text25) {
|
|
42938
42938
|
if (this.refTraceEnabled) {
|
|
42939
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, "subchannel_refcount", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " +
|
|
42939
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, "subchannel_refcount", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text25);
|
|
42940
42940
|
}
|
|
42941
42941
|
}
|
|
42942
42942
|
handleBackoffTimer() {
|
|
@@ -43223,8 +43223,8 @@ var require_resolver_dns = __commonJS({
|
|
|
43223
43223
|
var backoff_timeout_1 = require_backoff_timeout();
|
|
43224
43224
|
var environment_1 = require_environment();
|
|
43225
43225
|
var TRACER_NAME = "dns_resolver";
|
|
43226
|
-
function trace(
|
|
43227
|
-
logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME,
|
|
43226
|
+
function trace(text25) {
|
|
43227
|
+
logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
43228
43228
|
}
|
|
43229
43229
|
exports.DEFAULT_PORT = 443;
|
|
43230
43230
|
var DEFAULT_MIN_TIME_BETWEEN_RESOLUTIONS_MS = 3e4;
|
|
@@ -43509,8 +43509,8 @@ var require_http_proxy = __commonJS({
|
|
|
43509
43509
|
var url_1 = __require("url");
|
|
43510
43510
|
var resolver_dns_1 = require_resolver_dns();
|
|
43511
43511
|
var TRACER_NAME = "proxy";
|
|
43512
|
-
function trace(
|
|
43513
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME,
|
|
43512
|
+
function trace(text25) {
|
|
43513
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
43514
43514
|
}
|
|
43515
43515
|
function getProxyInfo() {
|
|
43516
43516
|
let proxyEnv = "";
|
|
@@ -44040,9 +44040,9 @@ var require_subchannel_call = __commonJS({
|
|
|
44040
44040
|
get traceEnabled() {
|
|
44041
44041
|
return logging.isTracerEnabled(TRACER_NAME);
|
|
44042
44042
|
}
|
|
44043
|
-
trace(
|
|
44043
|
+
trace(text25) {
|
|
44044
44044
|
if (this.traceEnabled) {
|
|
44045
|
-
logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callId + "] " +
|
|
44045
|
+
logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callId + "] " + text25);
|
|
44046
44046
|
}
|
|
44047
44047
|
}
|
|
44048
44048
|
/**
|
|
@@ -44409,24 +44409,24 @@ var require_transport = __commonJS({
|
|
|
44409
44409
|
get internalsTraceEnabled() {
|
|
44410
44410
|
return logging.isTracerEnabled("transport_internals");
|
|
44411
44411
|
}
|
|
44412
|
-
trace(
|
|
44412
|
+
trace(text25) {
|
|
44413
44413
|
if (this.traceEnabled) {
|
|
44414
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " +
|
|
44414
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text25);
|
|
44415
44415
|
}
|
|
44416
44416
|
}
|
|
44417
|
-
keepaliveTrace(
|
|
44417
|
+
keepaliveTrace(text25) {
|
|
44418
44418
|
if (this.keepaliveTraceEnabled) {
|
|
44419
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " +
|
|
44419
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text25);
|
|
44420
44420
|
}
|
|
44421
44421
|
}
|
|
44422
|
-
flowControlTrace(
|
|
44422
|
+
flowControlTrace(text25) {
|
|
44423
44423
|
if (this.flowControlTraceEnabled) {
|
|
44424
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, FLOW_CONTROL_TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " +
|
|
44424
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, FLOW_CONTROL_TRACER_NAME, "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text25);
|
|
44425
44425
|
}
|
|
44426
44426
|
}
|
|
44427
|
-
internalsTrace(
|
|
44427
|
+
internalsTrace(text25) {
|
|
44428
44428
|
if (this.internalsTraceEnabled) {
|
|
44429
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, "transport_internals", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " +
|
|
44429
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, "transport_internals", "(" + this.channelzRef.id + ") " + this.subchannelAddressString + " " + text25);
|
|
44430
44430
|
}
|
|
44431
44431
|
}
|
|
44432
44432
|
/**
|
|
@@ -44664,9 +44664,9 @@ var require_transport = __commonJS({
|
|
|
44664
44664
|
get traceEnabled() {
|
|
44665
44665
|
return logging.isTracerEnabled(TRACER_NAME);
|
|
44666
44666
|
}
|
|
44667
|
-
trace(
|
|
44667
|
+
trace(text25) {
|
|
44668
44668
|
if (this.traceEnabled) {
|
|
44669
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + " " +
|
|
44669
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, (0, uri_parser_1.uriToString)(this.channelTarget) + " " + text25);
|
|
44670
44670
|
}
|
|
44671
44671
|
}
|
|
44672
44672
|
createSession(secureConnectResult, address8, options3) {
|
|
@@ -44980,9 +44980,9 @@ var require_load_balancing_call = __commonJS({
|
|
|
44980
44980
|
get traceEnabled() {
|
|
44981
44981
|
return logging.isTracerEnabled(TRACER_NAME);
|
|
44982
44982
|
}
|
|
44983
|
-
trace(
|
|
44983
|
+
trace(text25) {
|
|
44984
44984
|
if (this.traceEnabled) {
|
|
44985
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " +
|
|
44985
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text25);
|
|
44986
44986
|
}
|
|
44987
44987
|
}
|
|
44988
44988
|
getSubchannelString(subchannel) {
|
|
@@ -45242,9 +45242,9 @@ var require_resolving_call = __commonJS({
|
|
|
45242
45242
|
get traceEnabled() {
|
|
45243
45243
|
return logging.isTracerEnabled(TRACER_NAME);
|
|
45244
45244
|
}
|
|
45245
|
-
trace(
|
|
45245
|
+
trace(text25) {
|
|
45246
45246
|
if (this.traceEnabled) {
|
|
45247
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " +
|
|
45247
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text25);
|
|
45248
45248
|
}
|
|
45249
45249
|
}
|
|
45250
45250
|
runDeadlineTimer() {
|
|
@@ -45633,9 +45633,9 @@ var require_retrying_call = __commonJS({
|
|
|
45633
45633
|
get traceEnabled() {
|
|
45634
45634
|
return logging.isTracerEnabled(TRACER_NAME);
|
|
45635
45635
|
}
|
|
45636
|
-
trace(
|
|
45636
|
+
trace(text25) {
|
|
45637
45637
|
if (this.traceEnabled) {
|
|
45638
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " +
|
|
45638
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text25);
|
|
45639
45639
|
}
|
|
45640
45640
|
}
|
|
45641
45641
|
reportStatus(statusObject) {
|
|
@@ -46502,9 +46502,9 @@ var require_internal_channel = __commonJS({
|
|
|
46502
46502
|
get traceEnabled() {
|
|
46503
46503
|
return (0, logging_1.isTracerEnabled)("channel");
|
|
46504
46504
|
}
|
|
46505
|
-
trace(
|
|
46505
|
+
trace(text25, verbosityOverride) {
|
|
46506
46506
|
if (this.traceEnabled) {
|
|
46507
|
-
(0, logging_1.trace)(verbosityOverride !== null && verbosityOverride !== void 0 ? verbosityOverride : constants_1.LogVerbosity.DEBUG, "channel", "(" + this.channelzRef.id + ") " + (0, uri_parser_1.uriToString)(this.target) + " " +
|
|
46507
|
+
(0, logging_1.trace)(verbosityOverride !== null && verbosityOverride !== void 0 ? verbosityOverride : constants_1.LogVerbosity.DEBUG, "channel", "(" + this.channelzRef.id + ") " + (0, uri_parser_1.uriToString)(this.target) + " " + text25);
|
|
46508
46508
|
}
|
|
46509
46509
|
}
|
|
46510
46510
|
callRefTimerRef() {
|
|
@@ -47748,8 +47748,8 @@ var require_server_interceptors = __commonJS({
|
|
|
47748
47748
|
var orca_1 = require_orca();
|
|
47749
47749
|
var environment_1 = require_environment();
|
|
47750
47750
|
var TRACER_NAME = "server_call";
|
|
47751
|
-
function trace(
|
|
47752
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME,
|
|
47751
|
+
function trace(text25) {
|
|
47752
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
47753
47753
|
}
|
|
47754
47754
|
var ServerListenerBuilder = class {
|
|
47755
47755
|
constructor() {
|
|
@@ -48565,8 +48565,8 @@ var require_server = __commonJS({
|
|
|
48565
48565
|
var { HTTP2_HEADER_PATH } = http2.constants;
|
|
48566
48566
|
var TRACER_NAME = "server";
|
|
48567
48567
|
var kMaxAge = Buffer.from("max_age");
|
|
48568
|
-
function serverCallTrace(
|
|
48569
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, "server_call",
|
|
48568
|
+
function serverCallTrace(text25) {
|
|
48569
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, "server_call", text25);
|
|
48570
48570
|
}
|
|
48571
48571
|
function noop() {
|
|
48572
48572
|
}
|
|
@@ -48705,11 +48705,11 @@ var require_server = __commonJS({
|
|
|
48705
48705
|
};
|
|
48706
48706
|
return socketInfo;
|
|
48707
48707
|
}
|
|
48708
|
-
trace(
|
|
48709
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " +
|
|
48708
|
+
trace(text25) {
|
|
48709
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + text25);
|
|
48710
48710
|
}
|
|
48711
|
-
keepaliveTrace(
|
|
48712
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " +
|
|
48711
|
+
keepaliveTrace(text25) {
|
|
48712
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + text25);
|
|
48713
48713
|
}
|
|
48714
48714
|
addProtoService() {
|
|
48715
48715
|
throw new Error("Not implemented. Use addService() instead");
|
|
@@ -50048,8 +50048,8 @@ var require_load_balancer_pick_first = __commonJS({
|
|
|
50048
50048
|
var net_1 = __require("net");
|
|
50049
50049
|
var call_interface_1 = require_call_interface();
|
|
50050
50050
|
var TRACER_NAME = "pick_first";
|
|
50051
|
-
function trace(
|
|
50052
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME,
|
|
50051
|
+
function trace(text25) {
|
|
50052
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
50053
50053
|
}
|
|
50054
50054
|
var TYPE_NAME = "pick_first";
|
|
50055
50055
|
var CONNECTION_DELAY_INTERVAL_MS = 250;
|
|
@@ -50460,8 +50460,8 @@ var require_certificate_provider = __commonJS({
|
|
|
50460
50460
|
var constants_1 = require_constants();
|
|
50461
50461
|
var util_1 = __require("util");
|
|
50462
50462
|
var TRACER_NAME = "certificate_provider";
|
|
50463
|
-
function trace(
|
|
50464
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME,
|
|
50463
|
+
function trace(text25) {
|
|
50464
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
50465
50465
|
}
|
|
50466
50466
|
var readFilePromise = (0, util_1.promisify)(fs.readFile);
|
|
50467
50467
|
var FileWatcherCertificateProvider = class {
|
|
@@ -50760,8 +50760,8 @@ var require_resolver_ip = __commonJS({
|
|
|
50760
50760
|
var uri_parser_1 = require_uri_parser();
|
|
50761
50761
|
var logging = require_logging();
|
|
50762
50762
|
var TRACER_NAME = "ip_resolver";
|
|
50763
|
-
function trace(
|
|
50764
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME,
|
|
50763
|
+
function trace(text25) {
|
|
50764
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
50765
50765
|
}
|
|
50766
50766
|
var IPV4_SCHEME = "ipv4";
|
|
50767
50767
|
var IPV6_SCHEME = "ipv6";
|
|
@@ -50851,8 +50851,8 @@ var require_load_balancer_round_robin = __commonJS({
|
|
|
50851
50851
|
var subchannel_address_1 = require_subchannel_address();
|
|
50852
50852
|
var load_balancer_pick_first_1 = require_load_balancer_pick_first();
|
|
50853
50853
|
var TRACER_NAME = "round_robin";
|
|
50854
|
-
function trace(
|
|
50855
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME,
|
|
50854
|
+
function trace(text25) {
|
|
50855
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
50856
50856
|
}
|
|
50857
50857
|
var TYPE_NAME = "round_robin";
|
|
50858
50858
|
var RoundRobinLoadBalancingConfig = class _RoundRobinLoadBalancingConfig {
|
|
@@ -51030,8 +51030,8 @@ var require_load_balancer_outlier_detection = __commonJS({
|
|
|
51030
51030
|
var subchannel_interface_1 = require_subchannel_interface();
|
|
51031
51031
|
var logging = require_logging();
|
|
51032
51032
|
var TRACER_NAME = "outlier_detection";
|
|
51033
|
-
function trace(
|
|
51034
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME,
|
|
51033
|
+
function trace(text25) {
|
|
51034
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
51035
51035
|
}
|
|
51036
51036
|
var TYPE_NAME = "outlier_detection";
|
|
51037
51037
|
var OUTLIER_DETECTION_ENABLED = ((_a3 = process.env.GRPC_EXPERIMENTAL_ENABLE_OUTLIER_DETECTION) !== null && _a3 !== void 0 ? _a3 : "true") === "true";
|
|
@@ -51630,8 +51630,8 @@ var require_load_balancer_weighted_round_robin = __commonJS({
|
|
|
51630
51630
|
var priority_queue_1 = require_priority_queue();
|
|
51631
51631
|
var subchannel_address_1 = require_subchannel_address();
|
|
51632
51632
|
var TRACER_NAME = "weighted_round_robin";
|
|
51633
|
-
function trace(
|
|
51634
|
-
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME,
|
|
51633
|
+
function trace(text25) {
|
|
51634
|
+
logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text25);
|
|
51635
51635
|
}
|
|
51636
51636
|
var TYPE_NAME = "weighted_round_robin";
|
|
51637
51637
|
var DEFAULT_OOB_REPORTING_PERIOD_MS = 1e4;
|
|
@@ -65236,8 +65236,8 @@ function ko_default() {
|
|
|
65236
65236
|
}
|
|
65237
65237
|
|
|
65238
65238
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/lt.js
|
|
65239
|
-
var capitalizeFirstCharacter = (
|
|
65240
|
-
return
|
|
65239
|
+
var capitalizeFirstCharacter = (text25) => {
|
|
65240
|
+
return text25.charAt(0).toUpperCase() + text25.slice(1);
|
|
65241
65241
|
};
|
|
65242
65242
|
function getUnitTypeFromNumber(number7) {
|
|
65243
65243
|
const abs = Math.abs(number7);
|
|
@@ -85450,7 +85450,7 @@ var require_core$3 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
85450
85450
|
}
|
|
85451
85451
|
errorsText(errors2 = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
85452
85452
|
if (!errors2 || errors2.length === 0) return "No errors";
|
|
85453
|
-
return errors2.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((
|
|
85453
|
+
return errors2.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text25, msg) => text25 + separator + msg);
|
|
85454
85454
|
}
|
|
85455
85455
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
85456
85456
|
const rules = this.RULES.all;
|
|
@@ -90853,21 +90853,21 @@ async function readRequestBody(request, maxBytes = DEFAULT_MAX_REQUEST_BODY_SIZE
|
|
|
90853
90853
|
const reader = request.body.getReader();
|
|
90854
90854
|
const decoder = new TextDecoder();
|
|
90855
90855
|
let received = 0;
|
|
90856
|
-
let
|
|
90856
|
+
let text25 = "";
|
|
90857
90857
|
try {
|
|
90858
90858
|
for (; ; ) {
|
|
90859
90859
|
const { done, value: value4 } = await reader.read();
|
|
90860
90860
|
if (done) break;
|
|
90861
90861
|
received += value4.byteLength;
|
|
90862
90862
|
if (received > maxBytes) return { tooLarge: true };
|
|
90863
|
-
|
|
90863
|
+
text25 += decoder.decode(value4, { stream: true });
|
|
90864
90864
|
}
|
|
90865
90865
|
} finally {
|
|
90866
90866
|
reader.releaseLock();
|
|
90867
90867
|
}
|
|
90868
90868
|
return {
|
|
90869
90869
|
tooLarge: false,
|
|
90870
|
-
text:
|
|
90870
|
+
text: text25 + decoder.decode()
|
|
90871
90871
|
};
|
|
90872
90872
|
}
|
|
90873
90873
|
var WebStandardStreamableHTTPServerTransport = class {
|
|
@@ -91961,6 +91961,7 @@ var EXECUTION_SUPPORT = {
|
|
|
91961
91961
|
"--compare": sceneOnly,
|
|
91962
91962
|
"--min-pass-rate": sceneOnly,
|
|
91963
91963
|
"--strict": sceneOnly,
|
|
91964
|
+
"--allow-simulated": sceneOnly,
|
|
91964
91965
|
"--seed": sceneOnly,
|
|
91965
91966
|
"--out": thisComputer,
|
|
91966
91967
|
"--detach": sceneOnly,
|
|
@@ -92052,9 +92053,9 @@ var NUMBER = new RegExp(
|
|
|
92052
92053
|
String.raw`(?<![\p{L}\p{N}_.,]|\p{L}[-−–+/_])(?<open>\()?(?<sign>[-−–+])?(?:(?<before>${CURRENCY})[ \u00A0]?)?(?<minus>[-−–])?(?<inner>\()?` + String.raw`(?<digits>\d{1,3}(?:,\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?)(?!\p{N}|[eE][-+]?\d|,\d{3}|\.\d)` + String.raw`(?:[ \u00A0]?(?<after>${CODES.join("|")}|[${SYMBOLS}]))?(?<close>\))?`,
|
|
92053
92054
|
"gu"
|
|
92054
92055
|
);
|
|
92055
|
-
function readNumbers(
|
|
92056
|
+
function readNumbers(text25) {
|
|
92056
92057
|
const numbers2 = [];
|
|
92057
|
-
for (const match3 of
|
|
92058
|
+
for (const match3 of text25.normalize("NFKC").matchAll(NUMBER)) {
|
|
92058
92059
|
const { open: open2, sign: sign3, before, minus, inner, digits, after, close } = match3.groups;
|
|
92059
92060
|
const parenthesized = (open2 !== void 0 || inner !== void 0) && close !== void 0;
|
|
92060
92061
|
const amount3 = before !== void 0 || after !== void 0 || /[,.]/.test(digits);
|
|
@@ -92074,22 +92075,22 @@ function numberMatches(number7, value4, tolerance) {
|
|
|
92074
92075
|
return near(number7.value) || number7.either === true && near(-number7.value);
|
|
92075
92076
|
}
|
|
92076
92077
|
function plainNumber(value4) {
|
|
92077
|
-
const
|
|
92078
|
-
return
|
|
92078
|
+
const text25 = String(value4);
|
|
92079
|
+
return text25.includes("e") ? value4.toLocaleString("en-US", { useGrouping: false, maximumFractionDigits: 20 }) : text25;
|
|
92079
92080
|
}
|
|
92080
92081
|
function answerText(output2) {
|
|
92081
92082
|
if (output2 === void 0 || output2 === null) return "";
|
|
92082
92083
|
if (typeof output2 === "string") return output2;
|
|
92083
92084
|
if (typeof output2 === "number") return Number.isFinite(output2) ? plainNumber(output2) : String(output2);
|
|
92084
|
-
if (Array.isArray(output2)) return output2.map(answerText).filter((
|
|
92085
|
+
if (Array.isArray(output2)) return output2.map(answerText).filter((text25) => text25 !== "").join("\n");
|
|
92085
92086
|
if (typeof output2 === "object") {
|
|
92086
|
-
return Object.entries(output2).map(([key4, value4]) => [key4, answerText(value4)]).filter(([,
|
|
92087
|
-
${
|
|
92087
|
+
return Object.entries(output2).map(([key4, value4]) => [key4, answerText(value4)]).filter(([, text25]) => text25 !== "").map(([key4, text25]) => text25.includes("\n") ? `${key4}:
|
|
92088
|
+
${text25}` : `${key4}: ${text25}`).join("\n");
|
|
92088
92089
|
}
|
|
92089
92090
|
return String(output2);
|
|
92090
92091
|
}
|
|
92091
92092
|
var AnswerNumberSchema = external_exports.strictObject({
|
|
92092
|
-
value: external_exports.union([external_exports.number(), external_exports.string().refine((
|
|
92093
|
+
value: external_exports.union([external_exports.number(), external_exports.string().refine((text25) => readNumbers(text25).length === 1, 'a number, or one number written as text, e.g. "1,240.00" or "(300.00)"')]).describe('The number the answer must state: a number, or one number as text ("1,240.00") to keep its decimal places'),
|
|
92093
92094
|
tolerance: external_exports.number().nonnegative().optional().describe("How far the stated number may be from value; default: half the last decimal place of value (1200.00 \u2192 0.005, 1240.5 \u2192 0.05, 1200 \u2192 0.5)")
|
|
92094
92095
|
});
|
|
92095
92096
|
var texts = external_exports.union([external_exports.string().min(1), external_exports.array(external_exports.string().min(1)).min(1)]);
|
|
@@ -92128,8 +92129,8 @@ function decimalsOf(value4) {
|
|
|
92128
92129
|
const [mantissa, exponent] = String(Math.abs(value4)).split("e");
|
|
92129
92130
|
return Math.max(0, (mantissa.split(".")[1]?.length ?? 0) - Number(exponent ?? 0));
|
|
92130
92131
|
}
|
|
92131
|
-
function comparableText(
|
|
92132
|
-
const plain3 =
|
|
92132
|
+
function comparableText(text25, sensitive = false) {
|
|
92133
|
+
const plain3 = text25.normalize("NFKC").replace(/[‘’‛′]/g, "'").replace(/[“”„″]/g, '"').replace(/[‐‑‒–—−]/g, "-").replace(/\s+/g, " ").trim();
|
|
92133
92134
|
return sensitive ? plain3 : plain3.toLowerCase();
|
|
92134
92135
|
}
|
|
92135
92136
|
|
|
@@ -92797,20 +92798,20 @@ var RANGE_HINT = "use <min>..<max> of simulated time, such as 3m..12m, or one du
|
|
|
92797
92798
|
var RATE_RE = /^(\d+(?:\.\d+)?)(?:\.\.(\d+(?:\.\d+)?))?\/(m|h|d)$/;
|
|
92798
92799
|
var RATE_HINT = "use <min>..<max>/<unit> or <n>/<unit> with unit m, h or d, such as 0..2/h";
|
|
92799
92800
|
var MAX_NOISE_PER_HOUR = 60;
|
|
92800
|
-
function parseDurationRange(
|
|
92801
|
-
const parts3 =
|
|
92802
|
-
if (parts3.length > 2 || parts3.some((part) => part === "")) throw new AnchaError("SCENE_INVALID", `invalid duration range "${
|
|
92801
|
+
function parseDurationRange(text25) {
|
|
92802
|
+
const parts3 = text25.split("..");
|
|
92803
|
+
if (parts3.length > 2 || parts3.some((part) => part === "")) throw new AnchaError("SCENE_INVALID", `invalid duration range "${text25}"`, { hint: RANGE_HINT });
|
|
92803
92804
|
const minMs = parseDuration(parts3[0]), maxMs = parseDuration(parts3[1] ?? parts3[0]);
|
|
92804
|
-
if (minMs < 0 || maxMs < minMs) throw new AnchaError("SCENE_INVALID", `invalid duration range "${
|
|
92805
|
+
if (minMs < 0 || maxMs < minMs) throw new AnchaError("SCENE_INVALID", `invalid duration range "${text25}": need 0 <= min <= max`, { hint: RANGE_HINT });
|
|
92805
92806
|
return { minMs, maxMs };
|
|
92806
92807
|
}
|
|
92807
|
-
function parseRate(
|
|
92808
|
-
const match3 = RATE_RE.exec(
|
|
92809
|
-
if (!match3) throw new AnchaError("SCENE_INVALID", `invalid rate "${
|
|
92808
|
+
function parseRate(text25) {
|
|
92809
|
+
const match3 = RATE_RE.exec(text25);
|
|
92810
|
+
if (!match3) throw new AnchaError("SCENE_INVALID", `invalid rate "${text25}"`, { hint: RATE_HINT });
|
|
92810
92811
|
const perHour = { m: 60, h: 1, d: 1 / 24 }[match3[3]];
|
|
92811
92812
|
const minPerHour = Number(match3[1]) * perHour, maxPerHour = Number(match3[2] ?? match3[1]) * perHour;
|
|
92812
|
-
if (maxPerHour < minPerHour) throw new AnchaError("SCENE_INVALID", `invalid rate "${
|
|
92813
|
-
if (maxPerHour > MAX_NOISE_PER_HOUR) throw new AnchaError("SCENE_INVALID", `invalid rate "${
|
|
92813
|
+
if (maxPerHour < minPerHour) throw new AnchaError("SCENE_INVALID", `invalid rate "${text25}": min is above max`, { hint: RATE_HINT });
|
|
92814
|
+
if (maxPerHour > MAX_NOISE_PER_HOUR) throw new AnchaError("SCENE_INVALID", `invalid rate "${text25}": at most ${MAX_NOISE_PER_HOUR} per hour`, { hint: RATE_HINT });
|
|
92814
92815
|
return { minPerHour, maxPerHour };
|
|
92815
92816
|
}
|
|
92816
92817
|
function parsed(parse15, description2) {
|
|
@@ -93971,9 +93972,9 @@ var GMAIL_SCOPES = {
|
|
|
93971
93972
|
var scopeValues = Object.values(GMAIL_SCOPES);
|
|
93972
93973
|
var EMAIL = /^[^\s<>@",;:()[\]\\]+@[^\s<>@",;:()[\]\\]+\.[^\s<>@",;:()[\]\\]+$/;
|
|
93973
93974
|
function parseGmailAddress(value4) {
|
|
93974
|
-
const
|
|
93975
|
-
if (EMAIL.test(
|
|
93976
|
-
const match3 = /^(.*?)\s*<([^<>]+)>$/.exec(
|
|
93975
|
+
const text25 = value4.trim();
|
|
93976
|
+
if (EMAIL.test(text25)) return { name: "", email: text25 };
|
|
93977
|
+
const match3 = /^(.*?)\s*<([^<>]+)>$/.exec(text25);
|
|
93977
93978
|
if (!match3 || !EMAIL.test(match3[2].trim())) return void 0;
|
|
93978
93979
|
let name5 = match3[1].trim();
|
|
93979
93980
|
if (name5.startsWith('"') && name5.endsWith('"') && name5.length >= 2) name5 = name5.slice(1, -1).replace(/\\(.)/g, "$1");
|
|
@@ -99704,16 +99705,16 @@ var FormulaSyntaxError = class extends Error {
|
|
|
99704
99705
|
};
|
|
99705
99706
|
var FormulaGap = class extends Error {
|
|
99706
99707
|
};
|
|
99707
|
-
function tokenize(
|
|
99708
|
+
function tokenize(text25) {
|
|
99708
99709
|
const out = [];
|
|
99709
99710
|
let i = 0;
|
|
99710
99711
|
const quoted3 = (close, what) => {
|
|
99711
99712
|
let j = i + 1, value4 = "";
|
|
99712
99713
|
for (; ; ) {
|
|
99713
|
-
if (j >=
|
|
99714
|
-
const c =
|
|
99715
|
-
if (c === "\\" && j + 1 <
|
|
99716
|
-
const e =
|
|
99714
|
+
if (j >= text25.length) throw new FormulaSyntaxError(`unterminated ${what}`);
|
|
99715
|
+
const c = text25[j];
|
|
99716
|
+
if (c === "\\" && j + 1 < text25.length) {
|
|
99717
|
+
const e = text25[j + 1];
|
|
99717
99718
|
value4 += e === "n" ? "\n" : e === "t" ? " " : e;
|
|
99718
99719
|
j += 2;
|
|
99719
99720
|
continue;
|
|
@@ -99725,8 +99726,8 @@ function tokenize(text24) {
|
|
|
99725
99726
|
i = j + 1;
|
|
99726
99727
|
return value4;
|
|
99727
99728
|
};
|
|
99728
|
-
while (i <
|
|
99729
|
-
const c =
|
|
99729
|
+
while (i < text25.length) {
|
|
99730
|
+
const c = text25[i], rest2 = text25.slice(i);
|
|
99730
99731
|
if (/\s/.test(c)) {
|
|
99731
99732
|
i++;
|
|
99732
99733
|
continue;
|
|
@@ -99767,8 +99768,8 @@ function tokenize(text24) {
|
|
|
99767
99768
|
out.push({ kind: "end" });
|
|
99768
99769
|
return out;
|
|
99769
99770
|
}
|
|
99770
|
-
function parseFormula(
|
|
99771
|
-
const tokens3 = tokenize(
|
|
99771
|
+
function parseFormula(text25) {
|
|
99772
|
+
const tokens3 = tokenize(text25);
|
|
99772
99773
|
let at3 = 0;
|
|
99773
99774
|
const isOp = (value4) => {
|
|
99774
99775
|
const token4 = tokens3[at3];
|
|
@@ -99852,8 +99853,8 @@ function printFormula(node5, field5 = (name5) => name5) {
|
|
|
99852
99853
|
case "unary":
|
|
99853
99854
|
return `${item2.op}${print(item2.arg, 5)}`;
|
|
99854
99855
|
case "binary": {
|
|
99855
|
-
const precedence = PRECEDENCE[item2.op],
|
|
99856
|
-
return precedence < parent2 ? `(${
|
|
99856
|
+
const precedence = PRECEDENCE[item2.op], text25 = `${print(item2.left, precedence)} ${item2.op} ${print(item2.right, precedence + 1)}`;
|
|
99857
|
+
return precedence < parent2 ? `(${text25})` : text25;
|
|
99857
99858
|
}
|
|
99858
99859
|
}
|
|
99859
99860
|
};
|
|
@@ -99908,8 +99909,8 @@ function num(value4) {
|
|
|
99908
99909
|
if (typeof value4 === "number") return value4;
|
|
99909
99910
|
if (typeof value4 === "boolean") return value4 ? 1 : 0;
|
|
99910
99911
|
if (typeof value4 === "string") {
|
|
99911
|
-
const
|
|
99912
|
-
return !
|
|
99912
|
+
const text25 = value4.trim();
|
|
99913
|
+
return !text25 ? 0 : NUMERIC.test(text25) ? Number(text25) : NaN;
|
|
99913
99914
|
}
|
|
99914
99915
|
return NaN;
|
|
99915
99916
|
}
|
|
@@ -99929,8 +99930,8 @@ function validDay(y, m, d) {
|
|
|
99929
99930
|
const ms = utc(y, m, d), date10 = new Date(ms);
|
|
99930
99931
|
return date10.getUTCFullYear() === y && date10.getUTCMonth() === m && date10.getUTCDate() === d ? ms : null;
|
|
99931
99932
|
}
|
|
99932
|
-
function parseFormulaDate(
|
|
99933
|
-
const value4 =
|
|
99933
|
+
function parseFormulaDate(text25) {
|
|
99934
|
+
const value4 = text25.trim();
|
|
99934
99935
|
let match3 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value4);
|
|
99935
99936
|
if (match3) {
|
|
99936
99937
|
const ms = validDay(+match3[1], +match3[2] - 1, +match3[3]);
|
|
@@ -99976,8 +99977,8 @@ function equal(a, b) {
|
|
|
99976
99977
|
}
|
|
99977
99978
|
if (typeof a === "string" && typeof b === "string") return a === b;
|
|
99978
99979
|
if (typeof a === "string" || typeof b === "string") {
|
|
99979
|
-
const
|
|
99980
|
-
return numericText(
|
|
99980
|
+
const text25 = typeof a === "string" ? a : b, other = typeof a === "string" ? b : a;
|
|
99981
|
+
return numericText(text25) ? Number(text25.trim()) === num(other) : formulaText(other) === text25;
|
|
99981
99982
|
}
|
|
99982
99983
|
return num(a) === num(b);
|
|
99983
99984
|
}
|
|
@@ -100028,8 +100029,8 @@ var UNITS = {
|
|
|
100028
100029
|
};
|
|
100029
100030
|
var FIXED = { milliseconds: 1, seconds: 1e3, minutes: 6e4, hours: 36e5, days: 864e5, weeks: 6048e5 };
|
|
100030
100031
|
var unitOf = (value4) => {
|
|
100031
|
-
const
|
|
100032
|
-
return UNITS[
|
|
100032
|
+
const text25 = formulaText(value4).trim();
|
|
100033
|
+
return UNITS[text25] ?? UNITS[text25.toLowerCase()] ?? null;
|
|
100033
100034
|
};
|
|
100034
100035
|
function addMonths(ms, months) {
|
|
100035
100036
|
const date10 = new Date(ms), day9 = date10.getUTCDate();
|
|
@@ -100137,7 +100138,7 @@ function formatFormulaDate(ms, format2) {
|
|
|
100137
100138
|
};
|
|
100138
100139
|
return format2.replace(FORMAT_TOKENS, (part, literal2) => literal2 ?? token4(part));
|
|
100139
100140
|
}
|
|
100140
|
-
function parseWithFormat(
|
|
100141
|
+
function parseWithFormat(text25, format2) {
|
|
100141
100142
|
const parts3 = [];
|
|
100142
100143
|
let pattern = "";
|
|
100143
100144
|
let last = 0;
|
|
@@ -100155,7 +100156,7 @@ function parseWithFormat(text24, format2) {
|
|
|
100155
100156
|
parts3.push(token4);
|
|
100156
100157
|
}
|
|
100157
100158
|
pattern += format2.slice(last).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
100158
|
-
const match3 = new RegExp(`^${pattern}$`).exec(
|
|
100159
|
+
const match3 = new RegExp(`^${pattern}$`).exec(text25.trim());
|
|
100159
100160
|
if (!match3) return null;
|
|
100160
100161
|
let y = 1970, mo = 0, d = 1, h = 0, mi = 0, s2 = 0, pm = null;
|
|
100161
100162
|
parts3.forEach((token4, i) => {
|
|
@@ -100219,16 +100220,16 @@ var FUNCTIONS = {
|
|
|
100219
100220
|
ISERROR: { min: 1, max: 1, run: (args) => isFormulaError(args[0]) || typeof args[0] === "number" && Number.isNaN(args[0]) },
|
|
100220
100221
|
// text
|
|
100221
100222
|
CONCATENATE: { min: 1, max: Infinity, run: (args) => args.map(formulaText).join("") },
|
|
100222
|
-
LEN: text1((
|
|
100223
|
-
LOWER: text1((
|
|
100224
|
-
UPPER: text1((
|
|
100225
|
-
TRIM: text1((
|
|
100223
|
+
LEN: text1((text25) => [...text25].length),
|
|
100224
|
+
LOWER: text1((text25) => text25.toLowerCase()),
|
|
100225
|
+
UPPER: text1((text25) => text25.toUpperCase()),
|
|
100226
|
+
TRIM: text1((text25) => text25.trim()),
|
|
100226
100227
|
T: { min: 1, max: 1, run: (args) => typeof single(args[0]) === "string" ? single(args[0]) : "" },
|
|
100227
|
-
ENCODE_URL_COMPONENT: text1((
|
|
100228
|
+
ENCODE_URL_COMPONENT: text1((text25) => encodeURIComponent(text25)),
|
|
100228
100229
|
LEFT: { min: 2, max: 2, run: (args) => formulaText(args[0]).slice(0, Math.max(0, num(args[1]))) },
|
|
100229
100230
|
RIGHT: { min: 2, max: 2, run: (args) => {
|
|
100230
|
-
const
|
|
100231
|
-
return n2 ?
|
|
100231
|
+
const text25 = formulaText(args[0]), n2 = Math.max(0, num(args[1]));
|
|
100232
|
+
return n2 ? text25.slice(-n2) : "";
|
|
100232
100233
|
} },
|
|
100233
100234
|
MID: { min: 3, max: 3, run: (args) => {
|
|
100234
100235
|
const start2 = Math.max(1, num(args[1]));
|
|
@@ -100243,20 +100244,20 @@ var FUNCTIONS = {
|
|
|
100243
100244
|
return at3 < 0 ? null : at3 + 1;
|
|
100244
100245
|
} },
|
|
100245
100246
|
SUBSTITUTE: { min: 3, max: 4, run: (args) => {
|
|
100246
|
-
const
|
|
100247
|
-
if (!old) return
|
|
100248
|
-
if (args[3] === void 0) return
|
|
100247
|
+
const text25 = formulaText(args[0]), old = formulaText(args[1]), replacement = formulaText(args[2]);
|
|
100248
|
+
if (!old) return text25;
|
|
100249
|
+
if (args[3] === void 0) return text25.split(old).join(replacement);
|
|
100249
100250
|
const index = num(args[3]);
|
|
100250
100251
|
let at3 = -1;
|
|
100251
100252
|
for (let i = 0; i < index; i++) {
|
|
100252
|
-
at3 =
|
|
100253
|
-
if (at3 < 0) return
|
|
100253
|
+
at3 = text25.indexOf(old, at3 + 1);
|
|
100254
|
+
if (at3 < 0) return text25;
|
|
100254
100255
|
}
|
|
100255
|
-
return
|
|
100256
|
+
return text25.slice(0, at3) + replacement + text25.slice(at3 + old.length);
|
|
100256
100257
|
} },
|
|
100257
100258
|
REPLACE: { min: 4, max: 4, run: (args) => {
|
|
100258
|
-
const
|
|
100259
|
-
return
|
|
100259
|
+
const text25 = formulaText(args[0]), start2 = Math.max(1, num(args[1])) - 1;
|
|
100260
|
+
return text25.slice(0, start2) + formulaText(args[3]) + text25.slice(start2 + Math.max(0, num(args[2])));
|
|
100260
100261
|
} },
|
|
100261
100262
|
REPT: { min: 2, max: 2, run: (args) => formulaText(args[0]).repeat(Math.max(0, Math.floor(num(args[1])) || 0)) },
|
|
100262
100263
|
REGEX_MATCH: { min: 2, max: 2, run: (args) => {
|
|
@@ -100358,9 +100359,9 @@ var FUNCTIONS = {
|
|
|
100358
100359
|
} },
|
|
100359
100360
|
DATETIME_PARSE: { min: 1, max: 3, run: (args) => {
|
|
100360
100361
|
if (args[2] !== void 0) throw new FormulaGap("DATETIME_PARSE() with a locale");
|
|
100361
|
-
const
|
|
100362
|
-
if (!
|
|
100363
|
-
return (args[1] === void 0 ? parseFormulaDate(
|
|
100362
|
+
const text25 = formulaText(args[0]);
|
|
100363
|
+
if (!text25) return null;
|
|
100364
|
+
return (args[1] === void 0 ? parseFormulaDate(text25) : parseWithFormat(text25, formulaText(args[1]))) ?? err();
|
|
100364
100365
|
} },
|
|
100365
100366
|
DATESTR: { min: 1, max: 1, run: (args) => {
|
|
100366
100367
|
const date10 = dateArg(args[0]);
|
|
@@ -100643,9 +100644,9 @@ var AirtableSeedSchema = external_exports.strictObject({
|
|
|
100643
100644
|
if (new Set(entry2.fields.map((item2) => lower4(item2.name))).size !== entry2.fields.length) issue8([...at3, "fields"], "duplicate field name");
|
|
100644
100645
|
if (!PRIMARY_TYPES.has(entry2.fields[0].type)) issue8([...at3, "fields", 0, "type"], `a ${entry2.fields[0].type} field cannot be the primary field`);
|
|
100645
100646
|
const has2 = (fieldName) => fields11.has(fieldName);
|
|
100646
|
-
const formula = (
|
|
100647
|
+
const formula = (text25, path4, vars = [], hasField = has2) => {
|
|
100647
100648
|
try {
|
|
100648
|
-
checkFormula(parseFormula(
|
|
100649
|
+
checkFormula(parseFormula(text25), hasField, vars);
|
|
100649
100650
|
} catch (error64) {
|
|
100650
100651
|
if (error64 instanceof FormulaSyntaxError || error64 instanceof FormulaGap) issue8(path4, `invalid formula: ${error64.message}`);
|
|
100651
100652
|
else throw error64;
|
|
@@ -104315,14 +104316,14 @@ function parseChecks(input5) {
|
|
|
104315
104316
|
}
|
|
104316
104317
|
var PROSE_KEYS = /* @__PURE__ */ new Set(["judge", "task", "text", "value", "about", "message"]);
|
|
104317
104318
|
var FIX_SHOWN = 120;
|
|
104318
|
-
function cutProseIssues(doc,
|
|
104319
|
+
function cutProseIssues(doc, text25, lineCounter) {
|
|
104319
104320
|
const issues = [];
|
|
104320
104321
|
(0, import_yaml.visit)(doc, {
|
|
104321
104322
|
Pair(_, pair, ancestors2) {
|
|
104322
104323
|
const value4 = pair.value;
|
|
104323
104324
|
if (!(0, import_yaml.isScalar)(pair.key) || !PROSE_KEYS.has(String(pair.key.value)) || !(0, import_yaml.isScalar)(value4)) return;
|
|
104324
104325
|
if (value4.type !== "PLAIN" || typeof value4.value !== "string" || !value4.range) return;
|
|
104325
|
-
const comment10 = /^[ \t]+#([^\r\n]*)/.exec(
|
|
104326
|
+
const comment10 = /^[ \t]+#([^\r\n]*)/.exec(text25.slice(value4.range[1]));
|
|
104326
104327
|
if (comment10 === null) return;
|
|
104327
104328
|
const key4 = String(pair.key.value);
|
|
104328
104329
|
const { line: line2 } = lineCounter.linePos(value4.range[0]);
|
|
@@ -104345,19 +104346,19 @@ function pathOf(ancestors2, pair) {
|
|
|
104345
104346
|
});
|
|
104346
104347
|
return formatPath([...segments3, String(pair.key.value)]);
|
|
104347
104348
|
}
|
|
104348
|
-
function parseSceneYaml(
|
|
104349
|
+
function parseSceneYaml(text25) {
|
|
104349
104350
|
const lineCounter = new import_yaml.LineCounter();
|
|
104350
|
-
const doc = (0, import_yaml.parseDocument)(
|
|
104351
|
+
const doc = (0, import_yaml.parseDocument)(text25, { lineCounter, prettyErrors: false });
|
|
104351
104352
|
if (doc.errors.length > 0) {
|
|
104352
104353
|
const issues = doc.errors.map((e) => {
|
|
104353
104354
|
const { line: line2, col: col2 } = lineCounter.linePos(e.pos[0]);
|
|
104354
104355
|
return { path: `line ${line2}, column ${col2}`, message: e.message };
|
|
104355
104356
|
});
|
|
104356
|
-
const atError = doc.errors.findIndex((e) =>
|
|
104357
|
+
const atError = doc.errors.findIndex((e) => text25[e.pos[0]] === "@");
|
|
104357
104358
|
if (atError >= 0) issues[atError].hint = "refs in a test use $, e.g. $alice \u2014 YAML reserves @";
|
|
104358
104359
|
throw sceneError(issues, doc.errors[0]);
|
|
104359
104360
|
}
|
|
104360
|
-
const cut = cutProseIssues(doc,
|
|
104361
|
+
const cut = cutProseIssues(doc, text25, lineCounter);
|
|
104361
104362
|
if (cut.length > 0) throw sceneError(cut);
|
|
104362
104363
|
return doc.toJS();
|
|
104363
104364
|
}
|
|
@@ -104441,6 +104442,20 @@ var WorldFileSchema = external_exports.strictObject({ version: external_exports.
|
|
|
104441
104442
|
var BODY_KEYS = Object.keys(body2);
|
|
104442
104443
|
var FILE_KEYS = ["version", "id", ...BODY_KEYS];
|
|
104443
104444
|
|
|
104445
|
+
// packages/core/src/company/profile.ts
|
|
104446
|
+
var text12 = (max) => external_exports.string().min(1).max(max).regex(/^[^\u0000-\u001f\u007f-\u009f]+$/u);
|
|
104447
|
+
var countries = new Set("AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BV BW BY BZ CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ DE DJ DK DM DO DZ EC EE EG EH ER ES ET FI FJ FK FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY HK HM HN HR HT HU ID IE IL IM IN IO IQ IR IS IT JE JM JO JP KE KG KH KI KM KN KP KR KW KY KZ LA LB LC LI LK LR LS LT LU LV LY MA MC MD ME MF MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ OM PA PE PF PG PH PK PL PM PN PR PS PT PW PY QA RE RO RS RU RW SA SB SC SD SE SG SH SI SJ SK SL SM SN SO SR SS ST SV SX SY SZ TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ UA UG UM US UY UZ VA VC VE VG VI VN VU WF WS YE YT ZA ZM ZW".split(" "));
|
|
104448
|
+
var CompanyProfileSchema = external_exports.strictObject({
|
|
104449
|
+
schemaVersion: external_exports.literal(1),
|
|
104450
|
+
name: text12(100),
|
|
104451
|
+
businessModel: external_exports.enum(["goods", "services", "mixed"]).nullable(),
|
|
104452
|
+
scale: external_exports.enum(["small", "medium", "large"]).nullable(),
|
|
104453
|
+
customerKinds: external_exports.array(text12(60)).max(8),
|
|
104454
|
+
vendorKinds: external_exports.array(text12(60)).max(8),
|
|
104455
|
+
offerings: external_exports.array(external_exports.strictObject({ name: text12(100), kind: external_exports.enum(["goods", "service"]) })).max(8),
|
|
104456
|
+
country: external_exports.enum([...countries]).nullable()
|
|
104457
|
+
});
|
|
104458
|
+
|
|
104444
104459
|
// packages/core/src/datasets/netsuite-pe/generate.ts
|
|
104445
104460
|
var ACCOUNTS = [
|
|
104446
104461
|
{ id: 1, number: "1000", name: "Operating Checking", type: "Bank" },
|
|
@@ -105231,9 +105246,9 @@ function netsuiteInferredCustomFields(seed43) {
|
|
|
105231
105246
|
var PRIVATE_KEY = /authorization|cookie|token|secret|password|api[_-]?key|app[_-]?key|routing[_-]?key|credential/i;
|
|
105232
105247
|
function cleanToolCompletion(value4, secrets = []) {
|
|
105233
105248
|
if (typeof value4 === "string") {
|
|
105234
|
-
let
|
|
105235
|
-
for (const secret of secrets) if (secret)
|
|
105236
|
-
return
|
|
105249
|
+
let text25 = value4.replace(/\bBearer\s+[^\s"'<>]+/gi, "Bearer [redacted]").replace(/\b(?:sk-[A-Za-z0-9_-]+|xox[baprs]-[A-Za-z0-9-]+)/g, "[redacted]").replace(/\b((?:api[_-]?key|access[_-]?token|password|secret)\s*[:=]\s*)[^\s,;"']+/gi, "$1[redacted]");
|
|
105250
|
+
for (const secret of secrets) if (secret) text25 = text25.replaceAll(secret, "[redacted]");
|
|
105251
|
+
return text25;
|
|
105237
105252
|
}
|
|
105238
105253
|
if (Array.isArray(value4)) return value4.map((v) => cleanToolCompletion(v, secrets));
|
|
105239
105254
|
if (value4 && typeof value4 === "object") return Object.fromEntries(Object.entries(value4).map(([k, v]) => [k, PRIVATE_KEY.test(k) ? "[redacted]" : cleanToolCompletion(v, secrets)]));
|
|
@@ -105243,9 +105258,9 @@ function toolSecrets(value4) {
|
|
|
105243
105258
|
if (!value4 || typeof value4 !== "object") return [];
|
|
105244
105259
|
return Object.entries(value4).flatMap(([key4, v]) => PRIVATE_KEY.test(key4) && typeof v === "string" ? [v] : toolSecrets(v));
|
|
105245
105260
|
}
|
|
105246
|
-
function toolErrorText(
|
|
105261
|
+
function toolErrorText(text25) {
|
|
105247
105262
|
let out = "", bytes2 = 0;
|
|
105248
|
-
for (const char of
|
|
105263
|
+
for (const char of text25) {
|
|
105249
105264
|
bytes2 += new TextEncoder().encode(char).length;
|
|
105250
105265
|
if (bytes2 > 4096) break;
|
|
105251
105266
|
out += char;
|
|
@@ -105304,8 +105319,8 @@ function functionCallFields(entry2) {
|
|
|
105304
105319
|
}
|
|
105305
105320
|
|
|
105306
105321
|
// backend/src/mcp/vendor-http.ts
|
|
105307
|
-
function mcpTextResult(
|
|
105308
|
-
return { isError, content: [{ type: "text", text:
|
|
105322
|
+
function mcpTextResult(text25, isError = false) {
|
|
105323
|
+
return { isError, content: [{ type: "text", text: text25 }] };
|
|
105309
105324
|
}
|
|
105310
105325
|
function mcpJsonResult(value4, isError = false) {
|
|
105311
105326
|
return {
|
|
@@ -105378,7 +105393,7 @@ function createVendorClient(info, tool, suffix = "", request = fetch) {
|
|
|
105378
105393
|
|
|
105379
105394
|
// backend/src/mcp/slack.ts
|
|
105380
105395
|
var id10 = external_exports.string().min(1).max(200);
|
|
105381
|
-
var
|
|
105396
|
+
var text13 = external_exports.string().max(4e4);
|
|
105382
105397
|
var cursor = external_exports.string().max(4096).optional();
|
|
105383
105398
|
var page2 = { limit: external_exports.number().int().min(1).max(1e3).optional(), cursor };
|
|
105384
105399
|
var window2 = { oldest: id10.optional(), latest: id10.optional(), inclusive: external_exports.boolean().optional() };
|
|
@@ -105392,8 +105407,8 @@ var definitions = [
|
|
|
105392
105407
|
["conversations.members", "List the members of a visible channel.", { ...channel2, ...page2 }],
|
|
105393
105408
|
["conversations.join", "Join an existing public channel.", channel2],
|
|
105394
105409
|
["conversations.create", "Create a channel and join it as the bot.", { name: external_exports.string().regex(/^[a-z0-9_-]{1,80}$/), is_private: external_exports.boolean().optional() }],
|
|
105395
|
-
["chat.postMessage", "Post a message or reply. Supply thread_ts to reply in a thread.", { ...channel2, text:
|
|
105396
|
-
["chat.update", "Edit a message authored by this bot. Text replaces prior blocks.", { ...channel2, ts: id10, text:
|
|
105410
|
+
["chat.postMessage", "Post a message or reply. Supply thread_ts to reply in a thread.", { ...channel2, text: text13, thread_ts: id10.optional() }],
|
|
105411
|
+
["chat.update", "Edit a message authored by this bot. Text replaces prior blocks.", { ...channel2, ts: id10, text: text13 }],
|
|
105397
105412
|
["chat.delete", "Delete a message authored by this bot.", { ...channel2, ts: id10 }],
|
|
105398
105413
|
["chat.getPermalink", "Get a message permalink. It is a fictional workspace address.", { ...channel2, message_ts: id10 }],
|
|
105399
105414
|
["reactions.add", "Add a named reaction to a message.", { ...channel2, timestamp: id10, name: id10 }],
|
|
@@ -105445,7 +105460,7 @@ Next cursor: ${cursor4}` : ""}`;
|
|
|
105445
105460
|
);
|
|
105446
105461
|
server.registerTool(
|
|
105447
105462
|
"slack_send_message",
|
|
105448
|
-
{ description: "Send a plain-text message to a Slack conversation.", inputSchema: external_exports.strictObject({ ...channelId, message:
|
|
105463
|
+
{ description: "Send a plain-text message to a Slack conversation.", inputSchema: external_exports.strictObject({ ...channelId, message: text13, thread_ts: id10.optional(), draft_id: id10.optional(), reply_broadcast: external_exports.boolean().optional() }), annotations: { readOnlyHint: false, openWorldHint: false } },
|
|
105449
105464
|
({ channel_id, message: message7, draft_id, ...args }, ctx) => draft_id ? Promise.resolve(mcpCoverageGap("slack_send_message", "Sending a saved draft is not implemented")) : /[*_~`\[\]]|(?:^|\n)(?:#{1,6} |[-+] |\d+\. )/.test(message7) ? Promise.resolve(mcpCoverageGap("slack_send_message", "Standard Markdown conversion is not implemented; use plain text")) : request("chat.postMessage", { channel: channel_id, text: message7, ...args }, ctx.mcpReq.signal, (value4) => `Message sent to <#${value4.channel}>. Timestamp: ${value4.ts}`)
|
|
105450
105465
|
);
|
|
105451
105466
|
server.registerTool("slack_read_user_profile", { description: "Read a Slack user profile. Omit user_id for the authenticated user.", inputSchema: external_exports.strictObject({ user_id: id10.optional() }), annotations: { readOnlyHint: true } }, async ({ user_id }, ctx) => {
|
|
@@ -105493,8 +105508,8 @@ var GITHUB_REPOSITORY_MCP_TOOLS = [
|
|
|
105493
105508
|
];
|
|
105494
105509
|
var slug3 = external_exports.string().regex(/^[A-Za-z0-9_.-]{1,100}$/);
|
|
105495
105510
|
var repo2 = { owner: slug3, repo: slug3 };
|
|
105496
|
-
var
|
|
105497
|
-
var branch =
|
|
105511
|
+
var text14 = external_exports.string().min(1);
|
|
105512
|
+
var branch = text14.refine(validGitBranch, "Invalid Git branch name");
|
|
105498
105513
|
var page3 = { page: external_exports.number().int().min(1).optional(), perPage: external_exports.number().int().min(1).max(100).optional() };
|
|
105499
105514
|
var read = { readOnlyHint: true, openWorldHint: false };
|
|
105500
105515
|
var write = { readOnlyHint: false, openWorldHint: false };
|
|
@@ -105547,11 +105562,11 @@ function registerGithubRepositoryTools(server, api3) {
|
|
|
105547
105562
|
inputSchema: external_exports.strictObject({
|
|
105548
105563
|
...repo2,
|
|
105549
105564
|
...page3,
|
|
105550
|
-
sha:
|
|
105551
|
-
author:
|
|
105552
|
-
path:
|
|
105553
|
-
since:
|
|
105554
|
-
until:
|
|
105565
|
+
sha: text14.optional(),
|
|
105566
|
+
author: text14.optional(),
|
|
105567
|
+
path: text14.optional(),
|
|
105568
|
+
since: text14.optional(),
|
|
105569
|
+
until: text14.optional(),
|
|
105555
105570
|
fields: external_exports.array(external_exports.enum(["sha", "html_url", "commit", "author", "committer"])).optional()
|
|
105556
105571
|
})
|
|
105557
105572
|
}, (args, context3) => {
|
|
@@ -105567,7 +105582,7 @@ function registerGithubRepositoryTools(server, api3) {
|
|
|
105567
105582
|
server.registerTool("get_commit", {
|
|
105568
105583
|
description: "Read a commit with no file detail, file stats, or full patches. Parent SHAs are not part of this vendor result.",
|
|
105569
105584
|
annotations: read,
|
|
105570
|
-
inputSchema: external_exports.strictObject({ ...repo2, ...page3, sha:
|
|
105585
|
+
inputSchema: external_exports.strictObject({ ...repo2, ...page3, sha: text14, detail: external_exports.enum(["none", "stats", "full_patch"]).optional() })
|
|
105571
105586
|
}, (args, context3) => invoke2("GET", `${root(args)}/commits/${pathSegments(args.sha)}`, void 0, context3.mcpReq.signal, (value4) => {
|
|
105572
105587
|
const size2 = args.perPage ?? 30, offset17 = ((args.page ?? 1) - 1) * size2;
|
|
105573
105588
|
return minimalCommit({ ...value4, files: value4.files?.slice(offset17, offset17 + size2) }, args.detail ?? "stats");
|
|
@@ -105585,8 +105600,8 @@ function registerGithubRepositoryTools(server, api3) {
|
|
|
105585
105600
|
inputSchema: external_exports.strictObject({
|
|
105586
105601
|
...repo2,
|
|
105587
105602
|
path: external_exports.string().optional(),
|
|
105588
|
-
ref:
|
|
105589
|
-
sha:
|
|
105603
|
+
ref: text14.optional(),
|
|
105604
|
+
sha: text14.optional(),
|
|
105590
105605
|
fields: external_exports.array(external_exports.enum(["type", "name", "path", "sha", "size", "html_url", "download_url", "url", "git_url", "target", "submodule_git_url"])).optional()
|
|
105591
105606
|
})
|
|
105592
105607
|
}, async (args, context3) => {
|
|
@@ -105636,7 +105651,7 @@ function registerGithubRepositoryTools(server, api3) {
|
|
|
105636
105651
|
server.registerTool("create_or_update_file", {
|
|
105637
105652
|
description: "Write raw text to one file on an existing branch. Supply the current blob SHA when updating.",
|
|
105638
105653
|
annotations: write,
|
|
105639
|
-
inputSchema: external_exports.strictObject({ ...repo2, path:
|
|
105654
|
+
inputSchema: external_exports.strictObject({ ...repo2, path: text14, content: text14, message: text14, branch, sha: text14.optional(), allow_symlink_write: external_exports.boolean().optional() })
|
|
105640
105655
|
}, async (args, context3) => {
|
|
105641
105656
|
if (!safePath(args.path)) return mcpJsonResult({ message: "Invalid repository path" }, true);
|
|
105642
105657
|
if (args.allow_symlink_write) return mcpCoverageGap("create_or_update_file", "Symbolic link writes are not implemented");
|
|
@@ -105654,7 +105669,7 @@ function registerGithubRepositoryTools(server, api3) {
|
|
|
105654
105669
|
server.registerTool("create_pull_request", {
|
|
105655
105670
|
description: "Open a same-repository pull request.",
|
|
105656
105671
|
annotations: write,
|
|
105657
|
-
inputSchema: external_exports.strictObject({ ...repo2, title:
|
|
105672
|
+
inputSchema: external_exports.strictObject({ ...repo2, title: text14, head: text14, base: text14, body: external_exports.string().optional(), draft: external_exports.boolean().optional(), maintainer_can_modify: external_exports.boolean().optional(), reviewers: external_exports.array(external_exports.string()).optional() })
|
|
105658
105673
|
}, async (args, context3) => {
|
|
105659
105674
|
if (args.reviewers?.length || args.maintainer_can_modify !== void 0) return mcpCoverageGap("create_pull_request", "Reviewer requests and maintainer edit controls are not implemented");
|
|
105660
105675
|
const response5 = await api3.call("POST", `${root(args)}/pulls`, { title: args.title, head: args.head, base: args.base, ...args.body !== void 0 ? { body: args.body } : {}, ...args.draft !== void 0 ? { draft: args.draft } : {} }, context3.mcpReq.signal);
|
|
@@ -105665,7 +105680,7 @@ function registerGithubRepositoryTools(server, api3) {
|
|
|
105665
105680
|
server.registerTool("merge_pull_request", {
|
|
105666
105681
|
description: "Merge an open pull request through the native merge path and its deployment hooks.",
|
|
105667
105682
|
annotations: write,
|
|
105668
|
-
inputSchema: external_exports.strictObject({ ...repo2, pullNumber: external_exports.number().int().min(1), commit_title: external_exports.string().optional(), commit_message: external_exports.string().optional(), merge_method: external_exports.enum(["merge", "squash", "rebase"]).optional(), expectedHeadSha:
|
|
105683
|
+
inputSchema: external_exports.strictObject({ ...repo2, pullNumber: external_exports.number().int().min(1), commit_title: external_exports.string().optional(), commit_message: external_exports.string().optional(), merge_method: external_exports.enum(["merge", "squash", "rebase"]).optional(), expectedHeadSha: text14.optional() })
|
|
105669
105684
|
}, (args, context3) => invoke2(
|
|
105670
105685
|
"PUT",
|
|
105671
105686
|
`${root(args)}/pulls/${args.pullNumber}/merge`,
|
|
@@ -105956,7 +105971,7 @@ var DATADOG_MCP_OPERATIONS = [
|
|
|
105956
105971
|
];
|
|
105957
105972
|
var DATADOG_MCP_TOOL_NAMES = DATADOG_MCP_OPERATIONS;
|
|
105958
105973
|
var read3 = { readOnlyHint: true, destructiveHint: false, openWorldHint: false };
|
|
105959
|
-
var
|
|
105974
|
+
var text15 = external_exports.string().max(16e3);
|
|
105960
105975
|
var integer3 = external_exports.number().int().nonnegative();
|
|
105961
105976
|
var schemaNote = " Native API.";
|
|
105962
105977
|
var params2 = (value4) => new URLSearchParams(Object.entries(value4).filter(([, v]) => v !== void 0).map(([key4, value5]) => [key4, String(value5)]));
|
|
@@ -105972,11 +105987,11 @@ function datadogMcpServer(info, request) {
|
|
|
105972
105987
|
annotations: read3,
|
|
105973
105988
|
inputSchema: external_exports.strictObject({
|
|
105974
105989
|
monitor_id: integer3.optional(),
|
|
105975
|
-
name:
|
|
105976
|
-
monitor_tags:
|
|
105990
|
+
name: text15.optional(),
|
|
105991
|
+
monitor_tags: text15.optional(),
|
|
105977
105992
|
page: integer3.optional(),
|
|
105978
105993
|
page_size: integer3.min(1).max(1e3).optional(),
|
|
105979
|
-
group_states:
|
|
105994
|
+
group_states: text15.optional()
|
|
105980
105995
|
})
|
|
105981
105996
|
}, async (args, context3) => {
|
|
105982
105997
|
const { monitor_id, ...query10 } = args;
|
|
@@ -105988,7 +106003,7 @@ function datadogMcpServer(info, request) {
|
|
|
105988
106003
|
server.registerTool("get_datadog_metric", {
|
|
105989
106004
|
description: "Query one native metric expression with integer epoch seconds from/to (maximum 24 hours)." + schemaNote,
|
|
105990
106005
|
annotations: read3,
|
|
105991
|
-
inputSchema: external_exports.strictObject({ query:
|
|
106006
|
+
inputSchema: external_exports.strictObject({ query: text15.min(1), from: external_exports.number().int(), to: external_exports.number().int() })
|
|
105992
106007
|
}, (args, context3) => api3.result("GET", `/api/v1/query?${params2(args)}`, void 0, context3.mcpReq.signal, headers));
|
|
105993
106008
|
server.registerTool("search_datadog_events", {
|
|
105994
106009
|
description: "Read native events using start/end epoch seconds and optional comma-separated tags." + schemaNote,
|
|
@@ -105996,9 +106011,9 @@ function datadogMcpServer(info, request) {
|
|
|
105996
106011
|
inputSchema: external_exports.strictObject({
|
|
105997
106012
|
start: integer3,
|
|
105998
106013
|
end: integer3,
|
|
105999
|
-
tags:
|
|
106014
|
+
tags: text15.optional(),
|
|
106000
106015
|
priority: external_exports.enum(["normal", "low"]).optional(),
|
|
106001
|
-
sources:
|
|
106016
|
+
sources: text15.optional(),
|
|
106002
106017
|
unaggregated: external_exports.boolean().optional(),
|
|
106003
106018
|
exclude_aggregate: external_exports.boolean().optional(),
|
|
106004
106019
|
page: integer3.optional()
|
|
@@ -106008,11 +106023,11 @@ function datadogMcpServer(info, request) {
|
|
|
106008
106023
|
description: "Search logs with the native query grammar, world-relative or ISO from/to, and cursor pagination." + schemaNote,
|
|
106009
106024
|
annotations: read3,
|
|
106010
106025
|
inputSchema: external_exports.strictObject({
|
|
106011
|
-
query:
|
|
106012
|
-
from:
|
|
106013
|
-
to:
|
|
106026
|
+
query: text15.optional(),
|
|
106027
|
+
from: text15.optional(),
|
|
106028
|
+
to: text15.optional(),
|
|
106014
106029
|
limit: integer3.min(1).max(1e3).optional(),
|
|
106015
|
-
cursor:
|
|
106030
|
+
cursor: text15.optional(),
|
|
106016
106031
|
sort: external_exports.enum(["timestamp", "-timestamp"]).optional()
|
|
106017
106032
|
})
|
|
106018
106033
|
}, (args, context3) => api3.result("POST", "/api/v2/logs/events/search", {
|
|
@@ -106707,7 +106722,7 @@ var HonoRequest = class {
|
|
|
106707
106722
|
* ```
|
|
106708
106723
|
*/
|
|
106709
106724
|
json() {
|
|
106710
|
-
return this.#cachedBody("text").then((
|
|
106725
|
+
return this.#cachedBody("text").then((text25) => JSON.parse(text25));
|
|
106711
106726
|
}
|
|
106712
106727
|
/**
|
|
106713
106728
|
* `.text()` can parse Request body of type `text/plain`
|
|
@@ -107225,8 +107240,8 @@ var Context = class {
|
|
|
107225
107240
|
* })
|
|
107226
107241
|
* ```
|
|
107227
107242
|
*/
|
|
107228
|
-
text = (
|
|
107229
|
-
return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(
|
|
107243
|
+
text = (text25, arg, headers) => {
|
|
107244
|
+
return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text25) : this.#newResponse(text25, arg, setDefaultContentType(TEXT_PLAIN, headers));
|
|
107230
107245
|
};
|
|
107231
107246
|
/**
|
|
107232
107247
|
* `.json()` can render JSON as `Content-Type:application/json`.
|
|
@@ -108199,8 +108214,8 @@ var PeopleModelError = class extends Error {
|
|
|
108199
108214
|
function promptSha256(request) {
|
|
108200
108215
|
return createHash4("sha256").update(JSON.stringify([request.system, request.user, request.schema, request.model ?? null])).digest("hex");
|
|
108201
108216
|
}
|
|
108202
|
-
function parseModelJson(
|
|
108203
|
-
const trimmed2 =
|
|
108217
|
+
function parseModelJson(text25) {
|
|
108218
|
+
const trimmed2 = text25.trim().replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/, "");
|
|
108204
108219
|
try {
|
|
108205
108220
|
return JSON.parse(trimmed2);
|
|
108206
108221
|
} catch {
|
|
@@ -108228,7 +108243,7 @@ async function fetchPost(url4, body6, headers, signal) {
|
|
|
108228
108243
|
function socketPost(socketPath) {
|
|
108229
108244
|
return (url4, body6, headers, signal) => new Promise((resolve7, reject2) => {
|
|
108230
108245
|
const req = httpRequest({ socketPath, path: new URL(url4).pathname, method: "POST", headers: { ...headers, host: "relay", "content-length": Buffer.byteLength(body6) }, signal }, (res) => {
|
|
108231
|
-
let
|
|
108246
|
+
let text25 = "", bytes2 = 0;
|
|
108232
108247
|
res.setEncoding("utf8");
|
|
108233
108248
|
res.on("data", (chunk) => {
|
|
108234
108249
|
bytes2 += Buffer.byteLength(chunk);
|
|
@@ -108239,9 +108254,9 @@ function socketPost(socketPath) {
|
|
|
108239
108254
|
res.destroy();
|
|
108240
108255
|
return;
|
|
108241
108256
|
}
|
|
108242
|
-
|
|
108257
|
+
text25 += chunk;
|
|
108243
108258
|
});
|
|
108244
|
-
res.on("end", () => resolve7({ status: res.statusCode ?? 0, headers: Object.fromEntries(Object.entries(res.headers).map(([k, v]) => [k, String(v)])), text:
|
|
108259
|
+
res.on("end", () => resolve7({ status: res.statusCode ?? 0, headers: Object.fromEntries(Object.entries(res.headers).map(([k, v]) => [k, String(v)])), text: text25 }));
|
|
108245
108260
|
res.on("error", reject2);
|
|
108246
108261
|
});
|
|
108247
108262
|
req.on("error", reject2);
|
|
@@ -108409,7 +108424,7 @@ async function simulate(model, request, signal) {
|
|
|
108409
108424
|
const recorded2 = (request.tool?.recorded ?? []).map((o) => ({ args: o.args, at: o.at, ...o.error !== void 0 ? { error: o.error } : { result: o.result } }));
|
|
108410
108425
|
const results = recorded2.filter((o) => "result" in o).map((o) => o.result);
|
|
108411
108426
|
const known2 = results.length ? results : (request.tool?.examples ?? []).filter((o) => o.error === void 0 && o.result !== void 0).map((o) => o.result);
|
|
108412
|
-
const
|
|
108427
|
+
const text25 = known2.length > 0 && known2.every((r2) => typeof r2 === "string");
|
|
108413
108428
|
const aware = request.tool?.schema !== void 0;
|
|
108414
108429
|
const errors2 = [...recorded2, ...request.tool?.examples ?? []].flatMap((o) => "error" in o && o.error !== void 0 ? [o.error] : []).map((error64, i) => ({ ref: `error-${i}`, error: error64 }));
|
|
108415
108430
|
const outputSchema = aware ? { name: "tool_answer", schema: {
|
|
@@ -108460,13 +108475,13 @@ ${feedback}` : user8, schema: outputSchema, temperature: 0, maxTokens: 1200 }, s
|
|
|
108460
108475
|
try {
|
|
108461
108476
|
result = JSON.parse(String(out?.result_json));
|
|
108462
108477
|
} catch {
|
|
108463
|
-
if (!
|
|
108478
|
+
if (!text25 || typeof out?.result_json !== "string") {
|
|
108464
108479
|
feedback = "Your result_json was not valid JSON. Answer again.";
|
|
108465
108480
|
continue;
|
|
108466
108481
|
}
|
|
108467
108482
|
result = out.result_json;
|
|
108468
108483
|
}
|
|
108469
|
-
if (
|
|
108484
|
+
if (text25 && typeof result !== "string" && typeof out?.result_json === "string") result = out.result_json;
|
|
108470
108485
|
if (sameShape(result, known2)) return { result, inputTokens, outputTokens, costUsd, model: model_ };
|
|
108471
108486
|
feedback = `Your result has the shape ${shape(result)}, but production's results have the shape ${shape(known2[0])}. Answer again in that shape.`;
|
|
108472
108487
|
}
|
|
@@ -108675,8 +108690,8 @@ function recordsMentioning(ctx, name5, args) {
|
|
|
108675
108690
|
const records3 = [];
|
|
108676
108691
|
const add = (tool, o, here) => {
|
|
108677
108692
|
const answer = o.error !== void 0 ? { error: o.error } : { result: o.result };
|
|
108678
|
-
const
|
|
108679
|
-
if (ids2.some((id14) => id14.test(
|
|
108693
|
+
const text25 = JSON.stringify([o.args, answer]);
|
|
108694
|
+
if (ids2.some((id14) => id14.test(text25))) records3.push({ tool, args: o.args ?? {}, ...answer, conversation: here ? "this one" : o.trace ?? "another" });
|
|
108680
108695
|
};
|
|
108681
108696
|
const others = Object.entries(ctx.scene.tools ?? {}).filter(([tool]) => tool !== name5);
|
|
108682
108697
|
for (const [tool] of others) for (const o of recorded(ctx, tool)) add(tool, o, true);
|
|
@@ -109407,7 +109422,7 @@ function findIncident(ctx, id14) {
|
|
|
109407
109422
|
|
|
109408
109423
|
// packages/server/src/world/words.ts
|
|
109409
109424
|
var list2 = (items, word) => items.length <= 1 ? items.join("") : `${items.slice(0, -1).join(", ")} ${word} ${items.at(-1)}`;
|
|
109410
|
-
var quoted = (
|
|
109425
|
+
var quoted = (text25) => `"${text25.length > 60 ? `${text25.slice(0, 59)}\u2026` : text25}"`;
|
|
109411
109426
|
function incident3(selector2) {
|
|
109412
109427
|
if ("ref" in selector2) return `incident ${selector2.ref}`;
|
|
109413
109428
|
return `the first incident on ${selector2.service}${selector2.after_start ? " created after the world started" : ""}`;
|
|
@@ -109567,8 +109582,8 @@ function inspectPredicate(env, predicate, atMs) {
|
|
|
109567
109582
|
const files2 = filesAt(ctx, Number(id14), revision);
|
|
109568
109583
|
if (!Object.hasOwn(files2, path4)) return outcome3(false, `file ${path4} missing at ${revision}`);
|
|
109569
109584
|
const content2 = files2[path4];
|
|
109570
|
-
const
|
|
109571
|
-
return outcome3("contains" in predicate ?
|
|
109585
|
+
const text25 = content2.toString("utf8");
|
|
109586
|
+
return outcome3("contains" in predicate ? text25.includes(predicate.contains) : text25 === predicate.equals, text25, `file ${path4} at ${revision}: ${text25}`);
|
|
109572
109587
|
} catch (error64) {
|
|
109573
109588
|
if (!(error64 instanceof GitObjectError)) throw error64;
|
|
109574
109589
|
return outcome3(false, `revision or production content unavailable in ${tuple3[0]} at ${tuple3[1]}`);
|
|
@@ -110086,8 +110101,8 @@ function takeNewMessages(env) {
|
|
|
110086
110101
|
function skipSeedHistory(env) {
|
|
110087
110102
|
takeNewMessages(env);
|
|
110088
110103
|
}
|
|
110089
|
-
var slackMentions = (
|
|
110090
|
-
var githubMentions = (
|
|
110104
|
+
var slackMentions = (text25) => new Set([...text25.matchAll(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g)].map((match3) => match3[1]));
|
|
110105
|
+
var githubMentions = (text25) => new Set([...text25.matchAll(/(?:^|[^\w`])@([A-Za-z0-9](?:[A-Za-z0-9-]{0,38}))/g)].map((match3) => match3[1].toLowerCase()));
|
|
110091
110106
|
function slackThreadParticipants(env, channel3, root3, beforeTs) {
|
|
110092
110107
|
return new Set(env.store.db.prepare("SELECT user_id FROM slack_messages WHERE channel_id = ? AND (ts = ? OR thread_ts = ?) AND ts < ?").all(channel3, root3, root3, beforeTs).map((row2) => row2.user_id));
|
|
110093
110108
|
}
|
|
@@ -110140,8 +110155,8 @@ function authorOf(message7, people3, bot) {
|
|
|
110140
110155
|
var FIELDS = ["to", "in", "in_thread_of", "from", "text_contains", "fact", "top_level", "dm"];
|
|
110141
110156
|
var hasTable4 = (env, name5) => env.store.db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(name5) !== void 0;
|
|
110142
110157
|
var startMs2 = (env) => env.clock.startTime.getTime();
|
|
110143
|
-
var excerpt = (
|
|
110144
|
-
const flat2 =
|
|
110158
|
+
var excerpt = (text25) => {
|
|
110159
|
+
const flat2 = text25.replace(/\s+/g, " ").trim();
|
|
110145
110160
|
return flat2.length > 80 ? `${flat2.slice(0, 77)}\u2026` : flat2;
|
|
110146
110161
|
};
|
|
110147
110162
|
var plural2 = (n2, word) => `${n2} ${word}${n2 === 1 ? "" : "s"}`;
|
|
@@ -110212,8 +110227,8 @@ function fieldTest(env, match3, field5) {
|
|
|
110212
110227
|
return (message7) => message7.tool === "slack" ? accounts2.slack !== void 0 && message7.authorId === accounts2.slack : accounts2.github !== void 0 && message7.authorId === accounts2.github.id;
|
|
110213
110228
|
}
|
|
110214
110229
|
case "text_contains": {
|
|
110215
|
-
const wanted = (Array.isArray(match3.text_contains) ? match3.text_contains : [match3.text_contains]).map((
|
|
110216
|
-
return (message7) => wanted.every((
|
|
110230
|
+
const wanted = (Array.isArray(match3.text_contains) ? match3.text_contains : [match3.text_contains]).map((text25) => text25.toLowerCase());
|
|
110231
|
+
return (message7) => wanted.every((text25) => message7.text.toLowerCase().includes(text25));
|
|
110217
110232
|
}
|
|
110218
110233
|
case "top_level":
|
|
110219
110234
|
return (message7) => message7.slack !== void 0 && message7.slack.topLevel;
|
|
@@ -110238,7 +110253,7 @@ function describeMatch(match3) {
|
|
|
110238
110253
|
...match3.in !== void 0 ? [`in ${match3.in}`] : [],
|
|
110239
110254
|
...match3.in_thread_of !== void 0 ? [`in the thread of ${match3.in_thread_of}`] : [],
|
|
110240
110255
|
...match3.from !== void 0 ? [`from ${match3.from}`] : [],
|
|
110241
|
-
...texts4.length ? [`containing ${texts4.map((
|
|
110256
|
+
...texts4.length ? [`containing ${texts4.map((text25) => `"${text25}"`).join(" and ")}`] : [],
|
|
110242
110257
|
...match3.fact !== void 0 ? [`telling ${match3.fact}`] : [],
|
|
110243
110258
|
...match3.top_level ? ["at the top level"] : [],
|
|
110244
110259
|
...match3.dm ? ["in a direct message"] : []
|
|
@@ -110446,17 +110461,17 @@ function graphqlMutation(entry2, field5, requireSuccess = false) {
|
|
|
110446
110461
|
function glob(pattern, caseInsensitive) {
|
|
110447
110462
|
const fold2 = (s2) => caseInsensitive ? s2.toLowerCase() : s2;
|
|
110448
110463
|
const pieces = fold2(pattern).split("*");
|
|
110449
|
-
if (pieces.length === 1) return (
|
|
110464
|
+
if (pieces.length === 1) return (text25) => fold2(text25) === pieces[0];
|
|
110450
110465
|
const first = pieces[0];
|
|
110451
110466
|
const last = pieces.at(-1);
|
|
110452
110467
|
const middle = pieces.slice(1, -1).filter((p2) => p2 !== "");
|
|
110453
110468
|
return (raw3) => {
|
|
110454
|
-
const
|
|
110455
|
-
if (
|
|
110456
|
-
const end =
|
|
110469
|
+
const text25 = fold2(raw3);
|
|
110470
|
+
if (text25.length < first.length + last.length || !text25.startsWith(first) || !text25.endsWith(last)) return false;
|
|
110471
|
+
const end = text25.length - last.length;
|
|
110457
110472
|
let pos = first.length;
|
|
110458
110473
|
for (const piece2 of middle) {
|
|
110459
|
-
const at3 =
|
|
110474
|
+
const at3 = text25.indexOf(piece2, pos);
|
|
110460
110475
|
if (at3 === -1 || at3 + piece2.length > end) return false;
|
|
110461
110476
|
pos = at3 + piece2.length;
|
|
110462
110477
|
}
|
|
@@ -110745,11 +110760,11 @@ function evaluateAnswer(check3, trace) {
|
|
|
110745
110760
|
explanation: `The agent gave ${answer ? "an empty" : "no"} final answer. An agent answers with a POST to ANCHA_DONE_URL, body {"output": <its answer>}, or by printing it on stdout.`
|
|
110746
110761
|
};
|
|
110747
110762
|
}
|
|
110748
|
-
const
|
|
110763
|
+
const text25 = comparableText(answer.text, sensitive);
|
|
110749
110764
|
const stated = readNumbers(answer.text);
|
|
110750
|
-
const missing7 = contains3.filter((piece2) => !
|
|
110765
|
+
const missing7 = contains3.filter((piece2) => !text25.includes(comparableText(piece2, sensitive)));
|
|
110751
110766
|
const unstated = numbers2.filter((n2) => !stated.some((number7) => numberMatches(number7, n2.value, n2.tolerance)));
|
|
110752
|
-
const present2 = absent.filter((piece2) =>
|
|
110767
|
+
const present2 = absent.filter((piece2) => text25.includes(comparableText(piece2, sensitive)));
|
|
110753
110768
|
const line2 = answer.text.replace(/\s+/g, " ").trim();
|
|
110754
110769
|
const actual = `"${line2.length > ANSWER_QUOTE ? `${line2.slice(0, ANSWER_QUOTE - 1)}\u2026` : line2}"`;
|
|
110755
110770
|
if (!missing7.length && !unstated.length && !present2.length) {
|
|
@@ -111357,9 +111372,9 @@ function formatPatch(patch, headerOptions) {
|
|
|
111357
111372
|
}
|
|
111358
111373
|
return ret.join("\n") + "\n";
|
|
111359
111374
|
}
|
|
111360
|
-
function splitLines(
|
|
111361
|
-
const hasTrailingNl =
|
|
111362
|
-
const result =
|
|
111375
|
+
function splitLines(text25) {
|
|
111376
|
+
const hasTrailingNl = text25.endsWith("\n");
|
|
111377
|
+
const result = text25.split("\n").map((line2) => line2 + "\n");
|
|
111363
111378
|
if (hasTrailingNl) {
|
|
111364
111379
|
result.pop();
|
|
111365
111380
|
} else {
|
|
@@ -111478,11 +111493,11 @@ function resolveRef2(ctx, repoId, ref22) {
|
|
|
111478
111493
|
return resolveCommit(ctx, repoId, /^[a-f0-9]{40}$/.test(ref22) || ref22.startsWith("refs/") ? ref22 : `refs/heads/${ref22}`);
|
|
111479
111494
|
}
|
|
111480
111495
|
function jsonBody(c, parsing = {}) {
|
|
111481
|
-
const
|
|
111482
|
-
if (
|
|
111496
|
+
const text25 = requestBodies.get(c.req.raw);
|
|
111497
|
+
if (text25 === void 0) throw new Error("GitHub body must be read before the synchronous route boundary");
|
|
111483
111498
|
c.env.ctx.signal?.throwIfAborted();
|
|
111484
111499
|
try {
|
|
111485
|
-
return parsing.allowEmpty &&
|
|
111500
|
+
return parsing.allowEmpty && text25.length === 0 ? {} : JSON.parse(text25);
|
|
111486
111501
|
} catch (error64) {
|
|
111487
111502
|
if (error64 instanceof SyntaxError) throw new GitHubError(400, "Problems parsing JSON");
|
|
111488
111503
|
throw error64;
|
|
@@ -111761,7 +111776,7 @@ function files(ctx, repoId, commit) {
|
|
|
111761
111776
|
visit4(getCommit(ctx, repoId, commit).tree, "");
|
|
111762
111777
|
return out;
|
|
111763
111778
|
}
|
|
111764
|
-
function
|
|
111779
|
+
function text16(bytes2) {
|
|
111765
111780
|
if (bytes2.includes(0)) return void 0;
|
|
111766
111781
|
try {
|
|
111767
111782
|
return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes2);
|
|
@@ -111774,7 +111789,7 @@ function diffFiles(ctx, repoId, base4, head) {
|
|
|
111774
111789
|
return [.../* @__PURE__ */ new Set([...before.keys(), ...after.keys()])].sort((a, b) => Buffer.compare(Buffer.from(a), Buffer.from(b))).flatMap((filename) => {
|
|
111775
111790
|
const old = before.get(filename), next2 = after.get(filename);
|
|
111776
111791
|
if (old && next2 && old.sha === next2.sha && old.mode === next2.mode) return [];
|
|
111777
|
-
const from =
|
|
111792
|
+
const from = text16(old?.bytes ?? Buffer.alloc(0)), to = text16(next2?.bytes ?? Buffer.alloc(0));
|
|
111778
111793
|
let additions = 0, deletions = 0, patch;
|
|
111779
111794
|
if (from !== void 0 && to !== void 0) {
|
|
111780
111795
|
for (const change3 of diffLines(from, to)) {
|
|
@@ -113619,16 +113634,16 @@ async function readArgs(req) {
|
|
|
113619
113634
|
for (const [key4, value4] of form2) entries3.set(key4, value4);
|
|
113620
113635
|
return Object.fromEntries(entries3);
|
|
113621
113636
|
}
|
|
113622
|
-
const
|
|
113623
|
-
if (
|
|
113637
|
+
const text25 = await req.text();
|
|
113638
|
+
if (text25 === "") return Object.fromEntries(entries3);
|
|
113624
113639
|
switch (type) {
|
|
113625
113640
|
case "application/x-www-form-urlencoded":
|
|
113626
|
-
for (const [key4, value4] of new URLSearchParams(
|
|
113641
|
+
for (const [key4, value4] of new URLSearchParams(text25)) entries3.set(key4, value4);
|
|
113627
113642
|
break;
|
|
113628
113643
|
case "application/json": {
|
|
113629
113644
|
let parsed3;
|
|
113630
113645
|
try {
|
|
113631
|
-
parsed3 = JSON.parse(
|
|
113646
|
+
parsed3 = JSON.parse(text25);
|
|
113632
113647
|
} catch {
|
|
113633
113648
|
throw new SlackError("invalid_json");
|
|
113634
113649
|
}
|
|
@@ -113749,16 +113764,16 @@ function limitArg(v) {
|
|
|
113749
113764
|
}
|
|
113750
113765
|
var MICROS_PER_SECOND2 = 1000000n;
|
|
113751
113766
|
function parseTs(v) {
|
|
113752
|
-
const
|
|
113753
|
-
if (typeof
|
|
113754
|
-
const m = /^(\d+)(?:\.(\d*))?$/.exec(
|
|
113767
|
+
const text25 = typeof v === "number" ? String(v) : v;
|
|
113768
|
+
if (typeof text25 !== "string") return void 0;
|
|
113769
|
+
const m = /^(\d+)(?:\.(\d*))?$/.exec(text25.trim());
|
|
113755
113770
|
if (!m) return void 0;
|
|
113756
113771
|
return BigInt(m[1]) * MICROS_PER_SECOND2 + BigInt((m[2] ?? "").padEnd(6, "0").slice(0, 6));
|
|
113757
113772
|
}
|
|
113758
113773
|
function tsBoundArg(v, errorCode) {
|
|
113759
|
-
const
|
|
113760
|
-
if (
|
|
113761
|
-
const micros2 = parseTs(
|
|
113774
|
+
const text25 = stringArg(v);
|
|
113775
|
+
if (text25 === void 0) return void 0;
|
|
113776
|
+
const micros2 = parseTs(text25);
|
|
113762
113777
|
if (micros2 === void 0) throw new SlackError(errorCode);
|
|
113763
113778
|
return micros2;
|
|
113764
113779
|
}
|
|
@@ -114075,8 +114090,8 @@ function emit(ctx, event3, id14, apiLinks) {
|
|
|
114075
114090
|
is_ext_shared_channel: false
|
|
114076
114091
|
} });
|
|
114077
114092
|
}
|
|
114078
|
-
function interpolateMentions(ctx,
|
|
114079
|
-
return
|
|
114093
|
+
function interpolateMentions(ctx, text25) {
|
|
114094
|
+
return text25.replace(/<\$user\.([A-Za-z0-9_]+)>/g, (_token, ref22) => `<@${ctx.refs.resolve(`$${ref22}`, "user")}>`);
|
|
114080
114095
|
}
|
|
114081
114096
|
function emitMessage(ctx, message7, apiLinks) {
|
|
114082
114097
|
const id14 = identity2(ctx);
|
|
@@ -114144,12 +114159,12 @@ function seedApp(ctx, service) {
|
|
|
114144
114159
|
ctx.store.db.prepare("INSERT INTO slack_apps VALUES (?, ?, ?, ?, ?)").run(service, app2, user8, bot, name5);
|
|
114145
114160
|
return { service, app_id: app2, user_id: user8, bot_id: bot, name: name5 };
|
|
114146
114161
|
}
|
|
114147
|
-
function appMessage(ctx, service, channel3,
|
|
114162
|
+
function appMessage(ctx, service, channel3, text25, blocks3, ts2, apiLinks) {
|
|
114148
114163
|
const app2 = ctx.store.db.prepare("SELECT * FROM slack_apps WHERE service = ?").get(service);
|
|
114149
114164
|
const target5 = ctx.store.db.prepare("SELECT is_archived FROM slack_channels WHERE id = ?").get(channel3);
|
|
114150
114165
|
if (!app2 || !target5 || target5.is_archived) throw new Error("Integration Slack app/channel unavailable");
|
|
114151
114166
|
if (ts2 === void 0) {
|
|
114152
|
-
const message8 = insertMessage(ctx, { channelId: channel3, userId: app2.user_id, botId: app2.bot_id, text:
|
|
114167
|
+
const message8 = insertMessage(ctx, { channelId: channel3, userId: app2.user_id, botId: app2.bot_id, text: text25, blocks: blocks3, threadTs: null });
|
|
114153
114168
|
persistMessageLinks(ctx, message8, apiLinks);
|
|
114154
114169
|
emitMessage(ctx, message8, apiLinks?.map((link6) => ({ ...link6, pointer: `/event${link6.pointer}` })));
|
|
114155
114170
|
return message8;
|
|
@@ -114157,7 +114172,7 @@ function appMessage(ctx, service, channel3, text24, blocks3, ts2, apiLinks) {
|
|
|
114157
114172
|
const previous = getMessage(ctx, channel3, ts2);
|
|
114158
114173
|
if (!previous || previous.user_id !== app2.user_id) throw new Error("Integration Slack message unavailable");
|
|
114159
114174
|
const previousLinks = messageLinks(ctx, previous);
|
|
114160
|
-
ctx.store.db.prepare("UPDATE slack_messages SET text = ?, blocks = ?, edited_ts = ? WHERE channel_id = ? AND ts = ?").run(
|
|
114175
|
+
ctx.store.db.prepare("UPDATE slack_messages SET text = ?, blocks = ?, edited_ts = ? WHERE channel_id = ? AND ts = ?").run(text25, JSON.stringify(blocks3), (ctx.clock.nowMs() / 1e3).toFixed(6), channel3, ts2);
|
|
114161
114176
|
const message7 = getMessage(ctx, channel3, ts2);
|
|
114162
114177
|
persistMessageLinks(ctx, message7, apiLinks);
|
|
114163
114178
|
emitMessageChanged(ctx, message7, previous, [
|
|
@@ -114197,8 +114212,8 @@ function notificationHandles(message7, declared) {
|
|
|
114197
114212
|
}
|
|
114198
114213
|
return matches9;
|
|
114199
114214
|
}
|
|
114200
|
-
function blocks(
|
|
114201
|
-
return [{ type: "section", text: { type: "plain_text", text:
|
|
114215
|
+
function blocks(text25, path4) {
|
|
114216
|
+
return [{ type: "section", text: { type: "plain_text", text: text25 } }, { type: "actions", elements: [{ type: "button", text: { type: "plain_text", text: "View details" }, url: path4, action_id: "view_details" }] }];
|
|
114202
114217
|
}
|
|
114203
114218
|
var pointer = "/blocks/1/elements/0/url";
|
|
114204
114219
|
function initializeIntegrations(env) {
|
|
@@ -114232,9 +114247,9 @@ function initializeIntegrations(env) {
|
|
|
114232
114247
|
if (bindings2.length) reconcileMilestones(env);
|
|
114233
114248
|
for (const binding2 of bindings2) {
|
|
114234
114249
|
const mapped = ctx.store.db.prepare("SELECT ts FROM world_incident_messages WHERE binding = ? AND incident_id = ?").get(binding2.ordinal, row2.id);
|
|
114235
|
-
const
|
|
114250
|
+
const text25 = `PagerDuty #${row2.incident_number}: ${row2.title} \u2014 ${row2.status}`;
|
|
114236
114251
|
const path4 = `/incidents/${row2.id}`;
|
|
114237
|
-
const message7 = appMessage(env.ctxFor("slack"), "pagerduty", binding2.channel_id,
|
|
114252
|
+
const message7 = appMessage(env.ctxFor("slack"), "pagerduty", binding2.channel_id, text25, blocks(text25, path4), mapped?.ts, [{ pointer, path: path4, service: "pagerduty" }]);
|
|
114238
114253
|
if (!mapped) ctx.store.db.prepare("INSERT INTO world_incident_messages VALUES (?, ?, ?, ?)").run(binding2.ordinal, row2.id, binding2.channel_id, message7.ts);
|
|
114239
114254
|
ctx.trace.record({
|
|
114240
114255
|
source: "world",
|
|
@@ -114242,7 +114257,7 @@ function initializeIntegrations(env) {
|
|
|
114242
114257
|
method: "ACTION",
|
|
114243
114258
|
path: mapped ? "slack.chat.update" : "slack.chat.postMessage",
|
|
114244
114259
|
request: { source: { service: "pagerduty", incident_id: row2.id, event_id: JSON.parse(event3.body).event.id }, target: { channel: binding2.channel_id, ts: message7.ts } },
|
|
114245
|
-
response: { text:
|
|
114260
|
+
response: { text: text25, blocks: JSON.parse(message7.blocks) }
|
|
114246
114261
|
});
|
|
114247
114262
|
}
|
|
114248
114263
|
});
|
|
@@ -114290,16 +114305,16 @@ function initializeIntegrations(env) {
|
|
|
114290
114305
|
response: { ...response5, source: { monitor_id: monitor3.id, event_id: native2.id, cycle_key: notification.cycleKey }, target: target5 }
|
|
114291
114306
|
});
|
|
114292
114307
|
} else {
|
|
114293
|
-
const
|
|
114308
|
+
const text25 = `${native2.title}
|
|
114294
114309
|
${native2.text}`, path4 = `/api/v1/monitor/${monitor3.id}`;
|
|
114295
|
-
const message7 = appMessage(env.ctxFor("slack"), "datadog", binding2.channel_id,
|
|
114310
|
+
const message7 = appMessage(env.ctxFor("slack"), "datadog", binding2.channel_id, text25, blocks(text25, path4), void 0, [{ pointer, path: path4, service: "datadog" }]);
|
|
114296
114311
|
ctx.trace.record({
|
|
114297
114312
|
source: "world",
|
|
114298
114313
|
service: "slack",
|
|
114299
114314
|
method: "ACTION",
|
|
114300
114315
|
path: "slack.chat.postMessage",
|
|
114301
114316
|
request: { source: { service: "datadog", monitor_id: monitor3.id, event_id: native2.id, cycle_key: notification.cycleKey }, target: { channel: binding2.channel_id, ts: message7.ts } },
|
|
114302
|
-
response: { text:
|
|
114317
|
+
response: { text: text25, blocks: JSON.parse(message7.blocks) }
|
|
114303
114318
|
});
|
|
114304
114319
|
}
|
|
114305
114320
|
}
|
|
@@ -114380,11 +114395,11 @@ function requireComment(ctx, repoId, id14) {
|
|
|
114380
114395
|
if (!row2) throw new GitHubError(404, "Not Found");
|
|
114381
114396
|
return row2;
|
|
114382
114397
|
}
|
|
114383
|
-
function insertComment(ctx, issue8, userId2,
|
|
114398
|
+
function insertComment(ctx, issue8, userId2, text25) {
|
|
114384
114399
|
ctx.signal?.throwIfAborted();
|
|
114385
114400
|
return withMutation(ctx, () => {
|
|
114386
114401
|
const id14 = resourceId(ctx), at3 = ctx.clock.now().toISOString();
|
|
114387
|
-
ctx.store.db.prepare("INSERT INTO github_comments (id,repo_id,issue_number,user_id,body,created_at,updated_at) VALUES (?,?,?,?,?,?,?)").run(id14, issue8.repo_id, issue8.number, userId2,
|
|
114402
|
+
ctx.store.db.prepare("INSERT INTO github_comments (id,repo_id,issue_number,user_id,body,created_at,updated_at) VALUES (?,?,?,?,?,?,?)").run(id14, issue8.repo_id, issue8.number, userId2, text25, at3, at3);
|
|
114388
114403
|
ctx.store.db.prepare("UPDATE github_issues SET updated_at = ? WHERE id = ?").run(at3, issue8.id);
|
|
114389
114404
|
const row2 = requireComment(ctx, issue8.repo_id, id14);
|
|
114390
114405
|
commentEvent(ctx, getRepo(ctx, issue8.repo_id), row2, "created", userId2);
|
|
@@ -114430,9 +114445,9 @@ var issueRoutes = [
|
|
|
114430
114445
|
} },
|
|
114431
114446
|
{ method: "POST", path: "/repos/:owner/:repo/issues", coverage, handler: (c) => {
|
|
114432
114447
|
query2(c, []);
|
|
114433
|
-
const ctx = c.env.ctx, repo4 = repository(c), input5 = body3(c, ["title", "body", "labels"]), title2 = string4(input5.title, "title"),
|
|
114448
|
+
const ctx = c.env.ctx, repo4 = repository(c), input5 = body3(c, ["title", "body", "labels"]), title2 = string4(input5.title, "title"), text25 = input5.body === void 0 ? "" : string4(input5.body, "body", true);
|
|
114434
114449
|
const labels2 = input5.labels === void 0 ? [] : labelNames(ctx, repo4, input5.labels, ["id", "name", "description", "color"]);
|
|
114435
|
-
return json2(issueShape(ctx, repo4, createIssue(ctx, repo4, { title: title2, body:
|
|
114450
|
+
return json2(issueShape(ctx, repo4, createIssue(ctx, repo4, { title: title2, body: text25, labels: labels2 })), 201);
|
|
114436
114451
|
} },
|
|
114437
114452
|
{ method: "GET", path: "/repos/:owner/:repo/issues/comments", coverage, handler: (c) => {
|
|
114438
114453
|
query2(c, ["sort", "direction", "since", "page", "per_page"]);
|
|
@@ -114443,15 +114458,15 @@ var issueRoutes = [
|
|
|
114443
114458
|
query2(c, []);
|
|
114444
114459
|
const ctx = c.env.ctx, repo4 = repository(c), id14 = resourceNumber(c, "id");
|
|
114445
114460
|
const input5 = method2 === "PATCH" ? body3(c, ["body"]) : void 0;
|
|
114446
|
-
const
|
|
114461
|
+
const text25 = input5 ? string4(input5.body, "body") : void 0;
|
|
114447
114462
|
ctx.signal?.throwIfAborted();
|
|
114448
114463
|
return withMutation(ctx, () => {
|
|
114449
114464
|
const row2 = requireComment(ctx, repo4.id, id14);
|
|
114450
|
-
if (method2 === "GET" || method2 === "PATCH" &&
|
|
114465
|
+
if (method2 === "GET" || method2 === "PATCH" && text25 === row2.body) return commentShape(ctx, repo4, row2);
|
|
114451
114466
|
if (method2 === "DELETE") ctx.store.db.prepare("DELETE FROM github_comments WHERE repo_id = ? AND id = ?").run(repo4.id, id14);
|
|
114452
|
-
else ctx.store.db.prepare("UPDATE github_comments SET body = ?, updated_at = ? WHERE repo_id = ? AND id = ?").run(
|
|
114467
|
+
else ctx.store.db.prepare("UPDATE github_comments SET body = ?, updated_at = ? WHERE repo_id = ? AND id = ?").run(text25, ctx.clock.now().toISOString(), repo4.id, id14);
|
|
114453
114468
|
ctx.store.db.prepare("UPDATE github_issues SET updated_at = ? WHERE repo_id = ? AND number = ?").run(ctx.clock.now().toISOString(), repo4.id, row2.issue_number);
|
|
114454
|
-
if (method2 === "DELETE" ||
|
|
114469
|
+
if (method2 === "DELETE" || text25 !== row2.body) commentEvent(ctx, repo4, method2 === "DELETE" ? row2 : requireComment(ctx, repo4.id, id14), method2 === "DELETE" ? "deleted" : "edited", void 0, method2 === "PATCH" ? row2.body : void 0);
|
|
114455
114470
|
return method2 === "DELETE" ? new Response(null, { status: 204 }) : commentShape(ctx, repo4, requireComment(ctx, repo4.id, id14));
|
|
114456
114471
|
});
|
|
114457
114472
|
} })),
|
|
@@ -114498,9 +114513,9 @@ var issueRoutes = [
|
|
|
114498
114513
|
} },
|
|
114499
114514
|
{ method: "POST", path: "/repos/:owner/:repo/issues/:number/comments", coverage, handler: (c) => {
|
|
114500
114515
|
query2(c, []);
|
|
114501
|
-
const ctx = c.env.ctx, repo4 = repository(c), number7 = resourceNumber(c), input5 = body3(c, ["body"]),
|
|
114516
|
+
const ctx = c.env.ctx, repo4 = repository(c), number7 = resourceNumber(c), input5 = body3(c, ["body"]), text25 = string4(input5.body, "body");
|
|
114502
114517
|
ctx.signal?.throwIfAborted();
|
|
114503
|
-
return withMutation(ctx, () => json2(commentShape(ctx, repo4, insertComment(ctx, requireIssue(ctx, repo4.id, number7), botUser(ctx).id,
|
|
114518
|
+
return withMutation(ctx, () => json2(commentShape(ctx, repo4, insertComment(ctx, requireIssue(ctx, repo4.id, number7), botUser(ctx).id, text25)), 201));
|
|
114504
114519
|
} }
|
|
114505
114520
|
];
|
|
114506
114521
|
|
|
@@ -115187,11 +115202,11 @@ function hubspotTwin() {
|
|
|
115187
115202
|
try {
|
|
115188
115203
|
let body6;
|
|
115189
115204
|
if (!["GET", "HEAD"].includes(c.req.method)) {
|
|
115190
|
-
const
|
|
115191
|
-
if (
|
|
115192
|
-
if (
|
|
115205
|
+
const text25 = await c.req.text();
|
|
115206
|
+
if (text25.length > 1e6) throw new HubError(413, "VALIDATION_ERROR", "Body exceeds 1 MB.");
|
|
115207
|
+
if (text25) {
|
|
115193
115208
|
try {
|
|
115194
|
-
body6 = JSON.parse(
|
|
115209
|
+
body6 = JSON.parse(text25);
|
|
115195
115210
|
} catch {
|
|
115196
115211
|
throw new HubError(400, "VALIDATION_ERROR", "Malformed JSON.");
|
|
115197
115212
|
}
|
|
@@ -115234,11 +115249,11 @@ var renderGitHubDeployDatadog = (config11, event3, ctx) => {
|
|
|
115234
115249
|
};
|
|
115235
115250
|
|
|
115236
115251
|
// packages/server/src/world/catalog/github-slack.ts
|
|
115237
|
-
var link2 = (url4,
|
|
115252
|
+
var link2 = (url4, text25) => url4 ? `<${url4}|${text25}>` : text25;
|
|
115238
115253
|
var who = (user8) => link2(user8?.html_url, user8?.login ?? "someone");
|
|
115239
|
-
var escape2 = (
|
|
115240
|
-
var excerpt2 = (
|
|
115241
|
-
const flat2 = (
|
|
115254
|
+
var escape2 = (text25) => text25.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
115255
|
+
var excerpt2 = (text25) => {
|
|
115256
|
+
const flat2 = (text25 ?? "").replace(/\s+/g, " ").trim();
|
|
115242
115257
|
return flat2 ? `
|
|
115243
115258
|
${escape2(flat2.length > 160 ? `${flat2.slice(0, 157)}...` : flat2)}` : "";
|
|
115244
115259
|
};
|
|
@@ -115268,20 +115283,20 @@ var renderGitHubSlack = (config11, event3, ctx) => {
|
|
|
115268
115283
|
} else return [];
|
|
115269
115284
|
if (!config11.events.includes(key4)) return [];
|
|
115270
115285
|
const title2 = link2(item2.html_url, `#${item2.number} ${escape2(item2.title ?? "")}`);
|
|
115271
|
-
const
|
|
115286
|
+
const text25 = `${heading}
|
|
115272
115287
|
${title2}${excerpt2(body6)}`;
|
|
115273
115288
|
const footer = link2(repository3?.html_url, repository3?.full_name ?? "");
|
|
115274
115289
|
return [{
|
|
115275
115290
|
action: "slack.post",
|
|
115276
115291
|
as: config11.app,
|
|
115277
115292
|
channel: config11.channel,
|
|
115278
|
-
text:
|
|
115279
|
-
blocks: [{ type: "section", text: { type: "mrkdwn", text:
|
|
115293
|
+
text: text25,
|
|
115294
|
+
blocks: [{ type: "section", text: { type: "mrkdwn", text: text25 } }, { type: "context", elements: [{ type: "mrkdwn", text: footer }] }]
|
|
115280
115295
|
}];
|
|
115281
115296
|
};
|
|
115282
115297
|
|
|
115283
115298
|
// packages/server/src/world/catalog/hubspot-deal-slack.ts
|
|
115284
|
-
var escape3 = (
|
|
115299
|
+
var escape3 = (text25) => text25.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
115285
115300
|
var money8 = (amount3) => typeof amount3 === "string" && amount3 !== "" && Number.isFinite(Number(amount3)) ? `$${Number(amount3).toLocaleString("en-US")}` : void 0;
|
|
115286
115301
|
var renderHubSpotDealSlack = (config11, event3, ctx) => {
|
|
115287
115302
|
if (event3.type !== "deal.propertyChange") return [];
|
|
@@ -115292,9 +115307,9 @@ var renderHubSpotDealSlack = (config11, event3, ctx) => {
|
|
|
115292
115307
|
const deal = ctx.record?.("hubspot", "deal", String(item2.objectId));
|
|
115293
115308
|
const name5 = escape3(deal?.name ?? `Deal ${item2.objectId}`), stage = escape3(deal?.stageLabels?.[item2.propertyValue] ?? item2.propertyValue);
|
|
115294
115309
|
const details = [money8(deal?.amount), deal?.pipelineLabel ? `Pipeline: ${escape3(deal.pipelineLabel)}` : void 0].filter(Boolean).join(" \xB7 ");
|
|
115295
|
-
const
|
|
115310
|
+
const text25 = `*Deal stage changed:* ${deal?.url ? `<${deal.url}|${name5}>` : name5} moved to *${stage}*${details ? `
|
|
115296
115311
|
${details}` : ""}`;
|
|
115297
|
-
return [{ action: "slack.post", as: config11.app, channel: config11.channel, text:
|
|
115312
|
+
return [{ action: "slack.post", as: config11.app, channel: config11.channel, text: text25, blocks: [{ type: "section", text: { type: "mrkdwn", text: text25 } }] }];
|
|
115298
115313
|
});
|
|
115299
115314
|
};
|
|
115300
115315
|
|
|
@@ -115318,7 +115333,7 @@ var renderMonitorGitHubIssue = (config11, event3, ctx) => {
|
|
|
115318
115333
|
};
|
|
115319
115334
|
|
|
115320
115335
|
// packages/server/src/world/catalog/pagerduty-slack.ts
|
|
115321
|
-
var escape4 = (
|
|
115336
|
+
var escape4 = (text25) => text25.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
115322
115337
|
var names = (people3) => (people3 ?? []).map((person4) => escape4(person4.summary ?? "someone")).join(", ");
|
|
115323
115338
|
var renderPagerDutySlack = (config11, event3, ctx) => {
|
|
115324
115339
|
const envelope = event3.payload.event;
|
|
@@ -115329,13 +115344,13 @@ var renderPagerDutySlack = (config11, event3, ctx) => {
|
|
|
115329
115344
|
if (type === "incident.triggered") {
|
|
115330
115345
|
const title2 = `<${incident6.html_url}|#${incident6.number} ${escape4(incident6.title ?? "")}>`;
|
|
115331
115346
|
const assigned = names(incident6.assignees);
|
|
115332
|
-
const
|
|
115347
|
+
const text26 = `*Triggered:* ${title2}
|
|
115333
115348
|
Service: ${escape4(incident6.service?.summary ?? "")}${assigned ? ` \xB7 Assigned to ${assigned}` : ""}`;
|
|
115334
|
-
return [{ ...post4, key: key4, text:
|
|
115349
|
+
return [{ ...post4, key: key4, text: text26, blocks: [{ type: "section", text: { type: "mrkdwn", text: text26 } }] }];
|
|
115335
115350
|
}
|
|
115336
115351
|
const agent = envelope?.agent ? escape4(envelope.agent.summary ?? "someone") : void 0;
|
|
115337
|
-
const
|
|
115338
|
-
return
|
|
115352
|
+
const text25 = type === "incident.acknowledged" ? `Acknowledged by ${agent ?? "someone"}` : type === "incident.resolved" ? agent ? `Resolved by ${agent}` : "Resolved" : type === "incident.escalated" ? `Escalated to ${names(incident6.assignees) || "the next level"}` : void 0;
|
|
115353
|
+
return text25 === void 0 ? [] : [{ ...post4, thread_key: key4, text: text25 }];
|
|
115339
115354
|
};
|
|
115340
115355
|
|
|
115341
115356
|
// packages/server/src/world/catalog/index.ts
|
|
@@ -115577,9 +115592,9 @@ function aggregateValues(values2, aggregation) {
|
|
|
115577
115592
|
}
|
|
115578
115593
|
function resolveQueryRange(from, to, nowMs) {
|
|
115579
115594
|
if (!Number.isFinite(nowMs)) invalid3("invalid captured query time");
|
|
115580
|
-
const resolve7 = (
|
|
115581
|
-
if (
|
|
115582
|
-
const relative2 = /^now-(.+)$/.exec(
|
|
115595
|
+
const resolve7 = (text25) => {
|
|
115596
|
+
if (text25 === "now") return Math.floor(nowMs);
|
|
115597
|
+
const relative2 = /^now-(.+)$/.exec(text25);
|
|
115583
115598
|
if (relative2) {
|
|
115584
115599
|
let duration8;
|
|
115585
115600
|
try {
|
|
@@ -115590,8 +115605,8 @@ function resolveQueryRange(from, to, nowMs) {
|
|
|
115590
115605
|
if (!Number.isSafeInteger(duration8) || duration8 <= 0) return invalid3("relative query duration must be positive finite milliseconds");
|
|
115591
115606
|
return Math.floor(nowMs) - duration8;
|
|
115592
115607
|
}
|
|
115593
|
-
const absolute = /^(\d{4}-\d{2}-\d{2})T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})$/.exec(
|
|
115594
|
-
const value4 = absolute ? Date.parse(
|
|
115608
|
+
const absolute = /^(\d{4}-\d{2}-\d{2})T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?(?:Z|[+-]\d{2}:\d{2})$/.exec(text25);
|
|
115609
|
+
const value4 = absolute ? Date.parse(text25) : NaN;
|
|
115595
115610
|
if (!Number.isFinite(value4)) return invalid3("query time must be ISO or now[-<positive duration>]");
|
|
115596
115611
|
const date10 = /* @__PURE__ */ new Date(`${absolute[1]}T00:00:00Z`);
|
|
115597
115612
|
if (date10.toISOString().slice(0, 10) !== absolute[1]) return invalid3("invalid ISO calendar date");
|
|
@@ -115678,9 +115693,9 @@ function encodeCursor2(cursor4, seed43) {
|
|
|
115678
115693
|
const body6 = Buffer.from(JSON.stringify(cursor4)).toString("base64url");
|
|
115679
115694
|
return `${body6}.${createHmac("sha256", seed43).update(body6).digest("base64url")}`;
|
|
115680
115695
|
}
|
|
115681
|
-
function decodeCursor2(
|
|
115682
|
-
if (
|
|
115683
|
-
const [body6, signature2] =
|
|
115696
|
+
function decodeCursor2(text25, seed43) {
|
|
115697
|
+
if (text25.length > 4096 || !/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(text25)) return invalid3("invalid log cursor");
|
|
115698
|
+
const [body6, signature2] = text25.split(".");
|
|
115684
115699
|
if (createHmac("sha256", seed43).update(body6).digest("base64url") !== signature2) return invalid3("invalid log cursor signature");
|
|
115685
115700
|
let data5;
|
|
115686
115701
|
try {
|
|
@@ -116284,14 +116299,14 @@ var pullRoutes = [
|
|
|
116284
116299
|
{ method: "POST", path: "/repos/:owner/:repo/pulls", coverage: { status: "partial", notes: writeNotes }, handler: (c) => {
|
|
116285
116300
|
query2(c, []);
|
|
116286
116301
|
const ctx = c.env.ctx, repo4 = repository(c), input5 = body3(c, ["title", "body", "head", "base", "draft"]);
|
|
116287
|
-
const title2 = string4(input5.title, "title"),
|
|
116302
|
+
const title2 = string4(input5.title, "title"), text25 = input5.body === void 0 ? "" : string4(input5.body, "body", true), draft2 = boolean6(input5.draft, "draft", false);
|
|
116288
116303
|
ctx.signal?.throwIfAborted();
|
|
116289
116304
|
return withMutation(ctx, () => {
|
|
116290
116305
|
const head = branch2(ctx, repo4, input5.head, "head", true), base4 = branch2(ctx, repo4, input5.base, "base");
|
|
116291
116306
|
if (head.ref === base4.ref || isAncestor(ctx, repo4.id, head.sha, base4.sha) || getCommit(ctx, repo4.id, head.sha).tree === getCommit(ctx, repo4.id, base4.sha).tree) throw new GitHubError(422, "No commits or changes between base and head");
|
|
116292
116307
|
duplicate(ctx, repo4.id, head.ref, base4.ref);
|
|
116293
116308
|
const number7 = nextIssueNumber(ctx, repo4.id), at3 = ctx.clock.now().toISOString(), user8 = botUser(ctx), issueId = resourceId(ctx);
|
|
116294
|
-
ctx.store.db.prepare("INSERT INTO github_issues (id,repo_id,number,user_id,title,body,state,is_pull,created_at,updated_at) VALUES (?,?,?,?,?,?,'open',1,?,?)").run(issueId, repo4.id, number7, user8.id, title2,
|
|
116309
|
+
ctx.store.db.prepare("INSERT INTO github_issues (id,repo_id,number,user_id,title,body,state,is_pull,created_at,updated_at) VALUES (?,?,?,?,?,?,'open',1,?,?)").run(issueId, repo4.id, number7, user8.id, title2, text25, at3, at3);
|
|
116295
116310
|
const pullId = resourceId(ctx);
|
|
116296
116311
|
ctx.store.db.prepare("INSERT INTO github_pulls (id,repo_id,number,head_ref,head_sha,base_ref,draft) VALUES (?,?,?,?,?,?,?)").run(pullId, repo4.id, number7, head.ref, head.sha, base4.ref, draft2 ? 1 : 0);
|
|
116297
116312
|
pullEvent(ctx, repo4, requirePull(ctx, repo4.id, number7), "opened");
|
|
@@ -116415,8 +116430,8 @@ function decodeWords(value4) {
|
|
|
116415
116430
|
return decodeCharset(bytes2, label7);
|
|
116416
116431
|
});
|
|
116417
116432
|
}
|
|
116418
|
-
function decodeQuotedPrintable(
|
|
116419
|
-
const soft =
|
|
116433
|
+
function decodeQuotedPrintable(text25) {
|
|
116434
|
+
const soft = text25.replace(/=\r?\n/g, "");
|
|
116420
116435
|
const bytes2 = [];
|
|
116421
116436
|
for (let i = 0; i < soft.length; i++) {
|
|
116422
116437
|
const ch = soft[i];
|
|
@@ -116466,15 +116481,15 @@ function parseHeaderParams(value4) {
|
|
|
116466
116481
|
let charset = "utf-8";
|
|
116467
116482
|
const bytes2 = [];
|
|
116468
116483
|
pieces.forEach((piece2, i) => {
|
|
116469
|
-
let
|
|
116484
|
+
let text25 = piece2.text;
|
|
116470
116485
|
if (piece2.encoded && i === 0) {
|
|
116471
|
-
const m = /^([^']*)'[^']*'(.*)$/.exec(
|
|
116486
|
+
const m = /^([^']*)'[^']*'(.*)$/.exec(text25);
|
|
116472
116487
|
if (m) {
|
|
116473
116488
|
charset = m[1] || "utf-8";
|
|
116474
|
-
|
|
116489
|
+
text25 = m[2];
|
|
116475
116490
|
}
|
|
116476
116491
|
}
|
|
116477
|
-
bytes2.push(piece2.encoded ? Buffer.from(
|
|
116492
|
+
bytes2.push(piece2.encoded ? Buffer.from(text25.replace(/%([0-9A-Fa-f]{2})/g, (_, hex5) => String.fromCharCode(parseInt(hex5, 16))), "latin1") : Buffer.from(text25, "utf8"));
|
|
116478
116493
|
});
|
|
116479
116494
|
params10[name5] = decodeCharset(Buffer.concat(bytes2), charset);
|
|
116480
116495
|
}
|
|
@@ -116498,9 +116513,9 @@ function header2(headers, name5) {
|
|
|
116498
116513
|
return headers.find((h) => h.name.toLowerCase() === name5.toLowerCase())?.value;
|
|
116499
116514
|
}
|
|
116500
116515
|
function splitEntity(bytes2) {
|
|
116501
|
-
const
|
|
116502
|
-
const match3 = /\r?\n\r?\n/.exec(
|
|
116503
|
-
if (!match3) return { headerText: Buffer.from(
|
|
116516
|
+
const text25 = bytes2.toString("latin1");
|
|
116517
|
+
const match3 = /\r?\n\r?\n/.exec(text25);
|
|
116518
|
+
if (!match3) return { headerText: Buffer.from(text25, "latin1").toString("utf8"), body: Buffer.alloc(0) };
|
|
116504
116519
|
return { headerText: bytes2.subarray(0, match3.index).toString("utf8"), body: bytes2.subarray(match3.index + match3[0].length) };
|
|
116505
116520
|
}
|
|
116506
116521
|
function parseEntity(bytes2, partId, depth, count4, defaultType = "text/plain") {
|
|
@@ -116517,12 +116532,12 @@ function parseEntity(bytes2, partId, depth, count4, defaultType = "text/plain")
|
|
|
116517
116532
|
const boundary = type.params.boundary;
|
|
116518
116533
|
if (!boundary) throw new MimeError("Multipart entity without a boundary");
|
|
116519
116534
|
const parts3 = [];
|
|
116520
|
-
const
|
|
116535
|
+
const text25 = body6.toString("latin1");
|
|
116521
116536
|
const delimiter = new RegExp(`(?:^|\\r?\\n)--${boundary.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(--)?[ \\t]*(?=\\r?\\n|$)`, "g");
|
|
116522
116537
|
let previous, match3;
|
|
116523
|
-
while ((match3 = delimiter.exec(
|
|
116538
|
+
while ((match3 = delimiter.exec(text25)) !== null) {
|
|
116524
116539
|
if (previous !== void 0) {
|
|
116525
|
-
const chunk =
|
|
116540
|
+
const chunk = text25.slice(previous, match3.index).replace(/^\r?\n/, "");
|
|
116526
116541
|
parts3.push(parseEntity(Buffer.from(chunk, "latin1"), partId === "" ? String(parts3.length) : `${partId}.${parts3.length}`, depth + 1, count4, mimeType === "multipart/digest" ? "message/rfc822" : "text/plain"));
|
|
116527
116542
|
}
|
|
116528
116543
|
if (match3[1] === "--") {
|
|
@@ -116562,11 +116577,11 @@ function parseAddressList(value4) {
|
|
|
116562
116577
|
const out = [];
|
|
116563
116578
|
let current = "", quoted3 = false, angle = false;
|
|
116564
116579
|
const flush = () => {
|
|
116565
|
-
const
|
|
116580
|
+
const text25 = current.trim().replace(/^[^:<"@]*:\s*/, "").replace(/;$/, "").trim();
|
|
116566
116581
|
current = "";
|
|
116567
|
-
if (!
|
|
116568
|
-
const parsed3 = parseGmailAddress(
|
|
116569
|
-
if (!parsed3) throw new MimeError(`Invalid address: ${
|
|
116582
|
+
if (!text25) return;
|
|
116583
|
+
const parsed3 = parseGmailAddress(text25);
|
|
116584
|
+
if (!parsed3) throw new MimeError(`Invalid address: ${text25}`);
|
|
116570
116585
|
out.push(parsed3);
|
|
116571
116586
|
};
|
|
116572
116587
|
for (let i = 0; i < value4.length; i++) {
|
|
@@ -116607,8 +116622,8 @@ function formatAddress(a) {
|
|
|
116607
116622
|
const name5 = !ASCII.test(a.name) ? encodeWords(a.name) : /[()<>[\]:;@\\,."]/.test(a.name) ? `"${a.name.replace(/(["\\])/g, "\\$1")}"` : a.name;
|
|
116608
116623
|
return `${name5} <${a.email}>`;
|
|
116609
116624
|
}
|
|
116610
|
-
function quotedPrintable(
|
|
116611
|
-
const lines =
|
|
116625
|
+
function quotedPrintable(text25) {
|
|
116626
|
+
const lines = text25.replace(/\r?\n/g, "\n").split("\n").map((line2) => {
|
|
116612
116627
|
let encoded = "";
|
|
116613
116628
|
for (const byte of Buffer.from(line2, "utf8")) {
|
|
116614
116629
|
encoded += byte >= 33 && byte <= 126 && byte !== 61 || byte === 32 ? String.fromCharCode(byte) : `=${byte.toString(16).toUpperCase().padStart(2, "0")}`;
|
|
@@ -116680,10 +116695,10 @@ ${content2}\r
|
|
|
116680
116695
|
`, "utf8");
|
|
116681
116696
|
}
|
|
116682
116697
|
function rewriteHeaders(raw3, changes) {
|
|
116683
|
-
const
|
|
116684
|
-
const match3 = /\r?\n\r?\n/.exec(
|
|
116685
|
-
const headerText = match3 ?
|
|
116686
|
-
const rest2 = match3 ? raw3.subarray(Buffer.byteLength(
|
|
116698
|
+
const text25 = raw3.toString("latin1");
|
|
116699
|
+
const match3 = /\r?\n\r?\n/.exec(text25);
|
|
116700
|
+
const headerText = match3 ? text25.slice(0, match3.index) : text25;
|
|
116701
|
+
const rest2 = match3 ? raw3.subarray(Buffer.byteLength(text25.slice(0, match3.index + match3[0].length), "latin1")) : Buffer.alloc(0);
|
|
116687
116702
|
const kept = [];
|
|
116688
116703
|
const lower4 = new Map(Object.keys(changes).map((k) => [k.toLowerCase(), k]));
|
|
116689
116704
|
let skipping = false;
|
|
@@ -116854,11 +116869,11 @@ function handle(route12) {
|
|
|
116854
116869
|
const ctx = c.env.ctx;
|
|
116855
116870
|
let body6, bodyError;
|
|
116856
116871
|
if (route12.method !== "GET" && route12.method !== "DELETE") {
|
|
116857
|
-
const
|
|
116858
|
-
if (Buffer.byteLength(
|
|
116859
|
-
else if (
|
|
116872
|
+
const text25 = await c.req.text();
|
|
116873
|
+
if (Buffer.byteLength(text25) > MAX_BODY_BYTES) bodyError = new GmailError(501, "UNIMPLEMENTED", "notImplemented", "ancha: not implemented: request bodies over 10 MB");
|
|
116874
|
+
else if (text25.trim() === "") body6 = {};
|
|
116860
116875
|
else try {
|
|
116861
|
-
body6 = JSON.parse(
|
|
116876
|
+
body6 = JSON.parse(text25);
|
|
116862
116877
|
} catch {
|
|
116863
116878
|
bodyError = new GmailError(400, "INVALID_ARGUMENT", "parseError", "Invalid JSON payload received. Unexpected token.");
|
|
116864
116879
|
}
|
|
@@ -116953,7 +116968,7 @@ var escapeHtml = (s2) => s2.replace(/&/g, "&").replace(/</g, "<").replace
|
|
|
116953
116968
|
function describe4(raw3) {
|
|
116954
116969
|
const root3 = parseMessage(raw3);
|
|
116955
116970
|
const h = (name5) => header2(root3.headers, name5);
|
|
116956
|
-
const
|
|
116971
|
+
const text25 = bodyText(root3);
|
|
116957
116972
|
const html2 = leaves(root3).find((p2) => p2.mimeType === "text/html" && !isAttachment(p2));
|
|
116958
116973
|
const meta3 = {
|
|
116959
116974
|
from: parseAddressList(h("from")),
|
|
@@ -116961,9 +116976,9 @@ function describe4(raw3) {
|
|
|
116961
116976
|
cc: parseAddressList(h("cc")),
|
|
116962
116977
|
bcc: parseAddressList(h("bcc")),
|
|
116963
116978
|
subject: h("subject") ?? "",
|
|
116964
|
-
text:
|
|
116979
|
+
text: text25,
|
|
116965
116980
|
...html2 && { html: partText(html2) },
|
|
116966
|
-
snippet: escapeHtml((
|
|
116981
|
+
snippet: escapeHtml((text25 || (html2 ? htmlToText(partText(html2)) : "")).replace(/\s+/g, " ").trim().slice(0, 200)),
|
|
116967
116982
|
...h("message-id") && { messageId: h("message-id").trim() },
|
|
116968
116983
|
...h("in-reply-to") && { inReplyTo: h("in-reply-to").trim() },
|
|
116969
116984
|
references: (h("references") ?? "").match(/<[^<>\s]+>/g) ?? [],
|
|
@@ -117189,18 +117204,18 @@ function decidePrompt(person4, open2, messages2) {
|
|
|
117189
117204
|
temperature: 0
|
|
117190
117205
|
};
|
|
117191
117206
|
}
|
|
117192
|
-
function matchPrompt(fact2,
|
|
117207
|
+
function matchPrompt(fact2, text25) {
|
|
117193
117208
|
return {
|
|
117194
117209
|
system: `You decide whether a message tells its reader this fact: ${JSON.stringify(fact2.value)}. Answer {"told": true} only if the message states that information, directly or by clear paraphrase, even among other things; a question about it, or a mention of something else, does not count. Otherwise {"told": false}.`,
|
|
117195
|
-
user:
|
|
117210
|
+
user: text25,
|
|
117196
117211
|
schema: { name: "match", schema: { type: "object", additionalProperties: false, required: ["told"], properties: { told: { type: "boolean" } } } },
|
|
117197
117212
|
temperature: 0
|
|
117198
117213
|
};
|
|
117199
117214
|
}
|
|
117200
|
-
function matchManyPrompt(candidates,
|
|
117215
|
+
function matchManyPrompt(candidates, text25) {
|
|
117201
117216
|
return {
|
|
117202
117217
|
system: `You decide which of these facts a message tells its reader: ${JSON.stringify(candidates.map((fact2) => ({ id: fact2.ref, fact: fact2.value })))}. Include every fact the message states, directly or by clear paraphrase; a message can state several. A question about a fact does not count. Return {"told": []} if it tells none.`,
|
|
117203
|
-
user:
|
|
117218
|
+
user: text25,
|
|
117204
117219
|
schema: { name: "match", schema: { type: "object", additionalProperties: false, required: ["told"], properties: { told: { type: "array", items: { type: "string", enum: candidates.map((fact2) => fact2.ref) } } } } },
|
|
117205
117220
|
temperature: 0
|
|
117206
117221
|
};
|
|
@@ -117256,8 +117271,8 @@ var MAX_SINGLE_MATCHES = 8;
|
|
|
117256
117271
|
function peopleEngine(env) {
|
|
117257
117272
|
return engines.get(env);
|
|
117258
117273
|
}
|
|
117259
|
-
function normalize(
|
|
117260
|
-
return ` ${
|
|
117274
|
+
function normalize(text25) {
|
|
117275
|
+
return ` ${text25.toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ").trim()} `;
|
|
117261
117276
|
}
|
|
117262
117277
|
var PeopleEngine = class {
|
|
117263
117278
|
#env;
|
|
@@ -117590,10 +117605,10 @@ var PeopleEngine = class {
|
|
|
117590
117605
|
return [...this.#people.values()].filter((other) => other.ref !== person4.ref).flatMap((other) => (other.knows ?? []).filter((fact2) => fact2.match === "semantic" && !known2.has(`${other.ref}.${fact2.id}`)).map((fact2) => ({ ref: `${other.ref}.${fact2.id}`, value: fact2.value })));
|
|
117591
117606
|
}
|
|
117592
117607
|
#exactKnowledge(person4, message7, author) {
|
|
117593
|
-
const known2 = knownFacts(this.#env, person4.ref),
|
|
117608
|
+
const known2 = knownFacts(this.#env, person4.ref), text25 = normalize(message7.text);
|
|
117594
117609
|
for (const other of this.#people.values()) for (const fact2 of other.knows ?? []) {
|
|
117595
117610
|
const ref22 = `${other.ref}.${fact2.id}`;
|
|
117596
|
-
if (other.ref === person4.ref || fact2.match !== "exact" || known2.has(ref22) || !
|
|
117611
|
+
if (other.ref === person4.ref || fact2.match !== "exact" || known2.has(ref22) || !text25.includes(normalize(fact2.value))) continue;
|
|
117597
117612
|
recordKnowledge(this.#env, {
|
|
117598
117613
|
person: person4.ref,
|
|
117599
117614
|
fact: ref22,
|
|
@@ -117614,7 +117629,7 @@ var PeopleEngine = class {
|
|
|
117614
117629
|
for (const row2 of rows7) {
|
|
117615
117630
|
const candidates = env.world.read(() => this.#semanticCandidates(person4));
|
|
117616
117631
|
if (!candidates.length) return;
|
|
117617
|
-
const
|
|
117632
|
+
const text25 = env.world.read(() => this.#messageText(row2));
|
|
117618
117633
|
const learn = (ref22) => env.world.mutate(() => {
|
|
117619
117634
|
recordKnowledge(env, {
|
|
117620
117635
|
person: person4.ref,
|
|
@@ -117626,14 +117641,14 @@ var PeopleEngine = class {
|
|
|
117626
117641
|
});
|
|
117627
117642
|
});
|
|
117628
117643
|
if (candidates.length > MAX_SINGLE_MATCHES) {
|
|
117629
|
-
const told = (await this.#call(person4, "match", "message", matchManyPrompt(candidates,
|
|
117644
|
+
const told = (await this.#call(person4, "match", "message", matchManyPrompt(candidates, text25)))?.told;
|
|
117630
117645
|
if (Array.isArray(told)) {
|
|
117631
117646
|
for (const ref22 of told) if (typeof ref22 === "string" && candidates.some((fact2) => fact2.ref === ref22)) learn(ref22);
|
|
117632
117647
|
}
|
|
117633
117648
|
continue;
|
|
117634
117649
|
}
|
|
117635
117650
|
for (const fact2 of candidates) {
|
|
117636
|
-
const output2 = await this.#call(person4, "match", "message", matchPrompt(fact2,
|
|
117651
|
+
const output2 = await this.#call(person4, "match", "message", matchPrompt(fact2, text25));
|
|
117637
117652
|
if (output2 === void 0) return;
|
|
117638
117653
|
if (output2.told === true) learn(fact2.ref);
|
|
117639
117654
|
}
|
|
@@ -117935,13 +117950,13 @@ ${issue8.body}`, isNew: fresh.has(`github.issue:${issue8.id}`) }] : [],
|
|
|
117935
117950
|
#execute(person4, place2, step2) {
|
|
117936
117951
|
const env = this.#env, key4 = place2.key;
|
|
117937
117952
|
const accounts2 = this.#everyone().find((entry2) => entry2.person.ref === person4.ref).accounts;
|
|
117938
|
-
const
|
|
117953
|
+
const text25 = this.#withMentions(step2.text ?? "");
|
|
117939
117954
|
if (key4.startsWith("slack:") && accounts2.slack !== void 0) {
|
|
117940
117955
|
const [, channel3, root3] = key4.split(":");
|
|
117941
117956
|
const ctx = env.ctxFor("slack");
|
|
117942
|
-
const row2 = insertMessage(ctx, { channelId: channel3, userId: accounts2.slack, botId: null, text:
|
|
117957
|
+
const row2 = insertMessage(ctx, { channelId: channel3, userId: accounts2.slack, botId: null, text: text25, blocks: null, threadTs: root3 === "0" ? null : root3 });
|
|
117943
117958
|
emitMessage(ctx, row2);
|
|
117944
|
-
env.trace.record({ source: "world", service: "slack", method: "ACTION", path: "people.post", request: { person: person4.ref, channel: channel3, thread_ts: root3 === "0" ? null : root3, text:
|
|
117959
|
+
env.trace.record({ source: "world", service: "slack", method: "ACTION", path: "people.post", request: { person: person4.ref, channel: channel3, thread_ts: root3 === "0" ? null : root3, text: text25 } });
|
|
117945
117960
|
return;
|
|
117946
117961
|
}
|
|
117947
117962
|
if (key4.startsWith("gmail:") && accounts2.gmail !== void 0) {
|
|
@@ -117953,12 +117968,12 @@ ${issue8.body}`, isNew: fresh.has(`github.issue:${issue8.id}`) }] : [],
|
|
|
117953
117968
|
if (key4.startsWith("github:") && accounts2.github !== void 0) {
|
|
117954
117969
|
const [repoId, number7] = key4.slice("github:".length).split("#").map(Number);
|
|
117955
117970
|
const ctx = env.ctxFor("github");
|
|
117956
|
-
insertComment(ctx, requireIssue(ctx, repoId, number7), Number(accounts2.github.id),
|
|
117957
|
-
env.trace.record({ source: "world", service: "github", method: "ACTION", path: "people.comment", request: { person: person4.ref, repo: repoId, number: number7, body:
|
|
117971
|
+
insertComment(ctx, requireIssue(ctx, repoId, number7), Number(accounts2.github.id), text25);
|
|
117972
|
+
env.trace.record({ source: "world", service: "github", method: "ACTION", path: "people.comment", request: { person: person4.ref, repo: repoId, number: number7, body: text25 } });
|
|
117958
117973
|
}
|
|
117959
117974
|
}
|
|
117960
117975
|
/** `@Name` for a person or a Slack user in this world becomes a real mention. */
|
|
117961
|
-
#withMentions(
|
|
117976
|
+
#withMentions(text25) {
|
|
117962
117977
|
const names5 = /* @__PURE__ */ new Map();
|
|
117963
117978
|
for (const entry2 of this.#everyone()) if (entry2.accounts.slack) names5.set(entry2.person.name.toLowerCase(), entry2.accounts.slack);
|
|
117964
117979
|
const bot = this.#botAccounts().slack;
|
|
@@ -117966,7 +117981,7 @@ ${issue8.body}`, isNew: fresh.has(`github.issue:${issue8.id}`) }] : [],
|
|
|
117966
117981
|
const row2 = this.#env.store.db.prepare("SELECT name FROM slack_users WHERE id = ?").get(bot);
|
|
117967
117982
|
if (row2) names5.set(row2.name.toLowerCase(), bot);
|
|
117968
117983
|
}
|
|
117969
|
-
return
|
|
117984
|
+
return text25.replace(/@([A-Za-z][\w.-]*)/g, (match3, name5) => {
|
|
117970
117985
|
const id14 = names5.get(name5.toLowerCase());
|
|
117971
117986
|
return id14 ? `<@${id14}>` : match3;
|
|
117972
117987
|
});
|
|
@@ -118000,7 +118015,7 @@ function messageIn(ctx, channelId, ts2) {
|
|
|
118000
118015
|
if (!row2) throw new SlackError("message_not_found");
|
|
118001
118016
|
return row2;
|
|
118002
118017
|
}
|
|
118003
|
-
var hasText = (
|
|
118018
|
+
var hasText = (text25) => text25 !== void 0 && text25.trim() !== "";
|
|
118004
118019
|
function messageText(args) {
|
|
118005
118020
|
if (args.markdown_text === void 0) return stringArg(args.text);
|
|
118006
118021
|
if (args.text !== void 0 || args.blocks !== void 0) throw new SlackError("markdown_text_conflict");
|
|
@@ -118038,14 +118053,14 @@ function supported(ctx, args, fields11) {
|
|
|
118038
118053
|
registerMethods({
|
|
118039
118054
|
"chat.postMessage": (ctx, args, caller2) => {
|
|
118040
118055
|
supported(ctx, args, ["channel", "text", "blocks", "markdown_text", "thread_ts"]);
|
|
118041
|
-
const
|
|
118056
|
+
const text25 = messageText(args);
|
|
118042
118057
|
const target5 = stringArg(args.channel);
|
|
118043
118058
|
const user8 = target5 !== void 0 && /^[UW][A-Z0-9]+$/.test(target5) ? ctx.store.db.prepare("SELECT id FROM slack_users WHERE id = ? AND deleted = 0").get(target5) : void 0;
|
|
118044
118059
|
const channel3 = user8 ? directMessage(ctx, caller2.userId, user8.id, true) : channelByIdOrName(ctx, caller2, args.channel);
|
|
118045
118060
|
if (channel3.is_archived === 1) throw new SlackError("is_archived");
|
|
118046
118061
|
if (!isMember(ctx, channel3.id, caller2.userId)) throw new SlackError("not_in_channel");
|
|
118047
118062
|
const blocks3 = blocksArg(args.blocks);
|
|
118048
|
-
if (!hasText(
|
|
118063
|
+
if (!hasText(text25) && (blocks3 === void 0 || blocks3.length === 0)) throw new SlackError("no_text");
|
|
118049
118064
|
let threadTs = null;
|
|
118050
118065
|
const parentTs = stringArg(args.thread_ts);
|
|
118051
118066
|
if (parentTs !== void 0) {
|
|
@@ -118057,7 +118072,7 @@ registerMethods({
|
|
|
118057
118072
|
channelId: channel3.id,
|
|
118058
118073
|
userId: caller2.userId,
|
|
118059
118074
|
botId: caller2.botId ?? null,
|
|
118060
|
-
text:
|
|
118075
|
+
text: text25 ?? "",
|
|
118061
118076
|
blocks: blocks3 === void 0 || blocks3.length === 0 ? null : blocks3,
|
|
118062
118077
|
threadTs
|
|
118063
118078
|
});
|
|
@@ -118067,7 +118082,7 @@ registerMethods({
|
|
|
118067
118082
|
"chat.postEphemeral": (ctx, args, caller2) => {
|
|
118068
118083
|
requireScope(caller2, "chat:write");
|
|
118069
118084
|
supported(ctx, args, ["channel", "user", "text", "blocks", "markdown_text", "thread_ts"]);
|
|
118070
|
-
const
|
|
118085
|
+
const text25 = messageText(args);
|
|
118071
118086
|
const channel3 = channelByIdOrName(ctx, caller2, args.channel);
|
|
118072
118087
|
if (channel3.is_archived) throw new SlackError("is_archived");
|
|
118073
118088
|
if (!isMember(ctx, channel3.id, caller2.userId)) throw new SlackError("not_in_channel");
|
|
@@ -118075,7 +118090,7 @@ registerMethods({
|
|
|
118075
118090
|
if (!user8 || user8.deleted) throw new SlackError("user_not_found");
|
|
118076
118091
|
if (!isMember(ctx, channel3.id, user8.id)) throw new SlackError("user_not_in_channel");
|
|
118077
118092
|
const blocks3 = blocksArg(args.blocks);
|
|
118078
|
-
if (!hasText(
|
|
118093
|
+
if (!hasText(text25) && !blocks3?.length) throw new SlackError("no_text");
|
|
118079
118094
|
let threadTs = null;
|
|
118080
118095
|
if (args.thread_ts !== void 0) {
|
|
118081
118096
|
const parent2 = getMessage(ctx, channel3.id, stringArg(args.thread_ts) ?? "");
|
|
@@ -118084,13 +118099,13 @@ registerMethods({
|
|
|
118084
118099
|
}
|
|
118085
118100
|
ensureAssistantTables(ctx);
|
|
118086
118101
|
const ts2 = nextTs(ctx, ctx.clock.nowMs());
|
|
118087
|
-
ctx.store.db.prepare("INSERT INTO slack_ephemeral_messages (channel_id, ts, user_id, recipient_user_id, text, blocks, thread_ts) VALUES (?, ?, ?, ?, ?, ?, ?)").run(channel3.id, ts2, caller2.userId, user8.id,
|
|
118102
|
+
ctx.store.db.prepare("INSERT INTO slack_ephemeral_messages (channel_id, ts, user_id, recipient_user_id, text, blocks, thread_ts) VALUES (?, ?, ?, ?, ?, ?, ?)").run(channel3.id, ts2, caller2.userId, user8.id, text25 ?? "", blocks3?.length ? JSON.stringify(blocks3) : null, threadTs);
|
|
118088
118103
|
return { message_ts: ts2 };
|
|
118089
118104
|
},
|
|
118090
118105
|
"chat.scheduleMessage": (ctx, args, caller2) => {
|
|
118091
118106
|
supported(ctx, args, ["channel", "post_at", "text", "blocks", "markdown_text", "thread_ts"]);
|
|
118092
|
-
const
|
|
118093
|
-
if (!hasText(
|
|
118107
|
+
const text25 = messageText(args), blocks3 = blocksArg(args.blocks);
|
|
118108
|
+
if (!hasText(text25) && !blocks3?.length) throw new SlackError("no_text");
|
|
118094
118109
|
const postAt = Number(args.post_at);
|
|
118095
118110
|
if (!Number.isSafeInteger(postAt) || postAt <= 0) throw new SlackError("invalid_time");
|
|
118096
118111
|
if (postAt * 1e3 <= ctx.clock.nowMs()) throw new SlackError("time_in_past");
|
|
@@ -118107,24 +118122,24 @@ registerMethods({
|
|
|
118107
118122
|
}
|
|
118108
118123
|
ensureAssistantTables(ctx);
|
|
118109
118124
|
const id14 = `Q${ctx.ids.alnumUpper(10)}`;
|
|
118110
|
-
ctx.store.db.prepare("INSERT INTO slack_scheduled_messages (id, channel_id, user_id, bot_id, text, blocks, thread_ts, post_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(id14, channel3.id, caller2.userId, caller2.botId ?? null,
|
|
118125
|
+
ctx.store.db.prepare("INSERT INTO slack_scheduled_messages (id, channel_id, user_id, bot_id, text, blocks, thread_ts, post_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(id14, channel3.id, caller2.userId, caller2.botId ?? null, text25 ?? "", blocks3?.length ? JSON.stringify(blocks3) : null, threadTs, postAt);
|
|
118111
118126
|
ctx.enqueueJob({ atMs: postAt * 1e3 - ctx.clock.startTime.getTime(), kind: "slack.scheduled_message", payload: { id: id14 } });
|
|
118112
|
-
return { channel: channel3.id, post_at: postAt, scheduled_message_id: id14, message: { text:
|
|
118127
|
+
return { channel: channel3.id, post_at: postAt, scheduled_message_id: id14, message: { text: text25 ?? "", ...blocks3?.length && { blocks: blocks3 } } };
|
|
118113
118128
|
},
|
|
118114
118129
|
"chat.update": (ctx, args, caller2) => {
|
|
118115
118130
|
supported(ctx, args, ["channel", "ts", "text", "blocks", "markdown_text"]);
|
|
118116
|
-
const
|
|
118131
|
+
const text25 = messageText(args);
|
|
118117
118132
|
const channel3 = channelToRead(ctx, caller2, args.channel);
|
|
118118
118133
|
const row2 = messageIn(ctx, channel3.id, args.ts);
|
|
118119
118134
|
if (row2.user_id !== caller2.userId) throw new SlackError("cant_update_message");
|
|
118120
118135
|
const blocks3 = blocksArg(args.blocks);
|
|
118121
|
-
if (
|
|
118122
|
-
const newText =
|
|
118123
|
-
const newBlocks = blocks3 === void 0 ?
|
|
118136
|
+
if (text25 === void 0 && blocks3 === void 0) throw new SlackError("no_text");
|
|
118137
|
+
const newText = text25 ?? row2.text;
|
|
118138
|
+
const newBlocks = blocks3 === void 0 ? text25 === void 0 ? row2.blocks : null : blocks3.length === 0 ? null : JSON.stringify(blocks3);
|
|
118124
118139
|
if (!hasText(newText) && newBlocks === null) throw new SlackError("no_text");
|
|
118125
118140
|
const editedTs = nextTs(ctx, ctx.clock.nowMs());
|
|
118126
118141
|
ctx.store.db.prepare("UPDATE slack_messages SET text = ?, blocks = ?, edited_ts = ? WHERE channel_id = ? AND ts = ?").run(newText, newBlocks, editedTs, channel3.id, row2.ts);
|
|
118127
|
-
if (blocks3 !== void 0 ||
|
|
118142
|
+
if (blocks3 !== void 0 || text25 !== void 0) ctx.store.db.prepare("DELETE FROM slack_message_links WHERE channel_id = ? AND ts = ?").run(channel3.id, row2.ts);
|
|
118128
118143
|
const updated = getMessage(ctx, channel3.id, row2.ts);
|
|
118129
118144
|
emitMessageChanged(ctx, updated, row2);
|
|
118130
118145
|
return { channel: channel3.id, ts: row2.ts, text: newText, message: messageShape(ctx, updated) };
|
|
@@ -118221,8 +118236,8 @@ var MAX_EVIDENCE = 20;
|
|
|
118221
118236
|
var CONVERSATION_LINES = 20;
|
|
118222
118237
|
var hasTable6 = (env, name5) => env.store.db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(name5) !== void 0;
|
|
118223
118238
|
var simAt = (env, ms) => new Date(env.clock.startTime.getTime() + ms).toISOString();
|
|
118224
|
-
var clip = (
|
|
118225
|
-
const flat2 =
|
|
118239
|
+
var clip = (text25, limit = 200) => {
|
|
118240
|
+
const flat2 = text25.replace(/\s+/g, " ").trim();
|
|
118226
118241
|
return flat2.length > limit ? `${flat2.slice(0, limit - 1)}\u2026` : flat2;
|
|
118227
118242
|
};
|
|
118228
118243
|
var nameOf = (env, ref22) => env.scene.people?.find((person4) => person4.ref === ref22)?.name ?? ref22;
|
|
@@ -120278,8 +120293,8 @@ function dayBounds(seconds3, zone5) {
|
|
|
120278
120293
|
const inZone = (wall) => {
|
|
120279
120294
|
let candidate = wall;
|
|
120280
120295
|
for (let i = 0; i < 3; i++) {
|
|
120281
|
-
const
|
|
120282
|
-
const m = /GMT([+-])(\d{2}):(\d{2})/.exec(
|
|
120296
|
+
const text25 = new Intl.DateTimeFormat("en", { timeZone: zone5, timeZoneName: "longOffset" }).formatToParts(new Date(candidate)).find((x) => x.type === "timeZoneName").value;
|
|
120297
|
+
const m = /GMT([+-])(\d{2}):(\d{2})/.exec(text25), offset17 = m ? (m[1] === "-" ? -1 : 1) * (Number(m[2]) * 60 + Number(m[3])) * 6e4 : 0;
|
|
120283
120298
|
candidate = wall - offset17;
|
|
120284
120299
|
}
|
|
120285
120300
|
return candidate / 1e3;
|
|
@@ -120365,7 +120380,7 @@ function parse5(schema, value4) {
|
|
|
120365
120380
|
if (!parsed3.success) invalid6(parsed3.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ").slice(0, 1e3));
|
|
120366
120381
|
return parsed3.data;
|
|
120367
120382
|
}
|
|
120368
|
-
function
|
|
120383
|
+
function text17(value4, field5, max = 1e3) {
|
|
120369
120384
|
if (typeof value4 !== "string" || value4.length > max) invalid6(`Invalid ${field5}`, field5);
|
|
120370
120385
|
return value4;
|
|
120371
120386
|
}
|
|
@@ -120450,7 +120465,7 @@ function pagination(rows7, query10, defaultLimit = 20, max = 500) {
|
|
|
120450
120465
|
if (after !== void 0 && before !== void 0) invalid6("Use only after or before");
|
|
120451
120466
|
let start2 = 0, end = rows7.length;
|
|
120452
120467
|
if (after !== void 0 || before !== void 0) {
|
|
120453
|
-
const cursor4 =
|
|
120468
|
+
const cursor4 = text17(after ?? before, "cursor", 4096), index = rows7.findIndex((row2) => row2.id === cursor4);
|
|
120454
120469
|
if (index < 0) invalid6("Cursor is not visible in this result");
|
|
120455
120470
|
if (after !== void 0) start2 = index + 1;
|
|
120456
120471
|
else {
|
|
@@ -120515,7 +120530,7 @@ function creative(value4, access3, creating) {
|
|
|
120515
120530
|
}
|
|
120516
120531
|
function parent(access3, kind, value4) {
|
|
120517
120532
|
if (kind === "campaigns") return void 0;
|
|
120518
|
-
const row2 = find(access3, kind === "adGroups" ? "campaigns" : "adGroups",
|
|
120533
|
+
const row2 = find(access3, kind === "adGroups" ? "campaigns" : "adGroups", text17(value4[kind === "adGroups" ? "campaign_id" : "ad_group_id"], "parent id", 200));
|
|
120519
120534
|
if (row2.status === "archived") invalid6("Cannot create a child of an archived resource");
|
|
120520
120535
|
if (kind === "ads" && find(access3, "campaigns", row2.campaign_id).status === "archived") invalid6("Cannot create an ad in an archived campaign");
|
|
120521
120536
|
return row2;
|
|
@@ -120572,10 +120587,10 @@ function list5(c, access3, kind) {
|
|
|
120572
120587
|
const query10 = params3(c, ["include", "name", "limit", "after", "before", "order", ...parentKey ? [parentKey] : []], ["include"]), issues = includes2(query10);
|
|
120573
120588
|
if (query10.order !== void 0 && !["asc", "desc"].includes(query10.order)) invalid6("order must be asc or desc");
|
|
120574
120589
|
if (query10.name !== void 0) {
|
|
120575
|
-
const name5 =
|
|
120590
|
+
const name5 = text17(query10.name, "name");
|
|
120576
120591
|
if (name5.length < 3 || !name5.trim()) invalid6("name must have at least three characters");
|
|
120577
120592
|
}
|
|
120578
|
-
if (parentKey && query10[parentKey] !== void 0) find(access3, kind === "adGroups" ? "campaigns" : "adGroups",
|
|
120593
|
+
if (parentKey && query10[parentKey] !== void 0) find(access3, kind === "adGroups" ? "campaigns" : "adGroups", text17(query10[parentKey], parentKey, 200));
|
|
120579
120594
|
const rows7 = access3.seed[kind].filter((row2) => row2.accountId === access3.account.id && (query10.name === void 0 || row2.name === query10.name) && (!parentKey || query10[parentKey] === void 0 || row2[parentKey] === query10[parentKey]));
|
|
120580
120595
|
rows7.sort((a, b) => (a.created_at - b.created_at || a.id.localeCompare(b.id)) * (query10.order === "asc" ? 1 : -1));
|
|
120581
120596
|
const page18 = pagination(rows7, query10);
|
|
@@ -120660,7 +120675,7 @@ function report(c, access3, scope2) {
|
|
|
120660
120675
|
if (start2 % 3600 || end % 3600) unsupported6("insights non-hour-aligned bound normalization");
|
|
120661
120676
|
}
|
|
120662
120677
|
const field5 = (value4) => {
|
|
120663
|
-
const name5 =
|
|
120678
|
+
const name5 = text17(value4, "field", 200);
|
|
120664
120679
|
if (name5 === "metadata.readable_time") return name5;
|
|
120665
120680
|
const [entity3, key4, ...rest2] = name5.split(".");
|
|
120666
120681
|
if (rest2.length || !levels.includes(entity3)) unsupported6(`insights field ${name5}`);
|
|
@@ -120803,7 +120818,7 @@ function object9(value4, field5) {
|
|
|
120803
120818
|
function keys3(value4, allowed2, field5) {
|
|
120804
120819
|
for (const key4 of Object.keys(value4)) if (!allowed2.includes(key4)) unsupported7(`${field5}.${key4}`);
|
|
120805
120820
|
}
|
|
120806
|
-
function
|
|
120821
|
+
function text18(value4, field5, max = 300) {
|
|
120807
120822
|
if (typeof value4 !== "string" || value4.length > max) invalid7(`Invalid ${field5}`);
|
|
120808
120823
|
return value4;
|
|
120809
120824
|
}
|
|
@@ -120905,13 +120920,13 @@ var metrics2 = {
|
|
|
120905
120920
|
totalRevenue: { uiName: "Total revenue", type: "TYPE_CURRENCY", description: "Seeded event revenue in the property currency." }
|
|
120906
120921
|
};
|
|
120907
120922
|
function dimensionName(value4) {
|
|
120908
|
-
const name5 =
|
|
120923
|
+
const name5 = text18(value4, "dimension name");
|
|
120909
120924
|
if (Object.hasOwn(metrics2, name5)) invalid7(`${name5} is a metric, not a dimension`);
|
|
120910
120925
|
if (!Object.hasOwn(dimensions, name5)) unsupported7(`dimension ${name5}`);
|
|
120911
120926
|
return name5;
|
|
120912
120927
|
}
|
|
120913
120928
|
function metricName(value4) {
|
|
120914
|
-
const name5 =
|
|
120929
|
+
const name5 = text18(value4, "metric name");
|
|
120915
120930
|
if (Object.hasOwn(dimensions, name5)) invalid7(`${name5} is a dimension, not a metric`);
|
|
120916
120931
|
if (!Object.hasOwn(metrics2, name5)) unsupported7(`metric ${name5}`);
|
|
120917
120932
|
return name5;
|
|
@@ -121026,7 +121041,7 @@ function compileFilter(raw3, kind) {
|
|
|
121026
121041
|
const match3 = value4.matchType === void 0 ? "EXACT" : value4.matchType, caseSensitive = bool2(value4.caseSensitive, "caseSensitive");
|
|
121027
121042
|
if (["FULL_REGEXP", "PARTIAL_REGEXP"].includes(match3)) unsupported7(`stringFilter ${match3}`);
|
|
121028
121043
|
if (!["EXACT", "BEGINS_WITH", "ENDS_WITH", "CONTAINS"].includes(match3)) invalid7("Invalid matchType");
|
|
121029
|
-
const pattern =
|
|
121044
|
+
const pattern = text18(value4.value, "stringFilter.value", 2e3), normalized = caseSensitive ? pattern : pattern.toLowerCase();
|
|
121030
121045
|
return (read6) => {
|
|
121031
121046
|
const raw5 = String(read6(field5)), actual = caseSensitive ? raw5 : raw5.toLowerCase();
|
|
121032
121047
|
return match3 === "EXACT" ? actual === normalized : match3 === "BEGINS_WITH" ? actual.startsWith(normalized) : match3 === "ENDS_WITH" ? actual.endsWith(normalized) : actual.includes(normalized);
|
|
@@ -121038,7 +121053,7 @@ function compileFilter(raw3, kind) {
|
|
|
121038
121053
|
const sensitive = bool2(value4.caseSensitive, "caseSensitive");
|
|
121039
121054
|
if (!Array.isArray(value4.values) || value4.values.length < 1 || value4.values.length > 100) invalid7("Invalid inListFilter.values");
|
|
121040
121055
|
const expected = value4.values.map((v) => {
|
|
121041
|
-
const s2 =
|
|
121056
|
+
const s2 = text18(v, "inListFilter.values", 2e3);
|
|
121042
121057
|
return sensitive ? s2 : s2.toLowerCase();
|
|
121043
121058
|
});
|
|
121044
121059
|
return (read6) => expected.includes(sensitive ? String(read6(field5)) : String(read6(field5)).toLowerCase());
|
|
@@ -121073,7 +121088,7 @@ function compileFilter(raw3, kind) {
|
|
|
121073
121088
|
|
|
121074
121089
|
// packages/server/src/twins/ga4/report.ts
|
|
121075
121090
|
function date9(value4, property4, ctx) {
|
|
121076
|
-
const input5 =
|
|
121091
|
+
const input5 = text18(value4, "date", 30);
|
|
121077
121092
|
if (external_exports.iso.date().safeParse(input5).success) return input5;
|
|
121078
121093
|
const match3 = /^(\d{1,6})daysAgo$/.exec(input5), ago = input5 === "today" ? 0 : input5 === "yesterday" ? 1 : match3 ? Number(match3[1]) : void 0;
|
|
121079
121094
|
if (ago === void 0) invalid7("Dates must use YYYY-MM-DD, today, yesterday or NdaysAgo");
|
|
@@ -121089,7 +121104,7 @@ function ranges(raw3, property4, ctx) {
|
|
|
121089
121104
|
keys3(value4, ["startDate", "endDate", "name"], "dateRanges");
|
|
121090
121105
|
const start2 = date9(value4.startDate, property4, ctx), end = date9(value4.endDate, property4, ctx);
|
|
121091
121106
|
if (end < start2) invalid7("startDate must not be after endDate");
|
|
121092
|
-
const name5 = value4.name === void 0 ? `date_range_${i}` :
|
|
121107
|
+
const name5 = value4.name === void 0 ? `date_range_${i}` : text18(value4.name, "date range name", 100);
|
|
121093
121108
|
if (value4.name !== void 0 && (!name5.length || /^(date_range_|RESERVED_)/.test(name5))) invalid7("Invalid date range name");
|
|
121094
121109
|
return { start: start2, end, name: name5 };
|
|
121095
121110
|
});
|
|
@@ -121310,12 +121325,12 @@ function pull(ctx, args) {
|
|
|
121310
121325
|
if (!row2) return outcome(false, expected, `Pull ${args.pull} not found`);
|
|
121311
121326
|
return outcome(Boolean(row2.merged) === args.merged, expected, `Pull #${row2.number} merged is ${Boolean(row2.merged)}`);
|
|
121312
121327
|
}
|
|
121313
|
-
var texts3 = (value4) => (value4 === void 0 ? [] : Array.isArray(value4) ? value4 : [value4]).map((
|
|
121328
|
+
var texts3 = (value4) => (value4 === void 0 ? [] : Array.isArray(value4) ? value4 : [value4]).map((text25) => text25.toLowerCase());
|
|
121314
121329
|
var counted = (args, n2) => args.count !== void 0 ? n2 === args.count : args.count_gte === void 0 && args.count_lte === void 0 ? n2 >= 1 : (args.count_gte === void 0 || n2 >= args.count_gte) && (args.count_lte === void 0 || n2 <= args.count_lte);
|
|
121315
121330
|
function issue3(ctx, args) {
|
|
121316
121331
|
const filters = [
|
|
121317
|
-
...texts3(args.title_contains).map((
|
|
121318
|
-
...texts3(args.body_contains).map((
|
|
121332
|
+
...texts3(args.title_contains).map((text25) => `title contains ${JSON.stringify(text25)}`),
|
|
121333
|
+
...texts3(args.body_contains).map((text25) => `body contains ${JSON.stringify(text25)}`),
|
|
121319
121334
|
...(args.labels ?? []).map((name5) => `label ${JSON.stringify(name5)}`),
|
|
121320
121335
|
...args.state ? [`state ${args.state}`] : [],
|
|
121321
121336
|
...args.state_reason !== void 0 ? [`state reason ${args.state_reason}`] : []
|
|
@@ -121328,7 +121343,7 @@ function issue3(ctx, args) {
|
|
|
121328
121343
|
const rows7 = ctx.store.db.prepare("SELECT * FROM github_issues WHERE repo_id = ? AND is_pull = 0 ORDER BY number").all(repo4.id);
|
|
121329
121344
|
const matches9 = rows7.filter((row2) => {
|
|
121330
121345
|
const names5 = new Set(issueLabels(ctx, repo4.id, row2.number).map((label7) => label7.name.toLowerCase()));
|
|
121331
|
-
return (args.state === void 0 || row2.state === args.state) && (args.state_reason === void 0 || issueStateReason(ctx, row2) === args.state_reason) && title2.every((
|
|
121346
|
+
return (args.state === void 0 || row2.state === args.state) && (args.state_reason === void 0 || issueStateReason(ctx, row2) === args.state_reason) && title2.every((text25) => row2.title.toLowerCase().includes(text25)) && body6.every((text25) => row2.body.toLowerCase().includes(text25)) && labels2.every((name5) => names5.has(name5));
|
|
121332
121347
|
});
|
|
121333
121348
|
const numbers2 = new Set(matches9.map((row2) => row2.number));
|
|
121334
121349
|
const prefix2 = `/repos/${repo4.owner}/${repo4.name}/issues`.toLowerCase();
|
|
@@ -121443,7 +121458,7 @@ var searchRoutes = [{
|
|
|
121443
121458
|
case "mentions": {
|
|
121444
121459
|
const escaped = lower4.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
121445
121460
|
const mention = new RegExp(`(^|[^a-z0-9_])@${escaped}(?![a-z0-9_-])`, "i");
|
|
121446
|
-
predicates.push((item2) => [item2.issue.body, ...item2.comments].some((
|
|
121461
|
+
predicates.push((item2) => [item2.issue.body, ...item2.comments].some((text25) => mention.test(text25)));
|
|
121447
121462
|
break;
|
|
121448
121463
|
}
|
|
121449
121464
|
case "no":
|
|
@@ -122198,10 +122213,10 @@ function reviewCommit(ctx, p2, value4) {
|
|
|
122198
122213
|
if (!isAncestor(ctx, p2.repo_id, sha2, head)) throw new GitHubError(422, "commit_id is not part of this pull request");
|
|
122199
122214
|
return sha2;
|
|
122200
122215
|
}
|
|
122201
|
-
function insertReview(ctx, p2, sha2, state2,
|
|
122216
|
+
function insertReview(ctx, p2, sha2, state2, text25) {
|
|
122202
122217
|
const id14 = resourceId(ctx), at3 = ctx.clock.now().toISOString();
|
|
122203
122218
|
const ordinal2 = ctx.store.db.prepare("SELECT COALESCE(MAX(ordinal),0) + 1 AS n FROM github_reviews").get().n;
|
|
122204
|
-
ctx.store.db.prepare("INSERT INTO github_reviews (id,repo_id,pull_number,user_id,commit_sha,state,body,submitted_at,ordinal) VALUES (?,?,?,?,?,?,?,?,?)").run(id14, p2.repo_id, p2.number, botUser(ctx).id, sha2, state2,
|
|
122219
|
+
ctx.store.db.prepare("INSERT INTO github_reviews (id,repo_id,pull_number,user_id,commit_sha,state,body,submitted_at,ordinal) VALUES (?,?,?,?,?,?,?,?,?)").run(id14, p2.repo_id, p2.number, botUser(ctx).id, sha2, state2, text25, at3, ordinal2);
|
|
122205
122220
|
ctx.store.db.prepare("UPDATE github_issues SET updated_at = ? WHERE repo_id = ? AND number = ?").run(at3, p2.repo_id, p2.number);
|
|
122206
122221
|
return requireReview(ctx, p2.repo_id, p2.number, id14);
|
|
122207
122222
|
}
|
|
@@ -122213,16 +122228,16 @@ function changedLine(ctx, p2, sha2, path4, line2, side) {
|
|
|
122213
122228
|
let old = 0, next2 = 0, hunk = "";
|
|
122214
122229
|
const lines = file3.patch.split("\n");
|
|
122215
122230
|
for (let i = 0; i < lines.length; i++) {
|
|
122216
|
-
const
|
|
122231
|
+
const text25 = lines[i], header3 = /^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(text25);
|
|
122217
122232
|
if (header3) {
|
|
122218
122233
|
old = Number(header3[1]);
|
|
122219
122234
|
next2 = Number(header3[2]);
|
|
122220
|
-
hunk =
|
|
122235
|
+
hunk = text25;
|
|
122221
122236
|
continue;
|
|
122222
122237
|
}
|
|
122223
122238
|
hunk += `
|
|
122224
|
-
${
|
|
122225
|
-
const target5 = side === "LEFT" ?
|
|
122239
|
+
${text25}`;
|
|
122240
|
+
const target5 = side === "LEFT" ? text25.startsWith("-") && old === line2 : text25.startsWith("+") && next2 === line2;
|
|
122226
122241
|
if (target5) {
|
|
122227
122242
|
let end = i + 1;
|
|
122228
122243
|
while (end < lines.length && !lines[end].startsWith("@@ ")) {
|
|
@@ -122232,9 +122247,9 @@ ${lines[end]}`;
|
|
|
122232
122247
|
}
|
|
122233
122248
|
return hunk.replace(/\n$/, "");
|
|
122234
122249
|
}
|
|
122235
|
-
if (
|
|
122236
|
-
else if (
|
|
122237
|
-
else if (
|
|
122250
|
+
if (text25.startsWith("-")) old++;
|
|
122251
|
+
else if (text25.startsWith("+")) next2++;
|
|
122252
|
+
else if (text25.startsWith(" ")) {
|
|
122238
122253
|
old++;
|
|
122239
122254
|
next2++;
|
|
122240
122255
|
}
|
|
@@ -122256,12 +122271,12 @@ var reviewRoutes = [
|
|
|
122256
122271
|
if (input5.event === void 0) unsupported("pending review workflows");
|
|
122257
122272
|
const event3 = string4(input5.event, "event");
|
|
122258
122273
|
if (!["APPROVE", "REQUEST_CHANGES", "COMMENT"].includes(event3)) unsupported(`review event ${event3}`);
|
|
122259
|
-
const
|
|
122260
|
-
if (event3 !== "APPROVE" && !
|
|
122274
|
+
const text25 = input5.body === void 0 ? "" : string4(input5.body, "body", true);
|
|
122275
|
+
if (event3 !== "APPROVE" && !text25.trim()) throw new GitHubError(422, "body is required for COMMENT or REQUEST_CHANGES");
|
|
122261
122276
|
ctx.signal?.throwIfAborted();
|
|
122262
122277
|
return withMutation(ctx, () => {
|
|
122263
122278
|
const p2 = requirePull2(ctx, repo4.id, number7), sha2 = reviewCommit(ctx, p2, input5.commit_id);
|
|
122264
|
-
return json2(reviewShape(ctx, repo4, insertReview(ctx, p2, sha2, { APPROVE: "APPROVED", REQUEST_CHANGES: "CHANGES_REQUESTED", COMMENT: "COMMENTED" }[event3],
|
|
122279
|
+
return json2(reviewShape(ctx, repo4, insertReview(ctx, p2, sha2, { APPROVE: "APPROVED", REQUEST_CHANGES: "CHANGES_REQUESTED", COMMENT: "COMMENTED" }[event3], text25)), 200);
|
|
122265
122280
|
});
|
|
122266
122281
|
} },
|
|
122267
122282
|
{ method: "GET", path: "/repos/:owner/:repo/pulls/:number/reviews/:id", coverage: coverage3, handler: (c) => {
|
|
@@ -122277,13 +122292,13 @@ var reviewRoutes = [
|
|
|
122277
122292
|
...["GET", "PATCH", "DELETE"].map((method2) => ({ method: method2, path: "/repos/:owner/:repo/pulls/comments/:id", coverage: coverage3, handler: (c) => {
|
|
122278
122293
|
query2(c, []);
|
|
122279
122294
|
const ctx = c.env.ctx, repo4 = repository(c), id14 = resourceNumber(c, "id");
|
|
122280
|
-
const input5 = method2 === "PATCH" ? body3(c, ["body"]) : void 0,
|
|
122295
|
+
const input5 = method2 === "PATCH" ? body3(c, ["body"]) : void 0, text25 = input5 ? string4(input5.body, "body") : void 0;
|
|
122281
122296
|
ctx.signal?.throwIfAborted();
|
|
122282
122297
|
return withMutation(ctx, () => {
|
|
122283
122298
|
const row2 = requireComment2(ctx, repo4.id, id14);
|
|
122284
122299
|
if (method2 === "GET") return reviewCommentShape(ctx, repo4, row2);
|
|
122285
122300
|
if (method2 === "DELETE") ctx.store.db.prepare("DELETE FROM github_review_comments WHERE repo_id = ? AND id = ?").run(repo4.id, id14);
|
|
122286
|
-
else ctx.store.db.prepare("UPDATE github_review_comments SET body = ?, updated_at = ? WHERE repo_id = ? AND id = ?").run(
|
|
122301
|
+
else ctx.store.db.prepare("UPDATE github_review_comments SET body = ?, updated_at = ? WHERE repo_id = ? AND id = ?").run(text25, ctx.clock.now().toISOString(), repo4.id, id14);
|
|
122287
122302
|
ctx.store.db.prepare("UPDATE github_issues SET updated_at = ? WHERE repo_id = ? AND number = ?").run(ctx.clock.now().toISOString(), repo4.id, row2.pull_number);
|
|
122288
122303
|
return method2 === "DELETE" ? new Response(null, { status: 204 }) : reviewCommentShape(ctx, repo4, requireComment2(ctx, repo4.id, id14));
|
|
122289
122304
|
});
|
|
@@ -122295,7 +122310,7 @@ var reviewRoutes = [
|
|
|
122295
122310
|
} },
|
|
122296
122311
|
{ method: "POST", path: "/repos/:owner/:repo/pulls/:number/comments", coverage: coverage3, handler: (c) => {
|
|
122297
122312
|
query2(c, []);
|
|
122298
|
-
const ctx = c.env.ctx, repo4 = repository(c), number7 = resourceNumber(c), input5 = body3(c, ["body", "commit_id", "path", "line", "side", "in_reply_to"]),
|
|
122313
|
+
const ctx = c.env.ctx, repo4 = repository(c), number7 = resourceNumber(c), input5 = body3(c, ["body", "commit_id", "path", "line", "side", "in_reply_to"]), text25 = string4(input5.body, "body");
|
|
122299
122314
|
ctx.signal?.throwIfAborted();
|
|
122300
122315
|
return withMutation(ctx, () => {
|
|
122301
122316
|
const p2 = requirePull2(ctx, repo4.id, number7);
|
|
@@ -122322,7 +122337,7 @@ var reviewRoutes = [
|
|
|
122322
122337
|
reviewId = insertReview(ctx, p2, sha2, "COMMENTED", "").id;
|
|
122323
122338
|
}
|
|
122324
122339
|
const id14 = resourceId(ctx), at3 = ctx.clock.now().toISOString();
|
|
122325
|
-
ctx.store.db.prepare("INSERT INTO github_review_comments (id,repo_id,pull_number,review_id,user_id,commit_sha,path,line,side,diff_hunk,in_reply_to_id,body,created_at,updated_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)").run(id14, repo4.id, number7, reviewId, botUser(ctx).id, sha2, path4, line2, side, diff2, parent2?.id ?? null,
|
|
122340
|
+
ctx.store.db.prepare("INSERT INTO github_review_comments (id,repo_id,pull_number,review_id,user_id,commit_sha,path,line,side,diff_hunk,in_reply_to_id,body,created_at,updated_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)").run(id14, repo4.id, number7, reviewId, botUser(ctx).id, sha2, path4, line2, side, diff2, parent2?.id ?? null, text25, at3, at3);
|
|
122326
122341
|
ctx.store.db.prepare("UPDATE github_issues SET updated_at = ? WHERE repo_id = ? AND number = ?").run(at3, repo4.id, number7);
|
|
122327
122342
|
return json2(reviewCommentShape(ctx, repo4, requireComment2(ctx, repo4.id, id14)), 201);
|
|
122328
122343
|
});
|
|
@@ -122548,8 +122563,8 @@ function seed7(ctx) {
|
|
|
122548
122563
|
for (const monitor3 of seed43.monitors ?? []) insertMonitor(monitor3, false);
|
|
122549
122564
|
for (const monitor3 of ctx.scene.world_rules?.monitors ?? []) insertMonitor(monitor3, true);
|
|
122550
122565
|
for (const board of seed43.dashboards ?? []) {
|
|
122551
|
-
const
|
|
122552
|
-
const id14 = `${
|
|
122566
|
+
const text25 = ctx.ids.fork("dashboard").alnumUpper(9).toLowerCase();
|
|
122567
|
+
const id14 = `${text25.slice(0, 3)}-${text25.slice(3, 6)}-${text25.slice(6)}`;
|
|
122553
122568
|
db3.prepare("INSERT INTO datadog_dashboards VALUES (?, ?, ?, ?, ?, ?, ?, ?)").run(
|
|
122554
122569
|
id14,
|
|
122555
122570
|
board.ref,
|
|
@@ -122745,7 +122760,7 @@ function boolean7(value4, name5) {
|
|
|
122745
122760
|
if (typeof value4 !== "boolean") throw new DatadogError(400, `Invalid ${name5}`);
|
|
122746
122761
|
return value4;
|
|
122747
122762
|
}
|
|
122748
|
-
function
|
|
122763
|
+
function text19(value4, name5) {
|
|
122749
122764
|
if (typeof value4 !== "string") throw new DatadogError(400, `Invalid ${name5}`);
|
|
122750
122765
|
return value4;
|
|
122751
122766
|
}
|
|
@@ -122810,7 +122825,7 @@ function parse7(c, body6, version5, old) {
|
|
|
122810
122825
|
const end = schedule3.end === void 0 ? old.end : timestamp2(schedule3.end, version5, "end");
|
|
122811
122826
|
if (end <= start2 || end <= now11) throw new DatadogError(400, "end must be after start and current time");
|
|
122812
122827
|
const zone5 = attrs[version5 === 1 ? "timezone" : "display_timezone"];
|
|
122813
|
-
const timezone = zone5 === void 0 ? old?.timezone ?? "UTC" :
|
|
122828
|
+
const timezone = zone5 === void 0 ? old?.timezone ?? "UTC" : text19(zone5, "timezone");
|
|
122814
122829
|
try {
|
|
122815
122830
|
new Intl.DateTimeFormat("en", { timeZone: timezone });
|
|
122816
122831
|
} catch {
|
|
@@ -122825,7 +122840,7 @@ function parse7(c, body6, version5, old) {
|
|
|
122825
122840
|
start: start2,
|
|
122826
122841
|
end,
|
|
122827
122842
|
canceled: old?.canceled ?? null,
|
|
122828
|
-
message: attrs.message === void 0 ? old?.message ?? "" :
|
|
122843
|
+
message: attrs.message === void 0 ? old?.message ?? "" : text19(attrs.message, "message"),
|
|
122829
122844
|
timezone,
|
|
122830
122845
|
mute_first: attrs.mute_first_recovery_notification === void 0 ? old?.mute_first ?? 0 : Number(boolean7(attrs.mute_first_recovery_notification, "mute_first_recovery_notification")),
|
|
122831
122846
|
notify_types: attrs.notify_end_types === void 0 ? old?.notify_types ?? '["expired"]' : JSON.stringify(list7(attrs.notify_end_types, "notify_end_types", ["expired", "canceled"])),
|
|
@@ -123056,9 +123071,9 @@ var datadogCoverage = [
|
|
|
123056
123071
|
];
|
|
123057
123072
|
|
|
123058
123073
|
// packages/server/src/twins/datadog/methods/search.ts
|
|
123059
|
-
function terms(
|
|
123060
|
-
const tokens3 =
|
|
123061
|
-
if ((
|
|
123074
|
+
function terms(text25) {
|
|
123075
|
+
const tokens3 = text25.match(/(?:[^\s"]|"[^"]*")+/g) ?? [];
|
|
123076
|
+
if ((text25.match(/"/g)?.length ?? 0) % 2) throw new DatadogError(400, "Invalid search query");
|
|
123062
123077
|
return tokens3.filter((token4) => token4 !== "AND").map((token4) => {
|
|
123063
123078
|
if (/^(OR|NOT)$|[()!]|^-/.test(token4)) unsupported4("monitor search expressions");
|
|
123064
123079
|
const colon = token4.indexOf(":");
|
|
@@ -123083,7 +123098,7 @@ function matches3(row2, term2) {
|
|
|
123083
123098
|
case "type":
|
|
123084
123099
|
return ["metric", "metric alert"].includes(term2.value);
|
|
123085
123100
|
default:
|
|
123086
|
-
return term2.value === "*" || [row2.name, row2.overall_state, ...tags4].some((
|
|
123101
|
+
return term2.value === "*" || [row2.name, row2.overall_state, ...tags4].some((text25) => text25.toLowerCase().includes(term2.value));
|
|
123087
123102
|
}
|
|
123088
123103
|
}
|
|
123089
123104
|
function counts(values2) {
|
|
@@ -123165,8 +123180,8 @@ function listEvents(c) {
|
|
|
123165
123180
|
function createEvent(c, input5) {
|
|
123166
123181
|
query4(c, []);
|
|
123167
123182
|
const body6 = object6(input5, "event");
|
|
123168
|
-
const title2 = string5(body6.title, "title"),
|
|
123169
|
-
if (
|
|
123183
|
+
const title2 = string5(body6.title, "title"), text25 = string5(body6.text, "text");
|
|
123184
|
+
if (text25.length > 4e3) throw new DatadogError(400, "Event text exceeds 4000 characters");
|
|
123170
123185
|
const now11 = c.env.ctx.clock.nowMs();
|
|
123171
123186
|
const seconds3 = body6.date_happened === void 0 ? Math.floor(now11 / 1e3) : body6.date_happened;
|
|
123172
123187
|
if (typeof seconds3 !== "number" || !Number.isSafeInteger(seconds3) || seconds3 < 0 || seconds3 < Math.floor(now11 / 1e3) - 18 * 3600 || seconds3 > Math.floor(now11 / 1e3) + 2 * 3600) throw new DatadogError(400, "Invalid date_happened: expected integer seconds within 18 hours past and 2 hours future");
|
|
@@ -123175,7 +123190,7 @@ function createEvent(c, input5) {
|
|
|
123175
123190
|
if (typeof alert !== "string" || !["error", "warning", "info", "success", "user_update", "recommendation", "snapshot"].includes(alert)) throw new DatadogError(400, "Invalid alert_type");
|
|
123176
123191
|
if (!["error", "warning", "info", "success"].includes(alert)) unsupported4(`event alert_type ${alert}`);
|
|
123177
123192
|
keys(body6, ["title", "text", "date_happened", "tags", "alert_type"], "event");
|
|
123178
|
-
const row2 = { id: nextEventId(c.env.ctx), ref: null, title: title2, text:
|
|
123193
|
+
const row2 = { id: nextEventId(c.env.ctx), ref: null, title: title2, text: text25, at: seconds3 * 1e3, tags: JSON.stringify([...body6.tags ?? []].sort()), alert_type: alert };
|
|
123179
123194
|
c.env.ctx.store.db.prepare("INSERT INTO datadog_events VALUES (?, ?, ?, ?, ?, ?, ?)").run(row2.id, row2.ref, row2.title, row2.text, row2.at, row2.tags, row2.alert_type);
|
|
123180
123195
|
return { status: "ok", event: eventShape(row2) };
|
|
123181
123196
|
}
|
|
@@ -123315,11 +123330,11 @@ function queryMetrics(c) {
|
|
|
123315
123330
|
// packages/server/src/twins/datadog/methods/logs.ts
|
|
123316
123331
|
async function searchLogs(c) {
|
|
123317
123332
|
try {
|
|
123318
|
-
const
|
|
123333
|
+
const text25 = await c.req.text();
|
|
123319
123334
|
let input5 = {};
|
|
123320
|
-
if (
|
|
123335
|
+
if (text25 !== "") {
|
|
123321
123336
|
try {
|
|
123322
|
-
input5 = JSON.parse(
|
|
123337
|
+
input5 = JSON.parse(text25);
|
|
123323
123338
|
} catch {
|
|
123324
123339
|
throw new DatadogError(400, "Invalid JSON body");
|
|
123325
123340
|
}
|
|
@@ -123967,8 +123982,8 @@ function posterOf(ctx, userId2) {
|
|
|
123967
123982
|
const row2 = ctx.store.db.prepare("SELECT name FROM slack_users WHERE id = ?").get(userId2) ?? ctx.store.db.prepare("SELECT name FROM slack_apps WHERE user_id = ?").get(userId2);
|
|
123968
123983
|
return row2 ? `@${row2.name}: ` : "";
|
|
123969
123984
|
}
|
|
123970
|
-
function opening(
|
|
123971
|
-
const flat2 =
|
|
123985
|
+
function opening(text25, max = 48) {
|
|
123986
|
+
const flat2 = text25.replace(/\s+/g, " ").trim();
|
|
123972
123987
|
if (flat2.length <= max) return flat2;
|
|
123973
123988
|
const cut = flat2.slice(0, max), space = cut.lastIndexOf(" ");
|
|
123974
123989
|
return `${(space > max * 0.6 ? cut.slice(0, space) : cut).replace(/[\s,.;:!?-]+$/, "")}\u2026`;
|
|
@@ -124649,7 +124664,7 @@ registerMethods({
|
|
|
124649
124664
|
});
|
|
124650
124665
|
|
|
124651
124666
|
// packages/server/src/twins/slack/canvas-html.ts
|
|
124652
|
-
var escape5 = (
|
|
124667
|
+
var escape5 = (text25) => text25.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
124653
124668
|
var gap2 = () => {
|
|
124654
124669
|
throw new SlackError("invalid_arguments", { ancha_gap: "Canvas HTML conversion for this Markdown syntax is not implemented" });
|
|
124655
124670
|
};
|
|
@@ -124726,14 +124741,14 @@ function canvasHtml(markdown) {
|
|
|
124726
124741
|
return out.length ? `${out.join("\n")}
|
|
124727
124742
|
` : "";
|
|
124728
124743
|
}
|
|
124729
|
-
function inline(
|
|
124730
|
-
if (
|
|
124731
|
-
if (/\[[^\]]*\]\[|\\[\s\S]| {2}$/.test(
|
|
124744
|
+
function inline(text25) {
|
|
124745
|
+
if (text25.length > 16384) gap2();
|
|
124746
|
+
if (/\[[^\]]*\]\[|\\[\s\S]| {2}$/.test(text25)) gap2();
|
|
124732
124747
|
const token4 = /`([^`\n]+)`|\*\*([^*\n]+)\*\*|__([^_\n]+)__|\*([^*\n]+)\*|_([^_\n]+)_|\[([^\]\n]+)\]\(([^\s)]+)\)/g;
|
|
124733
124748
|
const out = [];
|
|
124734
124749
|
let offset17 = 0;
|
|
124735
|
-
for (const match3 of
|
|
124736
|
-
out.push(escape5(
|
|
124750
|
+
for (const match3 of text25.matchAll(token4)) {
|
|
124751
|
+
out.push(escape5(text25.slice(offset17, match3.index)));
|
|
124737
124752
|
if (match3[1] !== void 0) out.push(`<code>${escape5(match3[1])}</code>`);
|
|
124738
124753
|
else if (match3[2] !== void 0 || match3[3] !== void 0) out.push(`<strong>${escape5(match3[2] ?? match3[3])}</strong>`);
|
|
124739
124754
|
else if (match3[4] !== void 0 || match3[5] !== void 0) out.push(`<em>${escape5(match3[4] ?? match3[5])}</em>`);
|
|
@@ -124743,7 +124758,7 @@ function inline(text24) {
|
|
|
124743
124758
|
}
|
|
124744
124759
|
offset17 = match3.index + match3[0].length;
|
|
124745
124760
|
}
|
|
124746
|
-
out.push(escape5(
|
|
124761
|
+
out.push(escape5(text25.slice(offset17)));
|
|
124747
124762
|
return out.join("");
|
|
124748
124763
|
}
|
|
124749
124764
|
|
|
@@ -125363,11 +125378,11 @@ function salesforceTwin() {
|
|
|
125363
125378
|
try {
|
|
125364
125379
|
let body6;
|
|
125365
125380
|
if (c.req.method !== "GET") {
|
|
125366
|
-
const
|
|
125367
|
-
if (
|
|
125368
|
-
if (
|
|
125381
|
+
const text25 = await c.req.text();
|
|
125382
|
+
if (text25.length > 1e6) throw new SalesforceError(413, "REQUEST_LIMIT_EXCEEDED", "Request body exceeds 1 MB.");
|
|
125383
|
+
if (text25) {
|
|
125369
125384
|
try {
|
|
125370
|
-
body6 = JSON.parse(
|
|
125385
|
+
body6 = JSON.parse(text25);
|
|
125371
125386
|
} catch {
|
|
125372
125387
|
throw new SalesforceError(400, "JSON_PARSER_ERROR", "Malformed JSON.");
|
|
125373
125388
|
}
|
|
@@ -126982,9 +126997,9 @@ function namePrefix(name5, value4) {
|
|
|
126982
126997
|
}
|
|
126983
126998
|
return false;
|
|
126984
126999
|
}
|
|
126985
|
-
function fullTextMatch(
|
|
127000
|
+
function fullTextMatch(text25, value4) {
|
|
126986
127001
|
const words6 = (input5) => input5.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter(Boolean);
|
|
126987
|
-
const haystack = words6(
|
|
127002
|
+
const haystack = words6(text25), needle = words6(value4.replace(/^"|"$/g, ""));
|
|
126988
127003
|
if (!needle.length) return false;
|
|
126989
127004
|
for (let i = 0; i + needle.length <= haystack.length; i++) if (needle.every((word, j) => haystack[i + j] === word)) return true;
|
|
126990
127005
|
return false;
|
|
@@ -127326,14 +127341,14 @@ function searchable(ctx, caller2, file3, access3) {
|
|
|
127326
127341
|
const granted = effectivePermissions(ctx, file3);
|
|
127327
127342
|
const people3 = (min) => granted.filter((entry2) => (entry2.grant.type === "user" || entry2.grant.type === "group") && RANK2[entry2.grant.role] >= RANK2[min]).map((entry2) => entry2.grant.email);
|
|
127328
127343
|
const anyone = granted.find((entry2) => entry2.grant.type === "anyone"), domain2 = granted.find((entry2) => entry2.grant.type === "domain");
|
|
127329
|
-
const
|
|
127344
|
+
const text25 = file3.content !== null && (isEditorFile(file3) || /^text\//.test(file3.mime_type)) ? file3.content.toString("utf8") : "";
|
|
127330
127345
|
const owner3 = getUser4(ctx, file3.owner);
|
|
127331
127346
|
return {
|
|
127332
127347
|
name: file3.name,
|
|
127333
127348
|
mimeType: file3.mime_type,
|
|
127334
127349
|
fullText: `${file3.name}
|
|
127335
127350
|
${file3.description ?? ""}
|
|
127336
|
-
${
|
|
127351
|
+
${text25}`,
|
|
127337
127352
|
trashed: trashedBy(ctx, file3) !== void 0,
|
|
127338
127353
|
starred: file3.starred === 1,
|
|
127339
127354
|
createdMs: file3.created_ms,
|
|
@@ -127908,20 +127923,20 @@ function exportFile(call2) {
|
|
|
127908
127923
|
if (!isEditorFile(file3)) throw new DriveError(403, "fileNotExportable", "Export only supports Docs Editors files.");
|
|
127909
127924
|
if (!DRIVE_EXPORT_FORMATS[file3.mime_type].includes(target5)) throw new DriveError(400, "badRequest", "The requested conversion is not supported.", { name: "convertTo" });
|
|
127910
127925
|
if (!EXPORTS[file3.mime_type].includes(target5)) unsupported11(`export to ${target5}`);
|
|
127911
|
-
const
|
|
127912
|
-
let body6 =
|
|
127913
|
-
if (target5 === "text/html") body6 = `<html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"></head><body>${
|
|
127914
|
-
else if (target5 === "text/tab-separated-values") body6 = csvRows(
|
|
127915
|
-
else if (target5 === "text/plain" && file3.mime_type === "application/vnd.google-apps.document") body6 = `\uFEFF${
|
|
127926
|
+
const text25 = (file3.content ?? Buffer.alloc(0)).toString("utf8");
|
|
127927
|
+
let body6 = text25;
|
|
127928
|
+
if (target5 === "text/html") body6 = `<html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"></head><body>${text25.split("\n").map((line2) => `<p>${line2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</p>`).join("")}</body></html>`;
|
|
127929
|
+
else if (target5 === "text/tab-separated-values") body6 = csvRows(text25).map((row2) => row2.join(" ")).join("\n");
|
|
127930
|
+
else if (target5 === "text/plain" && file3.mime_type === "application/vnd.google-apps.document") body6 = `\uFEFF${text25}`;
|
|
127916
127931
|
return new Response(body6, { status: 200, headers: { "content-type": `${target5}; charset=utf-8` } });
|
|
127917
127932
|
}
|
|
127918
|
-
function csvRows(
|
|
127933
|
+
function csvRows(text25) {
|
|
127919
127934
|
const rows7 = [];
|
|
127920
127935
|
let row2 = [], cell2 = "", quoted3 = false;
|
|
127921
|
-
for (let i = 0; i <
|
|
127922
|
-
const char =
|
|
127936
|
+
for (let i = 0; i < text25.length; i++) {
|
|
127937
|
+
const char = text25[i];
|
|
127923
127938
|
if (quoted3) {
|
|
127924
|
-
if (char === '"' &&
|
|
127939
|
+
if (char === '"' && text25[i + 1] === '"') {
|
|
127925
127940
|
cell2 += '"';
|
|
127926
127941
|
i++;
|
|
127927
127942
|
} else if (char === '"') quoted3 = false;
|
|
@@ -128377,7 +128392,7 @@ function message5(ctx, args) {
|
|
|
128377
128392
|
thread4 = ref22 && ctx.store.db.prepare("SELECT thread_id FROM gmail_messages WHERE mailbox = ? AND rfc822_id = ?").get(box.address, ref22.rfc822_id)?.thread_id;
|
|
128378
128393
|
if (!thread4) return checkOutcome(!args.exists, expected, `${args.in_thread_of} is not in ${box.address}'s mailbox`);
|
|
128379
128394
|
}
|
|
128380
|
-
const lower4 = (value4) => value4.toLowerCase(), has2 = (
|
|
128395
|
+
const lower4 = (value4) => value4.toLowerCase(), has2 = (text25, parts3) => (parts3 ?? []).every((part) => lower4(text25).includes(lower4(part)));
|
|
128381
128396
|
const same3 = (a, b) => a !== void 0 && lower4(a) === lower4(parseGmailAddress(b)?.email ?? b);
|
|
128382
128397
|
const matches9 = mailboxMessages(ctx, box.address).filter((row2) => {
|
|
128383
128398
|
const meta3 = metaOf(row2);
|
|
@@ -128404,12 +128419,12 @@ import { randomUUID as randomUUID3 } from "node:crypto";
|
|
|
128404
128419
|
import { STATUS_CODES } from "node:http";
|
|
128405
128420
|
var MAX_PARTS2 = 100;
|
|
128406
128421
|
var BODYLESS = /* @__PURE__ */ new Set(["GET", "HEAD", "DELETE"]);
|
|
128407
|
-
function traced(
|
|
128408
|
-
if (
|
|
128422
|
+
function traced(text25) {
|
|
128423
|
+
if (text25 === "") return void 0;
|
|
128409
128424
|
try {
|
|
128410
|
-
return JSON.parse(
|
|
128425
|
+
return JSON.parse(text25);
|
|
128411
128426
|
} catch {
|
|
128412
|
-
return
|
|
128427
|
+
return text25;
|
|
128413
128428
|
}
|
|
128414
128429
|
}
|
|
128415
128430
|
function batchHandler(app2) {
|
|
@@ -128436,7 +128451,7 @@ function batchHandler(app2) {
|
|
|
128436
128451
|
const content2 = payload2.join("\r\n\r\n").trim();
|
|
128437
128452
|
const url4 = new URL(target5, c.req.url);
|
|
128438
128453
|
const response5 = await app2.fetch(new Request(url4, { method: method2, headers, ...!BODYLESS.has(method2.toUpperCase()) && content2 !== "" && { body: content2 } }), c.env);
|
|
128439
|
-
const
|
|
128454
|
+
const text25 = await response5.text();
|
|
128440
128455
|
c.env.ctx.trace.record({
|
|
128441
128456
|
source: "agent",
|
|
128442
128457
|
service: "gmail",
|
|
@@ -128445,7 +128460,7 @@ function batchHandler(app2) {
|
|
|
128445
128460
|
...url4.search.length > 1 && { query: url4.search.slice(1) },
|
|
128446
128461
|
status: response5.status,
|
|
128447
128462
|
...content2 !== "" && { request: traced(content2) },
|
|
128448
|
-
...
|
|
128463
|
+
...text25 !== "" && { response: traced(text25) },
|
|
128449
128464
|
gap: response5.status === 501,
|
|
128450
128465
|
note: "batch part"
|
|
128451
128466
|
});
|
|
@@ -128456,7 +128471,7 @@ Content-ID: <response-${contentId}>\r
|
|
|
128456
128471
|
HTTP/1.1 ${response5.status} ${STATUS_CODES[response5.status] ?? ""}\r
|
|
128457
128472
|
Content-Type: ${response5.headers.get("content-type") ?? "application/json; charset=UTF-8"}\r
|
|
128458
128473
|
\r
|
|
128459
|
-
${
|
|
128474
|
+
${text25}\r
|
|
128460
128475
|
`;
|
|
128461
128476
|
}
|
|
128462
128477
|
return new Response(`${body6}--${out}--\r
|
|
@@ -128537,7 +128552,7 @@ function tokenize5(q) {
|
|
|
128537
128552
|
return tokens3;
|
|
128538
128553
|
}
|
|
128539
128554
|
var WORD = /[\p{L}\p{N}]+/gu;
|
|
128540
|
-
var words3 = (
|
|
128555
|
+
var words3 = (text25) => text25.toLowerCase().match(WORD) ?? [];
|
|
128541
128556
|
function containsWords(haystack, needle) {
|
|
128542
128557
|
const want = words3(needle);
|
|
128543
128558
|
if (!want.length) return true;
|
|
@@ -129609,7 +129624,7 @@ ${root3}`;
|
|
|
129609
129624
|
function parseXml(source) {
|
|
129610
129625
|
const root3 = { name: "#document", children: [], text: "" };
|
|
129611
129626
|
const stack = [root3];
|
|
129612
|
-
const decode6 = (
|
|
129627
|
+
const decode6 = (text25) => text25.replace(/&(lt|gt|amp|quot|apos|#\d+|#x[0-9a-fA-F]+);/g, (_, entity3) => entity3 === "lt" ? "<" : entity3 === "gt" ? ">" : entity3 === "amp" ? "&" : entity3 === "quot" ? '"' : entity3 === "apos" ? "'" : String.fromCodePoint(entity3[1] === "x" ? parseInt(entity3.slice(2), 16) : parseInt(entity3.slice(1), 10)));
|
|
129613
129628
|
const body6 = source.replace(/^?\s*<\?xml[^>]*\?>/, "").replace(/<!--[\s\S]*?-->/g, "");
|
|
129614
129629
|
const pattern = /<!\[CDATA\[([\s\S]*?)\]\]>|<(\/?)([A-Za-z_][\w:.-]*)((?:\s+[^\s=>/]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>/g;
|
|
129615
129630
|
let last = 0, match3;
|
|
@@ -131020,7 +131035,7 @@ function connection2(r2, type, rows7, args, toObj) {
|
|
|
131020
131035
|
}
|
|
131021
131036
|
};
|
|
131022
131037
|
}
|
|
131023
|
-
var slug5 = (
|
|
131038
|
+
var slug5 = (text25) => text25.toLowerCase().normalize("NFD").replace(new RegExp("\\p{M}", "gu"), "").replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 60);
|
|
131024
131039
|
var initials = (name5) => name5.split(/\s+/).filter(Boolean).map((w2) => w2[0].toUpperCase()).slice(0, 2).join("");
|
|
131025
131040
|
var identifier3 = (r2, row2) => `${teamById(r2.ctx, row2.team_id).key}-${row2.number}`;
|
|
131026
131041
|
var issueUrl = (r2, row2) => `https://linear.app/${r2.org.url_key}/issue/${identifier3(r2, row2)}/${slug5(row2.title)}`;
|
|
@@ -131596,7 +131611,7 @@ var Abort = class extends Error {
|
|
|
131596
131611
|
var authError = (message7) => error62(message7, { type: "authentication error", code: "AUTHENTICATION_ERROR", userPresentableMessage: "You need to authenticate to access this operation." }, 401);
|
|
131597
131612
|
async function handleGraphql2(c) {
|
|
131598
131613
|
const ctx = c.env.ctx;
|
|
131599
|
-
const
|
|
131614
|
+
const text25 = await c.req.text();
|
|
131600
131615
|
try {
|
|
131601
131616
|
const viewerId = withRead(ctx, () => {
|
|
131602
131617
|
const header3 = (c.req.header("authorization") ?? "").trim();
|
|
@@ -131608,7 +131623,7 @@ async function handleGraphql2(c) {
|
|
|
131608
131623
|
if (viewerId === null) return errors(401, [authError("Authentication failed: the API key is invalid")]);
|
|
131609
131624
|
let body6;
|
|
131610
131625
|
try {
|
|
131611
|
-
body6 = JSON.parse(
|
|
131626
|
+
body6 = JSON.parse(text25);
|
|
131612
131627
|
} catch {
|
|
131613
131628
|
return errors(400, [error62("Body is not valid JSON", { type: "graphql error", code: "BAD_REQUEST" }, 400)]);
|
|
131614
131629
|
}
|
|
@@ -132818,8 +132833,8 @@ function listLogs2(call2) {
|
|
|
132818
132833
|
let events3 = call2.ctx.store.db.prepare("SELECT * FROM okta_logs WHERE published_ms >= ? AND published_ms < ? ORDER BY seq").all(since, until).map((row2) => ({ row: row2, json: eventJson(call2.ctx, row2) }));
|
|
132819
132834
|
if (filter4) events3 = events3.filter(({ json: json33 }) => filter4(lookupIn(json33)));
|
|
132820
132835
|
if (words6.length) events3 = events3.filter(({ json: json33 }) => {
|
|
132821
|
-
const
|
|
132822
|
-
return words6.every((word) =>
|
|
132836
|
+
const text25 = JSON.stringify(json33).toLowerCase();
|
|
132837
|
+
return words6.every((word) => text25.includes(word));
|
|
132823
132838
|
});
|
|
132824
132839
|
if (order6 === "DESCENDING") events3.reverse();
|
|
132825
132840
|
const { page: page18, headers } = paginate3(call2, events3, (entry2) => String(entry2.row.seq), limitOf(query10.get("limit"), 100, 1e3));
|
|
@@ -132878,11 +132893,11 @@ async function handle9(c) {
|
|
|
132878
132893
|
const error64 = new OktaError(404, "E0000007", `Not found: Resource not found: ${url4.pathname} (Resource)`, [gapMessage(c)]);
|
|
132879
132894
|
return respond2(base4, 404, errorBody4(error64, requestId4), { [GAP_HEADER]: "1" });
|
|
132880
132895
|
}
|
|
132881
|
-
const
|
|
132896
|
+
const text25 = method2 === "GET" || method2 === "DELETE" ? "" : await c.req.text();
|
|
132882
132897
|
let body6;
|
|
132883
|
-
if (
|
|
132898
|
+
if (text25.trim()) {
|
|
132884
132899
|
try {
|
|
132885
|
-
body6 = JSON.parse(
|
|
132900
|
+
body6 = JSON.parse(text25);
|
|
132886
132901
|
} catch {
|
|
132887
132902
|
throw new OktaError(400, "E0000003", "The request body was not well-formed.");
|
|
132888
132903
|
}
|
|
@@ -136325,7 +136340,7 @@ function bool4(value4, name5) {
|
|
|
136325
136340
|
if (value4 === "true" || value4 === "false") return value4 === "true";
|
|
136326
136341
|
throw invalid14(name5);
|
|
136327
136342
|
}
|
|
136328
|
-
function
|
|
136343
|
+
function text20(value4, name5, max = 256) {
|
|
136329
136344
|
if (value4 === void 0 || value4 === null) return void 0;
|
|
136330
136345
|
if (typeof value4 !== "string" || value4.length > max) throw invalid14(name5);
|
|
136331
136346
|
return value4;
|
|
@@ -136600,7 +136615,7 @@ function createUser2(call2) {
|
|
|
136600
136615
|
const email11 = String(emails[0]).trim().toLowerCase();
|
|
136601
136616
|
if (!EMAIL15.test(email11)) throw invalid14("email_address");
|
|
136602
136617
|
if (ctx.store.db.prepare("SELECT 1 FROM clerk_users WHERE email = ?").get(email11)) throw taken("email_address", "email address");
|
|
136603
|
-
const username2 =
|
|
136618
|
+
const username2 = text20(body6.username, "username", 64);
|
|
136604
136619
|
if (username2 !== void 0) {
|
|
136605
136620
|
if (!/^[A-Za-z0-9_-]{4,64}$/.test(username2)) throw new ClerkError(422, "form_username_invalid_character", "Usernames can only contain letters, numbers, underscores and dashes.", "Usernames can only contain letters, numbers, underscores and dashes.", { param_name: "username" });
|
|
136606
136621
|
if (ctx.store.db.prepare("SELECT 1 FROM clerk_users WHERE username = ?").get(username2)) throw taken("username", "username");
|
|
@@ -136613,10 +136628,10 @@ function createUser2(call2) {
|
|
|
136613
136628
|
email: email11,
|
|
136614
136629
|
email_id: newId2(ctx.ids, "idn"),
|
|
136615
136630
|
email_strategy: "admin",
|
|
136616
|
-
first_name:
|
|
136617
|
-
last_name:
|
|
136631
|
+
first_name: text20(body6.first_name, "first_name") ?? null,
|
|
136632
|
+
last_name: text20(body6.last_name, "last_name") ?? null,
|
|
136618
136633
|
username: username2 ?? null,
|
|
136619
|
-
external_id:
|
|
136634
|
+
external_id: text20(body6.external_id, "external_id") ?? null,
|
|
136620
136635
|
password_enabled: password === void 0 ? 0 : 1,
|
|
136621
136636
|
banned: 0,
|
|
136622
136637
|
locked: 0,
|
|
@@ -136671,11 +136686,11 @@ function updateUser2(call2) {
|
|
|
136671
136686
|
["primary_phone_number_id", "primary_web3_wallet_id", "profile_image_id", "password_digest", "password_hasher", "totp_secret", "backup_codes", "create_organizations_limit", "created_at", "notify_primary_email_address_changed"]
|
|
136672
136687
|
);
|
|
136673
136688
|
const user8 = userFor2(call2), next2 = { ...user8, updated_ms: ctx.clock.nowMs() };
|
|
136674
|
-
if ("first_name" in body6) next2.first_name =
|
|
136675
|
-
if ("last_name" in body6) next2.last_name =
|
|
136676
|
-
if ("external_id" in body6) next2.external_id =
|
|
136689
|
+
if ("first_name" in body6) next2.first_name = text20(body6.first_name, "first_name") ?? null;
|
|
136690
|
+
if ("last_name" in body6) next2.last_name = text20(body6.last_name, "last_name") ?? null;
|
|
136691
|
+
if ("external_id" in body6) next2.external_id = text20(body6.external_id, "external_id") ?? null;
|
|
136677
136692
|
if ("username" in body6) {
|
|
136678
|
-
const username2 =
|
|
136693
|
+
const username2 = text20(body6.username, "username", 64) ?? null;
|
|
136679
136694
|
if (username2 !== null && username2 !== user8.username && ctx.store.db.prepare("SELECT 1 FROM clerk_users WHERE username = ?").get(username2)) throw taken("username", "username");
|
|
136680
136695
|
next2.username = username2;
|
|
136681
136696
|
}
|
|
@@ -136763,7 +136778,7 @@ function createOrg(call2) {
|
|
|
136763
136778
|
const { ctx } = call2;
|
|
136764
136779
|
params7(call2, []);
|
|
136765
136780
|
const body6 = fields7(call2, ["name", "slug", "created_by", "max_allowed_memberships", "public_metadata", "private_metadata"], ["role_set_key"]);
|
|
136766
|
-
const name5 =
|
|
136781
|
+
const name5 = text20(body6.name, "name");
|
|
136767
136782
|
if (!name5?.trim()) throw missing3("name");
|
|
136768
136783
|
const slug10 = checkSlug(ctx, body6.slug ?? slugify2(name5));
|
|
136769
136784
|
const creator = body6.created_by === void 0 ? void 0 : getUser6(ctx, String(body6.created_by));
|
|
@@ -136798,7 +136813,7 @@ function updateOrg(call2) {
|
|
|
136798
136813
|
const body6 = fields7(call2, ["name", "slug", "max_allowed_memberships", "admin_delete_enabled", "public_metadata", "private_metadata"]);
|
|
136799
136814
|
const org5 = orgFor(call2), next2 = { ...org5, updated_ms: ctx.clock.nowMs() };
|
|
136800
136815
|
if (body6.name !== void 0) {
|
|
136801
|
-
const name5 =
|
|
136816
|
+
const name5 = text20(body6.name, "name");
|
|
136802
136817
|
if (!name5?.trim()) throw invalid14("name");
|
|
136803
136818
|
next2.name = name5;
|
|
136804
136819
|
}
|
|
@@ -137040,12 +137055,12 @@ async function handle11(c) {
|
|
|
137040
137055
|
if (clerkRoutes.some((candidate) => candidate.pattern.test(url4.pathname))) unsupported15(`${method2} ${url4.pathname}`);
|
|
137041
137056
|
return errorResponse7(new ClerkError(404, "resource_not_found", "not found", gapMessage(c)), traceId, { [GAP_HEADER]: "1" });
|
|
137042
137057
|
}
|
|
137043
|
-
const
|
|
137058
|
+
const text25 = method2 === "GET" ? "" : await c.req.text();
|
|
137044
137059
|
let body6 = {};
|
|
137045
|
-
if (
|
|
137060
|
+
if (text25.trim()) {
|
|
137046
137061
|
let parsed3;
|
|
137047
137062
|
try {
|
|
137048
|
-
parsed3 = JSON.parse(
|
|
137063
|
+
parsed3 = JSON.parse(text25);
|
|
137049
137064
|
} catch {
|
|
137050
137065
|
throw new ClerkError(400, "malformed_request", "malformed request", "The request body is not valid JSON.");
|
|
137051
137066
|
}
|
|
@@ -137833,12 +137848,12 @@ async function handle12(c) {
|
|
|
137833
137848
|
response5.headers.set(GAP_HEADER, "1");
|
|
137834
137849
|
return response5;
|
|
137835
137850
|
}
|
|
137836
|
-
const
|
|
137851
|
+
const text25 = method2 === "GET" || method2 === "DELETE" ? "" : await c.req.text();
|
|
137837
137852
|
let body6 = {};
|
|
137838
|
-
if (
|
|
137853
|
+
if (text25.trim() && !route12.public) {
|
|
137839
137854
|
let parsed3;
|
|
137840
137855
|
try {
|
|
137841
|
-
parsed3 = JSON.parse(
|
|
137856
|
+
parsed3 = JSON.parse(text25);
|
|
137842
137857
|
} catch {
|
|
137843
137858
|
throw new BetterStackError(400, "Invalid JSON in the request body");
|
|
137844
137859
|
}
|
|
@@ -138169,8 +138184,8 @@ function handle13(route12) {
|
|
|
138169
138184
|
if (!known2) throw new Error(`no Notion parameter list for ${key4}`);
|
|
138170
138185
|
return async (c) => {
|
|
138171
138186
|
const ctx = c.env.ctx;
|
|
138172
|
-
const
|
|
138173
|
-
const rid = requestId2(ctx, c,
|
|
138187
|
+
const text25 = route12.method === "POST" || route12.method === "PATCH" ? await c.req.text() : "";
|
|
138188
|
+
const rid = requestId2(ctx, c, text25);
|
|
138174
138189
|
try {
|
|
138175
138190
|
const run3 = () => {
|
|
138176
138191
|
const token4 = /^Bearer\s+(\S+)$/i.exec(c.req.header("authorization") ?? "")?.[1];
|
|
@@ -138181,10 +138196,10 @@ function handle13(route12) {
|
|
|
138181
138196
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(version5)) throw new NotionError(400, "validation_error", `Notion-Version header failed validation: Notion-Version header should be a valid version, instead was \`"${version5}"\`.`);
|
|
138182
138197
|
if (version5 < NOTION_VERSION) unsupported17(`Notion-Version ${version5}; the twin serves ${NOTION_VERSION} shapes (data sources)`);
|
|
138183
138198
|
let body6 = {};
|
|
138184
|
-
if (
|
|
138199
|
+
if (text25.trim()) {
|
|
138185
138200
|
let parsed3;
|
|
138186
138201
|
try {
|
|
138187
|
-
parsed3 = JSON.parse(
|
|
138202
|
+
parsed3 = JSON.parse(text25);
|
|
138188
138203
|
} catch {
|
|
138189
138204
|
throw new NotionError(400, "invalid_json", "Error parsing JSON body.");
|
|
138190
138205
|
}
|
|
@@ -138403,12 +138418,12 @@ function blockFromInput(ctx, input5, path4) {
|
|
|
138403
138418
|
if (type === void 0) shouldBe(`${path4}.type`, "defined", void 0);
|
|
138404
138419
|
if (!NOTION_BLOCK_TYPES.includes(type)) return unsupported17(`block type ${type}`);
|
|
138405
138420
|
const body6 = block2[type] ?? {};
|
|
138406
|
-
const
|
|
138421
|
+
const text25 = () => richText(ctx, body6.rich_text ?? [], `${path4}.${type}.rich_text`);
|
|
138407
138422
|
const color2 = body6.color ?? "default";
|
|
138408
138423
|
const content2 = type === "divider" ? {} : type === "bookmark" ? (() => {
|
|
138409
138424
|
if (typeof body6.url !== "string") shouldBe(`${path4}.bookmark.url`, "a string", body6.url);
|
|
138410
138425
|
return { caption: [], url: body6.url };
|
|
138411
|
-
})() : type === "code" ? { caption: [], rich_text:
|
|
138426
|
+
})() : type === "code" ? { caption: [], rich_text: text25(), language: body6.language ?? "plain text" } : type === "to_do" ? { rich_text: text25(), checked: !!body6.checked, color: color2 } : type === "callout" ? { rich_text: text25(), icon: body6.icon ?? { type: "emoji", emoji: "\u{1F4A1}" }, color: color2 } : type.startsWith("heading_") ? { rich_text: text25(), is_toggleable: !!body6.is_toggleable, color: color2 } : { rich_text: text25(), color: color2 };
|
|
138412
138427
|
const nested = body6.children ?? [];
|
|
138413
138428
|
if (!Array.isArray(nested)) shouldBe(`${path4}.${type}.children`, "an array", nested);
|
|
138414
138429
|
return { type, content: content2, children: nested };
|
|
@@ -139157,16 +139172,16 @@ function limitOffset(value4, fallback = 500) {
|
|
|
139157
139172
|
function handle14(route12) {
|
|
139158
139173
|
return async (c) => {
|
|
139159
139174
|
const ctx = c.env.ctx;
|
|
139160
|
-
const
|
|
139175
|
+
const text25 = ["POST", "PUT", "PATCH"].includes(route12.method) ? await c.req.text() : "";
|
|
139161
139176
|
try {
|
|
139162
139177
|
const go = () => {
|
|
139163
139178
|
const token4 = /^Bearer\s+(\S+)$/i.exec(c.req.header("authorization") ?? "")?.[1];
|
|
139164
139179
|
const row2 = token4 ? ctx.store.db.prepare("SELECT member_id FROM attio_tokens WHERE token = ?").get(token4) : void 0;
|
|
139165
139180
|
if (!row2) throw new AttioError(401, "auth_error", "unauthorized", "Your API token is invalid or has been revoked.");
|
|
139166
139181
|
let body6 = {};
|
|
139167
|
-
if (
|
|
139182
|
+
if (text25.trim()) {
|
|
139168
139183
|
try {
|
|
139169
|
-
body6 = JSON.parse(
|
|
139184
|
+
body6 = JSON.parse(text25);
|
|
139170
139185
|
} catch {
|
|
139171
139186
|
invalid17("Body payload validation error: the body is not valid JSON.");
|
|
139172
139187
|
}
|
|
@@ -140961,7 +140976,7 @@ function page10(items, query10) {
|
|
|
140961
140976
|
function handle16(route12) {
|
|
140962
140977
|
return async (c) => {
|
|
140963
140978
|
const ctx = c.env.ctx;
|
|
140964
|
-
const
|
|
140979
|
+
const text25 = route12.method === "POST" || route12.method === "PATCH" ? await c.req.text() : "";
|
|
140965
140980
|
try {
|
|
140966
140981
|
const go = () => {
|
|
140967
140982
|
const header3 = c.req.header("authorization");
|
|
@@ -140971,9 +140986,9 @@ function handle16(route12) {
|
|
|
140971
140986
|
if (!key4) throw new ResendError(403, "invalid_api_key", "API key is invalid");
|
|
140972
140987
|
if (key4.permission === "sending_access" && !route12.sending) throw new ResendError(401, "restricted_api_key", "This API key is restricted to only send emails");
|
|
140973
140988
|
let body6 = {};
|
|
140974
|
-
if (
|
|
140989
|
+
if (text25.trim()) {
|
|
140975
140990
|
try {
|
|
140976
|
-
body6 = JSON.parse(
|
|
140991
|
+
body6 = JSON.parse(text25);
|
|
140977
140992
|
} catch {
|
|
140978
140993
|
invalid18("Invalid JSON in the request body.", "validation_error", 400);
|
|
140979
140994
|
}
|
|
@@ -140983,7 +140998,7 @@ function handle16(route12) {
|
|
|
140983
140998
|
if (keyHeader !== void 0) {
|
|
140984
140999
|
if (!keyHeader || keyHeader.length > 256) invalid18("The idempotency key must be between 1 and 256 characters.", "invalid_idempotency_key", 400);
|
|
140985
141000
|
const fingerprint = createHash37("sha256").update(`${route12.path}
|
|
140986
|
-
${
|
|
141001
|
+
${text25}`).digest("hex");
|
|
140987
141002
|
const seen = ctx.store.db.prepare("SELECT fingerprint, body FROM resend_idempotency WHERE key = ?").get(keyHeader);
|
|
140988
141003
|
if (seen) {
|
|
140989
141004
|
if (seen.fingerprint !== fingerprint) throw new ResendError(409, "invalid_idempotent_request", "Same idempotency key used with a different request payload. Change your idempotency key or payload.");
|
|
@@ -141052,10 +141067,10 @@ var UNIT_MS = { min: 6e4, minute: 6e4, hr: 36e5, hour: 36e5, day: 864e5, week: 6
|
|
|
141052
141067
|
function scheduleTime(r2, value4) {
|
|
141053
141068
|
if (value4 === void 0 || value4 === null) invalid18("Missing `scheduled_at` field.", "missing_required_field");
|
|
141054
141069
|
if (typeof value4 !== "string") invalid18("The `scheduled_at` field must be a string.");
|
|
141055
|
-
const now11 = r2.ctx.clock.nowMs(),
|
|
141056
|
-
const relative2 = /^in\s+(\d{1,6})\s+(min|minute|hr|hour|day|week)s?$/i.exec(
|
|
141057
|
-
const iso22 = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/i.exec(
|
|
141058
|
-
const ms = relative2 ? now11 + Number(relative2[1]) * UNIT_MS[relative2[2].toLowerCase()] : iso22 ? Date.parse(iso22[1] && !iso22[2] ? `${
|
|
141070
|
+
const now11 = r2.ctx.clock.nowMs(), text25 = value4.trim();
|
|
141071
|
+
const relative2 = /^in\s+(\d{1,6})\s+(min|minute|hr|hour|day|week)s?$/i.exec(text25);
|
|
141072
|
+
const iso22 = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/i.exec(text25);
|
|
141073
|
+
const ms = relative2 ? now11 + Number(relative2[1]) * UNIT_MS[relative2[2].toLowerCase()] : iso22 ? Date.parse(iso22[1] && !iso22[2] ? `${text25}Z` : text25) : unsupported20(`scheduled_at in natural language ("${text25}")`);
|
|
141059
141074
|
if (!Number.isFinite(ms)) invalid18("The `scheduled_at` field must be a valid date.");
|
|
141060
141075
|
if (ms <= now11) invalid18("The `scheduled_at` field must be a date in the future.");
|
|
141061
141076
|
if (ms > now11 + 30 * 864e5) invalid18("The `scheduled_at` field must be within the next 30 days.");
|
|
@@ -141663,8 +141678,8 @@ function zip(files2, modifiedMs) {
|
|
|
141663
141678
|
const dosDate = date10.getUTCFullYear() - 1980 << 9 | date10.getUTCMonth() + 1 << 5 | date10.getUTCDate();
|
|
141664
141679
|
const locals = [], centrals = [];
|
|
141665
141680
|
let offset17 = 0;
|
|
141666
|
-
for (const [name5,
|
|
141667
|
-
const raw3 = Buffer.from(
|
|
141681
|
+
for (const [name5, text25] of files2) {
|
|
141682
|
+
const raw3 = Buffer.from(text25, "utf8"), data5 = deflateRawSync(raw3), nameBytes = Buffer.from(name5, "utf8"), checksum2 = crc322(raw3);
|
|
141668
141683
|
const local2 = Buffer.alloc(30);
|
|
141669
141684
|
local2.writeUInt32LE(67324752, 0);
|
|
141670
141685
|
local2.writeUInt16LE(20, 4);
|
|
@@ -141726,7 +141741,7 @@ function unzip(bytes2) {
|
|
|
141726
141741
|
var DOCX_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
141727
141742
|
function buildDocx(paragraphs, properties3) {
|
|
141728
141743
|
const iso22 = (ms) => new Date(ms).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
141729
|
-
const body6 = paragraphs.map((
|
|
141744
|
+
const body6 = paragraphs.map((text25) => `<w:p><w:r><w:t xml:space="preserve">${escapeXml2(text25)}</w:t></w:r></w:p>`).join("");
|
|
141730
141745
|
return zip([
|
|
141731
141746
|
["[Content_Types].xml", '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/></Types>'],
|
|
141732
141747
|
["_rels/.rels", '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/></Relationships>'],
|
|
@@ -141744,20 +141759,20 @@ function docxParagraphs(bytes2) {
|
|
|
141744
141759
|
function buildPdf(lines, title2) {
|
|
141745
141760
|
const pages = [];
|
|
141746
141761
|
for (let i = 0; i < Math.max(lines.length, 1); i += 50) pages.push(lines.slice(i, i + 50));
|
|
141747
|
-
const
|
|
141762
|
+
const text25 = (value4) => value4.replace(/[^\x20-\x7e]/g, "?").replace(/([\\()])/g, "\\$1");
|
|
141748
141763
|
const objects = [];
|
|
141749
141764
|
objects.push("<< /Type /Catalog /Pages 2 0 R >>");
|
|
141750
141765
|
objects.push(`<< /Type /Pages /Kids [${pages.map((_, i) => `${4 + i * 2} 0 R`).join(" ")}] /Count ${pages.length} >>`);
|
|
141751
141766
|
objects.push("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>");
|
|
141752
141767
|
pages.forEach((page18, i) => {
|
|
141753
|
-
const stream = `BT /F1 11 Tf 72 750 Td 14 TL ${page18.map((line2) => `(${
|
|
141768
|
+
const stream = `BT /F1 11 Tf 72 750 Td 14 TL ${page18.map((line2) => `(${text25(line2)}) '`).join(" ")} ET`;
|
|
141754
141769
|
objects.push(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 3 0 R >> >> /Contents ${5 + i * 2} 0 R >>`);
|
|
141755
141770
|
objects.push(`<< /Length ${Buffer.byteLength(stream)} >>
|
|
141756
141771
|
stream
|
|
141757
141772
|
${stream}
|
|
141758
141773
|
endstream`);
|
|
141759
141774
|
});
|
|
141760
|
-
objects.push(`<< /Title (${
|
|
141775
|
+
objects.push(`<< /Title (${text25(title2)}) /Producer (Ancha) >>`);
|
|
141761
141776
|
let out = "%PDF-1.4\n";
|
|
141762
141777
|
const offsets = objects.map((body6, i) => {
|
|
141763
141778
|
const at3 = Buffer.byteLength(out);
|
|
@@ -142429,9 +142444,9 @@ function search7(call2, query10) {
|
|
|
142429
142444
|
};
|
|
142430
142445
|
visit4(scope2);
|
|
142431
142446
|
const matches9 = all9.filter((item2) => {
|
|
142432
|
-
const
|
|
142447
|
+
const text25 = `${item2.name}
|
|
142433
142448
|
${textOf2(item2) ?? ""}`.toLowerCase();
|
|
142434
|
-
return tokens3.every((token4) =>
|
|
142449
|
+
return tokens3.every((token4) => text25.includes(token4));
|
|
142435
142450
|
});
|
|
142436
142451
|
const response5 = collection(call2, "Collection(driveItem)", matches9);
|
|
142437
142452
|
return response5;
|
|
@@ -143434,12 +143449,12 @@ function childrenOf3(ctx, parent2, kind) {
|
|
|
143434
143449
|
return ctx.store.db.prepare("SELECT json FROM shopify_objects WHERE parent = ? AND kind = ? ORDER BY num").all(parent2, kind).map((r2) => JSON.parse(r2.json));
|
|
143435
143450
|
}
|
|
143436
143451
|
function cents4(value4) {
|
|
143437
|
-
const
|
|
143438
|
-
if (typeof
|
|
143439
|
-
const [whole2, frac = ""] =
|
|
143452
|
+
const text25 = typeof value4 === "number" ? String(value4) : value4;
|
|
143453
|
+
if (typeof text25 !== "string" || !/^-?\d{1,12}(\.\d+)?$/.test(text25.trim())) return null;
|
|
143454
|
+
const [whole2, frac = ""] = text25.trim().replace("-", "").split(".");
|
|
143440
143455
|
if (/[1-9]/.test(frac.slice(2))) return null;
|
|
143441
143456
|
const n2 = Number(whole2) * 100 + Number(frac.slice(0, 2).padEnd(2, "0"));
|
|
143442
|
-
return
|
|
143457
|
+
return text25.trim().startsWith("-") ? -n2 : n2;
|
|
143443
143458
|
}
|
|
143444
143459
|
function decimal2(c) {
|
|
143445
143460
|
const sign3 = c < 0 ? "-" : "", abs = Math.abs(c), frac = String(abs % 100).padStart(2, "0").replace(/0$/, "");
|
|
@@ -143668,7 +143683,7 @@ function compare7(op, a, b) {
|
|
|
143668
143683
|
return a >= b;
|
|
143669
143684
|
}
|
|
143670
143685
|
}
|
|
143671
|
-
var wordsOf = (
|
|
143686
|
+
var wordsOf = (text25) => text25.toLowerCase().split(/[^\p{L}\p{N}*]+/u).filter(Boolean);
|
|
143672
143687
|
function textMatch(values2, wanted, contains3, words6 = false) {
|
|
143673
143688
|
const options3 = wanted.split(",").map((v) => v.trim().toLowerCase()).filter(Boolean);
|
|
143674
143689
|
return values2.some((raw3) => {
|
|
@@ -144047,8 +144062,8 @@ function productShape(req, p2) {
|
|
|
144047
144062
|
descriptionHtml: p2.description_html,
|
|
144048
144063
|
bodyHtml: p2.description_html,
|
|
144049
144064
|
description: ({ truncateAt }) => {
|
|
144050
|
-
const
|
|
144051
|
-
return typeof truncateAt === "number" &&
|
|
144065
|
+
const text25 = stripHtml(p2.description_html);
|
|
144066
|
+
return typeof truncateAt === "number" && text25.length > truncateAt ? `${text25.slice(0, Math.max(0, truncateAt - 3)).trimEnd()}...` : text25;
|
|
144052
144067
|
},
|
|
144053
144068
|
vendor: p2.vendor,
|
|
144054
144069
|
productType: p2.product_type,
|
|
@@ -144872,7 +144887,7 @@ function mutationRoot(req) {
|
|
|
144872
144887
|
customerCreate: ({ input: input5 }) => customerWrite(req, input5, true)
|
|
144873
144888
|
};
|
|
144874
144889
|
}
|
|
144875
|
-
var slug8 = (
|
|
144890
|
+
var slug8 = (text25) => text25.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 255) || "product";
|
|
144876
144891
|
function retag(req, id14, tags4, apply2) {
|
|
144877
144892
|
const target5 = checkId(id14), kind = kindOf(target5);
|
|
144878
144893
|
if (!["Order", "Customer", "Product"].includes(kind)) gap5(`tags on ${kind}`);
|
|
@@ -145213,17 +145228,17 @@ async function handleGraphql3(c) {
|
|
|
145213
145228
|
const version5 = asked !== "unstable" && asked < "2026-01" ? "2026-01" : asked;
|
|
145214
145229
|
if (!API_VERSIONS.includes(version5)) return respond4(404, { errors: "Not Found" });
|
|
145215
145230
|
const headers = { "x-shopify-api-version": version5 };
|
|
145216
|
-
const
|
|
145231
|
+
const text25 = await c.req.text();
|
|
145217
145232
|
try {
|
|
145218
145233
|
const token4 = c.req.header("x-shopify-access-token");
|
|
145219
145234
|
const known2 = !!token4 && withRead(ctx, () => !!ctx.store.db.prepare("SELECT 1 FROM shopify_tokens WHERE token = ?").get(token4));
|
|
145220
145235
|
if (!known2) return respond4(401, { errors: "[API] Invalid API key or access token (unrecognized login or wrong password)" }, headers);
|
|
145221
145236
|
let body6;
|
|
145222
|
-
if ((c.req.header("content-type") ?? "").includes("application/graphql")) body6 = { query:
|
|
145237
|
+
if ((c.req.header("content-type") ?? "").includes("application/graphql")) body6 = { query: text25 };
|
|
145223
145238
|
else {
|
|
145224
145239
|
let parsed3;
|
|
145225
145240
|
try {
|
|
145226
|
-
parsed3 = JSON.parse(
|
|
145241
|
+
parsed3 = JSON.parse(text25);
|
|
145227
145242
|
} catch {
|
|
145228
145243
|
return respond4(400, { errors: { query: "Required parameter missing or invalid" } }, headers);
|
|
145229
145244
|
}
|
|
@@ -145909,11 +145924,11 @@ function renderTemplate(html2, variables2) {
|
|
|
145909
145924
|
return truthy2(value4(path4)) === (kind === "if") ? yes : no;
|
|
145910
145925
|
});
|
|
145911
145926
|
} while (out !== previous);
|
|
145912
|
-
const
|
|
145927
|
+
const text25 = (path4) => {
|
|
145913
145928
|
const item2 = value4(path4);
|
|
145914
145929
|
return item2 === void 0 || item2 === null ? "" : typeof item2 === "object" ? JSON.stringify(item2) : String(item2);
|
|
145915
145930
|
};
|
|
145916
|
-
return out.replace(/\{\{\{\s*([\w.]+)\s*\}\}\}/g, (_, path4) =>
|
|
145931
|
+
return out.replace(/\{\{\{\s*([\w.]+)\s*\}\}\}/g, (_, path4) => text25(path4)).replace(/\{\{\s*([\w.]+)\s*\}\}/g, (_, path4) => text25(path4).replace(/[&<>"']/g, (char) => ESCAPES[char]));
|
|
145917
145932
|
}
|
|
145918
145933
|
function mergeKeys(html2) {
|
|
145919
145934
|
const keys6 = /* @__PURE__ */ new Set();
|
|
@@ -145921,8 +145936,8 @@ function mergeKeys(html2) {
|
|
|
145921
145936
|
return [...keys6];
|
|
145922
145937
|
}
|
|
145923
145938
|
function htmlLines(html2) {
|
|
145924
|
-
const
|
|
145925
|
-
return
|
|
145939
|
+
const text25 = html2.replace(/<(style|script|head)\b[^>]*>[\s\S]*?<\/\1>/gi, "").replace(/<br\s*\/?>/gi, "\n").replace(/<\/(p|div|h[1-6]|li|tr|table|section|header|footer|address)>/gi, "\n").replace(/<[^>]+>/g, "").replace(/ /g, " ").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'|'/g, "'").replace(/&#(\d+);/g, (_, code2) => String.fromCodePoint(Number(code2))).replace(/&/g, "&");
|
|
145940
|
+
return text25.split("\n").map((line2) => line2.replace(/\s+/g, " ").trim()).filter(Boolean);
|
|
145926
145941
|
}
|
|
145927
145942
|
var STEPS = { usps_first_class: [24, 36, 72, 96], usps_standard: [24, 72, 168, 216] };
|
|
145928
145943
|
var FACILITIES = ["60126", "45246", "75261", "30320"];
|
|
@@ -146329,7 +146344,7 @@ function allowed(body6, known2, gaps2 = [], prefix2 = "") {
|
|
|
146329
146344
|
if (!known2.includes(field5)) throw invalid21(`${prefix2}${field5} is not allowed`);
|
|
146330
146345
|
}
|
|
146331
146346
|
}
|
|
146332
|
-
function
|
|
146347
|
+
function text21(body6, field5, max, options3 = {}) {
|
|
146333
146348
|
const value4 = body6[field5], name5 = `${options3.prefix ?? ""}${field5}`;
|
|
146334
146349
|
if (value4 === void 0 || value4 === null || value4 === "") {
|
|
146335
146350
|
if (options3.required) throw invalid21(`${name5} is required`);
|
|
@@ -146390,19 +146405,19 @@ function mergeVariablesOf(value4) {
|
|
|
146390
146405
|
var ADDRESS_FIELDS = ["description", "name", "company", "phone", "email", "address_line1", "address_line2", "address_city", "address_state", "address_zip", "address_country", "metadata"];
|
|
146391
146406
|
function addressInput(body6, prefix2 = "") {
|
|
146392
146407
|
allowed(body6, ADDRESS_FIELDS, [], prefix2);
|
|
146393
|
-
const at3 = { prefix: prefix2 }, country = (
|
|
146408
|
+
const at3 = { prefix: prefix2 }, country = (text21(body6, "address_country", 60, at3) ?? "US").toUpperCase();
|
|
146394
146409
|
if (!countryName2(country)) throw invalid21(`${prefix2}address_country must be a valid ISO 3166 country code`);
|
|
146395
146410
|
const input5 = {
|
|
146396
|
-
description:
|
|
146397
|
-
name:
|
|
146398
|
-
company:
|
|
146399
|
-
phone:
|
|
146400
|
-
email:
|
|
146401
|
-
line1:
|
|
146402
|
-
line2:
|
|
146403
|
-
city:
|
|
146404
|
-
state:
|
|
146405
|
-
zip:
|
|
146411
|
+
description: text21(body6, "description", 255, at3),
|
|
146412
|
+
name: text21(body6, "name", 40, at3),
|
|
146413
|
+
company: text21(body6, "company", 40, at3),
|
|
146414
|
+
phone: text21(body6, "phone", 40, at3),
|
|
146415
|
+
email: text21(body6, "email", 100, at3),
|
|
146416
|
+
line1: text21(body6, "address_line1", 64, { prefix: prefix2, required: true }),
|
|
146417
|
+
line2: text21(body6, "address_line2", 64, at3),
|
|
146418
|
+
city: text21(body6, "address_city", 200, at3),
|
|
146419
|
+
state: text21(body6, "address_state", 200, at3),
|
|
146420
|
+
zip: text21(body6, "address_zip", 40, at3),
|
|
146406
146421
|
country,
|
|
146407
146422
|
metadata: metadataOf(body6.metadata, prefix2)
|
|
146408
146423
|
};
|
|
@@ -146567,12 +146582,12 @@ function listBanks(call2) {
|
|
|
146567
146582
|
function createBank(call2) {
|
|
146568
146583
|
const { ctx, body: body6 } = call2;
|
|
146569
146584
|
allowed(body6, ["description", "routing_number", "account_number", "account_type", "signatory", "metadata"]);
|
|
146570
|
-
const routing =
|
|
146585
|
+
const routing = text21(body6, "routing_number", 9, { required: true }), account9 = text21(body6, "account_number", 17, { required: true });
|
|
146571
146586
|
if (!abaChecksum(routing)) throw invalid21("routing_number must be a valid ABA routing number");
|
|
146572
146587
|
if (!/^\d+$/.test(account9)) throw invalid21("account_number must only contain digits");
|
|
146573
146588
|
const type = choice(body6, "account_type", ["company", "individual"]);
|
|
146574
146589
|
if (!type) throw invalid21("account_type is required");
|
|
146575
|
-
const signatory =
|
|
146590
|
+
const signatory = text21(body6, "signatory", 30, { required: true }), description2 = text21(body6, "description", 255), metadata7 = metadataOf(body6.metadata);
|
|
146576
146591
|
const id14 = newId5(ctx, "bank"), now11 = ctx.clock.nowMs(), deposits = [ctx.ids.int(1, 99), ctx.ids.int(1, 99)];
|
|
146577
146592
|
const known2 = ctx.store.db.prepare("SELECT bank_name FROM lob_bank_accounts WHERE routing_number = ? AND bank_name IS NOT NULL ORDER BY rowid LIMIT 1").get(routing);
|
|
146578
146593
|
ctx.store.db.prepare(`INSERT INTO lob_bank_accounts (id, description, routing_number, account_number, account_type, signatory, bank_name, verified, deposits, metadata, created_ms, modified_ms, next_check)
|
|
@@ -146634,7 +146649,7 @@ function listTemplates(call2) {
|
|
|
146634
146649
|
function createTemplate(call2) {
|
|
146635
146650
|
const { ctx, body: body6 } = call2;
|
|
146636
146651
|
allowed(body6, ["description", "html", "engine", "metadata"], ["required_vars"]);
|
|
146637
|
-
const html2 =
|
|
146652
|
+
const html2 = text21(body6, "html", 1e5, { required: true }), description2 = text21(body6, "description", 255), engine = choice(body6, "engine", ["legacy", "handlebars"]) ?? "legacy";
|
|
146638
146653
|
const metadata7 = metadataOf(body6.metadata), id14 = newId5(ctx, "tmpl"), version5 = newId5(ctx, "vrsn"), now11 = ctx.clock.nowMs();
|
|
146639
146654
|
ctx.store.db.prepare("INSERT INTO lob_templates (id, description, metadata, published, created_ms, modified_ms) VALUES (?, ?, ?, ?, ?, ?)").run(id14, description2, JSON.stringify(metadata7), version5, now11, now11);
|
|
146640
146655
|
ctx.store.db.prepare("INSERT INTO lob_versions (id, template_id, description, html, engine, created_ms) VALUES (?, ?, ?, ?, ?, ?)").run(version5, id14, description2, html2, engine, now11);
|
|
@@ -146644,7 +146659,7 @@ var getTemplateRoute = (call2) => json19(templateJson(call2.ctx, liveTemplate(ca
|
|
|
146644
146659
|
function updateTemplate(call2) {
|
|
146645
146660
|
const { ctx, body: body6 } = call2, row2 = liveTemplate(ctx, call2.ids[0]);
|
|
146646
146661
|
allowed(body6, ["description", "published_version"]);
|
|
146647
|
-
const description2 = body6.description === void 0 ? row2.description :
|
|
146662
|
+
const description2 = body6.description === void 0 ? row2.description : text21(body6, "description", 255), published = text21(body6, "published_version", 40) ?? row2.published;
|
|
146648
146663
|
if (getVersion(ctx, published)?.template_id !== row2.id) throw notFound12("template version");
|
|
146649
146664
|
ctx.store.db.prepare("UPDATE lob_templates SET description = ?, published = ?, modified_ms = ? WHERE id = ?").run(description2, published, ctx.clock.nowMs(), row2.id);
|
|
146650
146665
|
return json19(templateJson(ctx, getTemplate(ctx, row2.id)));
|
|
@@ -146795,7 +146810,7 @@ function createLetter(call2) {
|
|
|
146795
146810
|
const perforated = integer8(body6.perforated_page, "perforated_page", 1, 1e3);
|
|
146796
146811
|
if (perforated !== null && !returnEnvelope) throw invalid21("perforated_page requires return_envelope", "invalid_perforation_return_envelope");
|
|
146797
146812
|
const doubleSided = flag3(body6, "double_sided") ?? true, placement = choice(body6, "address_placement", LOB_ADDRESS_PLACEMENTS) ?? "top_first_page";
|
|
146798
|
-
const times = sendTimes(call2), description2 =
|
|
146813
|
+
const times = sendTimes(call2), description2 = text21(body6, "description", 255), metadata7 = metadataOf(body6.metadata), variables2 = mergeVariablesOf(body6.merge_variables);
|
|
146799
146814
|
const to = addressFor(call2, "to", true), from = addressFor(call2, "from", true);
|
|
146800
146815
|
usOnly(from, "from");
|
|
146801
146816
|
if (mailType === "usps_standard" && to.country !== "US") throw invalid21("usps_standard is only available for US addresses");
|
|
@@ -146826,7 +146841,7 @@ function createPostcard(call2) {
|
|
|
146826
146841
|
filesAllowed(call2, ["front", "back"]);
|
|
146827
146842
|
const useType = useTypeOf(body6), size2 = choice(body6, "size", LOB_POSTCARD_SIZES) ?? "4x6", mailType = choice(body6, "mail_type", LOB_MAIL_TYPES) ?? "usps_first_class";
|
|
146828
146843
|
if (mailType === "usps_standard" && size2 === "4x6") throw invalid21("usps_standard cannot be used with 4x6 postcards");
|
|
146829
|
-
const times = sendTimes(call2), description2 =
|
|
146844
|
+
const times = sendTimes(call2), description2 = text21(body6, "description", 255), metadata7 = metadataOf(body6.metadata), variables2 = mergeVariablesOf(body6.merge_variables);
|
|
146830
146845
|
const to = addressFor(call2, "to", true), from = addressFor(call2, "from", false);
|
|
146831
146846
|
usOnly(from, "from");
|
|
146832
146847
|
if (mailType === "usps_standard" && to.country !== "US") throw invalid21("usps_standard is only available for US addresses");
|
|
@@ -146853,15 +146868,15 @@ function createCheck(call2) {
|
|
|
146853
146868
|
allowed(body6, [...MAIL_FIELDS, "bank_account", "amount", "memo", "message", "check_number", "logo", "check_bottom", "attachment"], ["billing_group_id"]);
|
|
146854
146869
|
filesAllowed(call2, ["check_bottom", "attachment"]);
|
|
146855
146870
|
const useType = useTypeOf(body6), mailType = choice(body6, "mail_type", ["usps_first_class"]) ?? "usps_first_class";
|
|
146856
|
-
const bankId =
|
|
146871
|
+
const bankId = text21(body6, "bank_account", 40, { required: true });
|
|
146857
146872
|
const raw3 = typeof body6.amount === "string" && /^\d+(\.\d+)?$/.test(body6.amount) ? Number(body6.amount) : body6.amount;
|
|
146858
146873
|
if (raw3 === void 0 || raw3 === null || raw3 === "") throw invalid21("amount is required");
|
|
146859
146874
|
if (typeof raw3 !== "number" || !Number.isFinite(raw3) || raw3 <= 0) throw invalid21("amount must be a positive number");
|
|
146860
146875
|
if (raw3 > 999999.99) throw invalid21("amount must be less than or equal to 999999.99");
|
|
146861
146876
|
if (Math.abs(raw3 * 100 - Math.round(raw3 * 100)) > 1e-6) throw invalid21("amount must have at most 2 decimal places");
|
|
146862
|
-
const memo3 =
|
|
146877
|
+
const memo3 = text21(body6, "memo", 40), message7 = text21(body6, "message", 400), logo = text21(body6, "logo", 2048), requested2 = integer8(body6.check_number, "check_number", 1, 99999999);
|
|
146863
146878
|
if (logo !== null && !/^https?:\/\//i.test(logo)) throw invalid21("logo must be a URL");
|
|
146864
|
-
const times = sendTimes(call2), description2 =
|
|
146879
|
+
const times = sendTimes(call2), description2 = text21(body6, "description", 255), metadata7 = metadataOf(body6.metadata), variables2 = mergeVariablesOf(body6.merge_variables);
|
|
146865
146880
|
const bank = liveBank(ctx, bankId);
|
|
146866
146881
|
if (bank.verified !== 1) throw new LobError(403, "Bank account must be verified before it can be used to create checks", "unverified_bank_account");
|
|
146867
146882
|
if (requested2 !== null && checkNumberUsed(ctx, bank.id, requested2)) throw invalid21(`check_number ${requested2} has already been used for this bank account`, "invalid_check_number");
|
|
@@ -146913,14 +146928,14 @@ var listMail = (kind) => (call2) => {
|
|
|
146913
146928
|
var VERIFY_FIELDS = ["address", "recipient", "primary_line", "secondary_line", "urbanization", "city", "state", "zip_code"];
|
|
146914
146929
|
function verificationInput(body6) {
|
|
146915
146930
|
allowed(body6, VERIFY_FIELDS);
|
|
146916
|
-
const recipient2 =
|
|
146931
|
+
const recipient2 = text21(body6, "recipient", 500), urbanization = text21(body6, "urbanization", 500) ?? void 0, single2 = text21(body6, "address", 500);
|
|
146917
146932
|
if (single2 !== null) return { recipient: recipient2, urbanization, ...splitAddressLine(single2) };
|
|
146918
|
-
const line1 =
|
|
146933
|
+
const line1 = text21(body6, "primary_line", 500);
|
|
146919
146934
|
if (line1 === null) throw invalid21("primary_line is required or address is required");
|
|
146920
|
-
const city =
|
|
146935
|
+
const city = text21(body6, "city", 200) ?? void 0, state2 = text21(body6, "state", 100) ?? void 0, zip2 = text21(body6, "zip_code", 10) ?? void 0;
|
|
146921
146936
|
if (zip2 && !/^\d{5}(-?\d{4})?$/.test(zip2)) throw invalid21("zip_code must be in a valid zip or zip+4 format");
|
|
146922
146937
|
if (!zip2 && !(city && state2)) throw invalid21("zip_code is required or both city and state are required");
|
|
146923
|
-
return { recipient: recipient2, urbanization, line1, line2:
|
|
146938
|
+
return { recipient: recipient2, urbanization, line1, line2: text21(body6, "secondary_line", 500) ?? void 0, city, state: state2, zip: zip2 };
|
|
146924
146939
|
}
|
|
146925
146940
|
function caseOf(call2) {
|
|
146926
146941
|
const query10 = {};
|
|
@@ -147027,15 +147042,15 @@ async function readBody(c) {
|
|
|
147027
147042
|
}
|
|
147028
147043
|
return { body: body6, files: files2 };
|
|
147029
147044
|
}
|
|
147030
|
-
const
|
|
147031
|
-
if (!
|
|
147045
|
+
const text25 = await c.req.text();
|
|
147046
|
+
if (!text25.trim()) return { body: body6, files: files2 };
|
|
147032
147047
|
if (/^application\/x-www-form-urlencoded/i.test(type)) {
|
|
147033
|
-
for (const [name5, value4] of new URLSearchParams(
|
|
147048
|
+
for (const [name5, value4] of new URLSearchParams(text25)) setPath(body6, name5, value4);
|
|
147034
147049
|
return { body: body6, files: files2 };
|
|
147035
147050
|
}
|
|
147036
147051
|
let parsed3;
|
|
147037
147052
|
try {
|
|
147038
|
-
parsed3 = JSON.parse(
|
|
147053
|
+
parsed3 = JSON.parse(text25);
|
|
147039
147054
|
} catch {
|
|
147040
147055
|
throw new LobError(400, "The request body is not valid JSON", "bad_request");
|
|
147041
147056
|
}
|
|
@@ -147171,9 +147186,9 @@ function unsupported23(what) {
|
|
|
147171
147186
|
throw new PayPalError(501, "NOT_IMPLEMENTED", `ancha: not implemented: ${what}`, [], true);
|
|
147172
147187
|
}
|
|
147173
147188
|
var json20 = (status4, body6, headers = {}) => body6 === null ? new Response(null, { status: status4, headers }) : new Response(JSON.stringify(body6), { status: status4, headers: { "content-type": "application/json", ...headers } });
|
|
147174
|
-
var debugId = (c,
|
|
147175
|
-
${
|
|
147176
|
-
function errorResponse12(c,
|
|
147189
|
+
var debugId = (c, text25) => createHash43("sha256").update(`${c.req.method} ${c.req.url}
|
|
147190
|
+
${text25}`).digest("hex").slice(0, 13);
|
|
147191
|
+
function errorResponse12(c, text25, e) {
|
|
147177
147192
|
const anchor2 = e.details[0]?.issue ?? e.code;
|
|
147178
147193
|
return json20(
|
|
147179
147194
|
e.status,
|
|
@@ -147181,7 +147196,7 @@ function errorResponse12(c, text24, e) {
|
|
|
147181
147196
|
name: e.code,
|
|
147182
147197
|
...e.details.length && { details: e.details },
|
|
147183
147198
|
message: e.message,
|
|
147184
|
-
debug_id: debugId(c,
|
|
147199
|
+
debug_id: debugId(c, text25),
|
|
147185
147200
|
links: [{ href: `https://developer.paypal.com/api/rest/reference/orders/v2/errors/#${String(anchor2).toLowerCase()}`, rel: "information_link", method: "GET" }]
|
|
147186
147201
|
},
|
|
147187
147202
|
e.gap ? { [GAP_HEADER]: "1" } : {}
|
|
@@ -147203,16 +147218,16 @@ function authorize(c, ctx) {
|
|
|
147203
147218
|
function handle19(route12) {
|
|
147204
147219
|
return async (c) => {
|
|
147205
147220
|
const ctx = c.env.ctx;
|
|
147206
|
-
const
|
|
147221
|
+
const text25 = route12.method === "GET" ? "" : await c.req.text();
|
|
147207
147222
|
try {
|
|
147208
147223
|
const denied = withRead(ctx, () => authorize(c, ctx));
|
|
147209
147224
|
if (denied) return denied;
|
|
147210
147225
|
if (c.req.header("paypal-mock-response")) unsupported23("PayPal-Mock-Response negative testing");
|
|
147211
147226
|
let body6 = {};
|
|
147212
|
-
if (
|
|
147227
|
+
if (text25.trim()) {
|
|
147213
147228
|
let parsed3;
|
|
147214
147229
|
try {
|
|
147215
|
-
parsed3 = JSON.parse(
|
|
147230
|
+
parsed3 = JSON.parse(text25);
|
|
147216
147231
|
} catch {
|
|
147217
147232
|
invalid22({ issue: "MALFORMED_REQUEST_JSON", description: "The request JSON is not well formed." });
|
|
147218
147233
|
}
|
|
@@ -147238,7 +147253,7 @@ function handle19(route12) {
|
|
|
147238
147253
|
} catch (error64) {
|
|
147239
147254
|
if (ctx.signal?.aborted) return new Response(null, { status: 409 });
|
|
147240
147255
|
if (!(error64 instanceof PayPalError)) throw error64;
|
|
147241
|
-
return errorResponse12(c,
|
|
147256
|
+
return errorResponse12(c, text25, error64);
|
|
147242
147257
|
}
|
|
147243
147258
|
};
|
|
147244
147259
|
}
|
|
@@ -147254,7 +147269,7 @@ var object14 = (v, field5) => {
|
|
|
147254
147269
|
function keys5(o, allowed2, field5) {
|
|
147255
147270
|
for (const key4 of Object.keys(o)) if (!allowed2.includes(key4)) unsupported23(`${field5}/${key4}`);
|
|
147256
147271
|
}
|
|
147257
|
-
function
|
|
147272
|
+
function text22(v, field5, max) {
|
|
147258
147273
|
if (typeof v !== "string" || !v.trim() || v.length > max) invalid22({ field: field5, issue: "INVALID_PARAMETER_VALUE", description: `Expected text of 1 to ${max} characters.`, location: "body" });
|
|
147259
147274
|
return v;
|
|
147260
147275
|
}
|
|
@@ -147282,7 +147297,7 @@ function invoiceFrom(ctx, body6) {
|
|
|
147282
147297
|
keys5(detail3, ["currency_code", "invoice_number", "reference", "note", "terms_and_conditions", "memo"], "/detail");
|
|
147283
147298
|
const currency = detail3.currency_code;
|
|
147284
147299
|
if (!["USD", "EUR", "GBP", "CAD", "AUD"].includes(currency)) unsupported23(`invoice currency ${String(currency)}`);
|
|
147285
|
-
for (const key4 of ["invoice_number", "reference", "note", "terms_and_conditions", "memo"]) if (detail3[key4] !== void 0)
|
|
147300
|
+
for (const key4 of ["invoice_number", "reference", "note", "terms_and_conditions", "memo"]) if (detail3[key4] !== void 0) text22(detail3[key4], `/detail/${key4}`, key4 === "invoice_number" ? 25 : 4e3);
|
|
147286
147301
|
if (detail3.invoice_number && allOf2(ctx, "invoice").some((i) => i.detail.invoice_number === detail3.invoice_number)) refused("DUPLICATE_INVOICE_NUMBER", "Invoice number must be unique.", "/detail/invoice_number");
|
|
147287
147302
|
if (b.configuration !== void 0) {
|
|
147288
147303
|
const c = object14(b.configuration, "/configuration");
|
|
@@ -147297,14 +147312,14 @@ function invoiceFrom(ctx, body6) {
|
|
|
147297
147312
|
if (c.name !== void 0) {
|
|
147298
147313
|
const n2 = object14(c.name, `${field5}/name`);
|
|
147299
147314
|
keys5(n2, ["given_name", "surname", "full_name"], `${field5}/name`);
|
|
147300
|
-
for (const [k, v3] of Object.entries(n2))
|
|
147315
|
+
for (const [k, v3] of Object.entries(n2)) text22(v3, `${field5}/name/${k}`, 300);
|
|
147301
147316
|
}
|
|
147302
147317
|
if (c.address !== void 0) {
|
|
147303
147318
|
const a = object14(c.address, `${field5}/address`);
|
|
147304
147319
|
keys5(a, ["address_line_1", "address_line_2", "admin_area_1", "admin_area_2", "postal_code", "country_code"], `${field5}/address`);
|
|
147305
|
-
for (const [k, v3] of Object.entries(a))
|
|
147320
|
+
for (const [k, v3] of Object.entries(a)) text22(v3, `${field5}/address/${k}`, 300);
|
|
147306
147321
|
}
|
|
147307
|
-
if (c.business_name !== void 0)
|
|
147322
|
+
if (c.business_name !== void 0) text22(c.business_name, `${field5}/business_name`, 300);
|
|
147308
147323
|
return c;
|
|
147309
147324
|
};
|
|
147310
147325
|
const invoicer = b.invoicer === void 0 ? void 0 : contact(b.invoicer, "/invoicer");
|
|
@@ -147319,7 +147334,7 @@ function invoiceFrom(ctx, body6) {
|
|
|
147319
147334
|
const items = b.items.map((raw3, index) => {
|
|
147320
147335
|
const path4 = `/items/${index}`, i = object14(raw3, path4);
|
|
147321
147336
|
keys5(i, ["name", "description", "quantity", "unit_amount", "tax", "discount", "unit_of_measure"], path4);
|
|
147322
|
-
const name5 =
|
|
147337
|
+
const name5 = text22(i.name, `${path4}/name`, 200), quantity = decimal3(i.quantity, `${path4}/quantity`);
|
|
147323
147338
|
if (quantity <= 0 || quantity > 1e6) invalid22({ field: `${path4}/quantity`, issue: "INVALID_PARAMETER_VALUE", description: "Quantity must be positive and at most 10000." });
|
|
147324
147339
|
const unit = money10(i.unit_amount, currency, `${path4}/unit_amount`), line2 = rounded(unit, quantity, 100);
|
|
147325
147340
|
let discount = 0, tax = 0;
|
|
@@ -147337,12 +147352,12 @@ function invoiceFrom(ctx, body6) {
|
|
|
147337
147352
|
if (i.tax !== void 0) {
|
|
147338
147353
|
const t = object14(i.tax, `${path4}/tax`);
|
|
147339
147354
|
keys5(t, ["name", "percent"], `${path4}/tax`);
|
|
147340
|
-
|
|
147355
|
+
text22(t.name, `${path4}/tax/name`, 100);
|
|
147341
147356
|
const percent = decimal3(t.percent, `${path4}/tax/percent`);
|
|
147342
147357
|
if (percent > 1e4) refused("INVALID_TAX_RATE", "Tax percent must be at most 100.");
|
|
147343
147358
|
tax = rounded(line2 - discount, percent, 1e4);
|
|
147344
147359
|
}
|
|
147345
|
-
if (i.description !== void 0)
|
|
147360
|
+
if (i.description !== void 0) text22(i.description, `${path4}/description`, 1e3);
|
|
147346
147361
|
if (i.unit_of_measure !== void 0 && !["QUANTITY", "HOURS", "AMOUNT"].includes(i.unit_of_measure)) invalid22({ field: `${path4}/unit_of_measure`, issue: "INVALID_PARAMETER_VALUE", description: "Invalid unit of measure." });
|
|
147347
147362
|
return { ...i, name: name5, cents: unit, line_cents: line2, discount_cents: discount, tax_cents: tax };
|
|
147348
147363
|
});
|
|
@@ -147576,14 +147591,14 @@ function money11(input5, field5, currency) {
|
|
|
147576
147591
|
return { currency: m.currency_code, cents: c };
|
|
147577
147592
|
}
|
|
147578
147593
|
function validateItemDetails(i, at3) {
|
|
147579
|
-
const
|
|
147594
|
+
const text25 = (input5, field5, min, max) => {
|
|
147580
147595
|
if (typeof input5 !== "string") invalid22({ field: field5, location: "body", issue: "INVALID_PARAMETER_SYNTAX", description: "The value of a field does not conform to the expected format." });
|
|
147581
147596
|
if (input5.length < min || input5.length > max) invalid22({ field: field5, location: "body", issue: "INVALID_STRING_LENGTH", description: "The length of a field is either too short or too long." });
|
|
147582
147597
|
return input5;
|
|
147583
147598
|
};
|
|
147584
|
-
if (i.description !== void 0)
|
|
147599
|
+
if (i.description !== void 0) text25(i.description, `${at3}/description`, 0, 2048);
|
|
147585
147600
|
for (const key4 of ["url", "image_url"]) if (i[key4] !== void 0) {
|
|
147586
|
-
const url4 =
|
|
147601
|
+
const url4 = text25(i[key4], `${at3}/${key4}`, 1, 2048);
|
|
147587
147602
|
try {
|
|
147588
147603
|
new URL(url4);
|
|
147589
147604
|
} catch {
|
|
@@ -147594,7 +147609,7 @@ function validateItemDetails(i, at3) {
|
|
|
147594
147609
|
if (!i.upc || typeof i.upc !== "object" || Array.isArray(i.upc)) invalid22({ field: `${at3}/upc`, location: "body", issue: "INVALID_PARAMETER_SYNTAX", description: "The value of a field does not conform to the expected format." });
|
|
147595
147610
|
for (const key4 of ["type", "code"]) if (i.upc[key4] === void 0) invalid22({ field: `${at3}/upc/${key4}`, location: "body", issue: "MISSING_REQUIRED_PARAMETER", description: "A required field / parameter is missing." });
|
|
147596
147611
|
if (!["UPC-A", "UPC-B", "UPC-C", "UPC-D", "UPC-E", "UPC-2", "UPC-5"].includes(i.upc.type)) invalid22({ field: `${at3}/upc/type`, location: "body", issue: "INVALID_PARAMETER_VALUE", description: "The value of a field is invalid." });
|
|
147597
|
-
if (!/^\d+$/.test(
|
|
147612
|
+
if (!/^\d+$/.test(text25(i.upc.code, `${at3}/upc/code`, 6, 17))) invalid22({ field: `${at3}/upc/code`, location: "body", issue: "INVALID_PARAMETER_SYNTAX", description: "The value of a field does not conform to the expected format." });
|
|
147598
147613
|
}
|
|
147599
147614
|
}
|
|
147600
147615
|
function unitFrom(input5, index, count4) {
|
|
@@ -148255,7 +148270,7 @@ var billingRoutes = [
|
|
|
148255
148270
|
];
|
|
148256
148271
|
|
|
148257
148272
|
// packages/server/src/twins/record-checks.ts
|
|
148258
|
-
var containsText = (
|
|
148273
|
+
var containsText = (text25, want) => want === void 0 || (Array.isArray(want) ? want : [want]).every((s2) => text25.toLowerCase().includes(s2.toLowerCase()));
|
|
148259
148274
|
var localRef = (value4) => value4.slice(1).replace(/^[^.]+\./, "");
|
|
148260
148275
|
var atStart = (created4, args, start2) => !args.after_start || created4 >= Date.parse(start2);
|
|
148261
148276
|
function counted2(kind, args, matches9, candidates) {
|
|
@@ -148824,8 +148839,8 @@ function isAdf(value4) {
|
|
|
148824
148839
|
const doc = value4;
|
|
148825
148840
|
return !!doc && typeof doc === "object" && doc.type === "doc" && doc.version === 1 && Array.isArray(doc.content) && doc.content.every(ok);
|
|
148826
148841
|
}
|
|
148827
|
-
function textToAdf(
|
|
148828
|
-
return { type: "doc", version: 1, content:
|
|
148842
|
+
function textToAdf(text25) {
|
|
148843
|
+
return { type: "doc", version: 1, content: text25.split(/\n\s*\n/).filter((p2) => p2.trim()).map((p2) => ({ type: "paragraph", content: p2.split("\n").flatMap((line2, i) => [...i ? [{ type: "hardBreak" }] : [], ...line2 ? [{ type: "text", text: line2 }] : []]) })) };
|
|
148829
148844
|
}
|
|
148830
148845
|
function adfToText(doc) {
|
|
148831
148846
|
if (!doc) return "";
|
|
@@ -148897,14 +148912,14 @@ function tokenize7(jql) {
|
|
|
148897
148912
|
continue;
|
|
148898
148913
|
}
|
|
148899
148914
|
if (ch === '"' || ch === "'") {
|
|
148900
|
-
let j = i + 1,
|
|
148915
|
+
let j = i + 1, text25 = "";
|
|
148901
148916
|
while (j < jql.length && jql[j] !== ch) {
|
|
148902
148917
|
if (jql[j] === "\\" && j + 1 < jql.length) j++;
|
|
148903
|
-
|
|
148918
|
+
text25 += jql[j];
|
|
148904
148919
|
j++;
|
|
148905
148920
|
}
|
|
148906
|
-
if (j >= jql.length) throw new JqlError(`Error in the JQL Query: The quoted string '${
|
|
148907
|
-
out.push({ kind: "string", text:
|
|
148921
|
+
if (j >= jql.length) throw new JqlError(`Error in the JQL Query: The quoted string '${text25}' has not been completed. (line 1, character ${i + 1})`);
|
|
148922
|
+
out.push({ kind: "string", text: text25, pos: i });
|
|
148908
148923
|
i = j + 1;
|
|
148909
148924
|
continue;
|
|
148910
148925
|
}
|
|
@@ -149145,16 +149160,16 @@ var localToUtc = (y, m, d, tz, h = 0, min = 0) => {
|
|
|
149145
149160
|
const guess = Date.UTC(y, m - 1, d, h, min);
|
|
149146
149161
|
return guess - zoned(guess, tz).offset;
|
|
149147
149162
|
};
|
|
149148
|
-
function period(
|
|
149149
|
-
const s2 =
|
|
149163
|
+
function period(text25) {
|
|
149164
|
+
const s2 = text25.trim();
|
|
149150
149165
|
if (!/^[-+]?(\d+\s*[wdhm]\s*)+$/.test(s2)) return null;
|
|
149151
149166
|
const sign3 = s2.startsWith("-") ? -1 : 1, unit = { w: 7 * DAY7, d: DAY7, h: 36e5, m: 6e4 };
|
|
149152
149167
|
return sign3 * [...s2.matchAll(/(\d+)\s*([wdhm])/g)].reduce((n2, x) => n2 + Number(x[1]) * unit[x[2]], 0);
|
|
149153
149168
|
}
|
|
149154
149169
|
function evaluate2(q, w2) {
|
|
149155
|
-
const userOf2 = (
|
|
149156
|
-
const t =
|
|
149157
|
-
if (!u) throw new JqlError(`The value '${
|
|
149170
|
+
const userOf2 = (text25, field5) => {
|
|
149171
|
+
const t = text25.toLowerCase(), u = w2.users.find((x) => x.account_id === text25 || x.email?.toLowerCase() === t || x.name.toLowerCase() === t);
|
|
149172
|
+
if (!u) throw new JqlError(`The value '${text25}' does not exist for the field '${field5}'.`);
|
|
149158
149173
|
return u.account_id;
|
|
149159
149174
|
};
|
|
149160
149175
|
const dateOf2 = (v, field5) => {
|
|
@@ -149188,9 +149203,9 @@ function evaluate2(q, w2) {
|
|
|
149188
149203
|
if (v.kind === "func") throw new JqlError(`Function '${v.name}' is not supported for the field '${field5}'.`);
|
|
149189
149204
|
return null;
|
|
149190
149205
|
};
|
|
149191
|
-
const issueId = (
|
|
149192
|
-
const found2 = w2.issues.find((i) => i.key.toLowerCase() ===
|
|
149193
|
-
if (!found2) throw new JqlError(/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(
|
|
149206
|
+
const issueId = (text25, field5) => {
|
|
149207
|
+
const found2 = w2.issues.find((i) => i.key.toLowerCase() === text25.toLowerCase() || String(i.id) === text25);
|
|
149208
|
+
if (!found2) throw new JqlError(/^[A-Za-z][A-Za-z0-9]*-\d+$/.test(text25) ? `An issue with key '${text25.toUpperCase()}' does not exist for field '${field5}'.` : `The issue key '${text25}' for field '${field5}' is invalid.`);
|
|
149194
149209
|
return found2.id;
|
|
149195
149210
|
};
|
|
149196
149211
|
const one7 = (resolve7) => (v) => {
|
|
@@ -149709,15 +149724,15 @@ function caller(c, ctx) {
|
|
|
149709
149724
|
function handle20(route12, api3) {
|
|
149710
149725
|
return async (c) => {
|
|
149711
149726
|
const ctx = c.env.ctx;
|
|
149712
|
-
const
|
|
149727
|
+
const text25 = route12.method === "GET" || route12.method === "DELETE" ? "" : await c.req.text();
|
|
149713
149728
|
try {
|
|
149714
149729
|
if (/^Bearer\s/i.test(c.req.header("authorization") ?? "")) unsupported24("OAuth 2.0 bearer tokens (use the API token with Basic auth)");
|
|
149715
149730
|
const me4 = withRead(ctx, () => caller(c, ctx));
|
|
149716
149731
|
if (!me4) return json21(401, { errorMessages: ["You are not authenticated. Authentication required to perform this operation."], errors: {} });
|
|
149717
149732
|
let body6 = void 0;
|
|
149718
|
-
if (
|
|
149733
|
+
if (text25.trim()) {
|
|
149719
149734
|
try {
|
|
149720
|
-
body6 = JSON.parse(
|
|
149735
|
+
body6 = JSON.parse(text25);
|
|
149721
149736
|
} catch {
|
|
149722
149737
|
fail2(400, "Unexpected character in the request body: it is not valid JSON.");
|
|
149723
149738
|
}
|
|
@@ -151292,14 +151307,14 @@ function primary2(value4) {
|
|
|
151292
151307
|
if (value4 !== void 0 && value4 !== null && value4 !== "" && Number(value4) !== 0) unsupported25("subaccounts other than 0");
|
|
151293
151308
|
}
|
|
151294
151309
|
function priceOf(value4, field5) {
|
|
151295
|
-
const
|
|
151296
|
-
if (typeof
|
|
151297
|
-
return Math.round(Number(
|
|
151310
|
+
const text25 = typeof value4 === "number" ? String(value4) : value4;
|
|
151311
|
+
if (typeof text25 !== "string" || !/^(0?\.\d{1,4}|0|1(\.0{1,4})?)$/.test(text25)) throw invalid23(`${field5} must be a dollar string such as "0.56"`);
|
|
151312
|
+
return Math.round(Number(text25) * ONE);
|
|
151298
151313
|
}
|
|
151299
151314
|
function countOf(value4, field5) {
|
|
151300
|
-
const
|
|
151301
|
-
if (typeof
|
|
151302
|
-
return Math.round(Number(
|
|
151315
|
+
const text25 = typeof value4 === "number" ? String(value4) : value4;
|
|
151316
|
+
if (typeof text25 !== "string" || !/^\d+(\.\d{1,2})?$/.test(text25)) throw invalid23(`${field5} must be a contract count such as "10" or "2.50"`);
|
|
151317
|
+
return Math.round(Number(text25) * 100);
|
|
151303
151318
|
}
|
|
151304
151319
|
function choice2(value4, field5, values2) {
|
|
151305
151320
|
if (typeof value4 !== "string" || !values2.includes(value4)) throw invalid23(`${field5} must be one of ${values2.join(", ")}`);
|
|
@@ -151948,12 +151963,12 @@ async function handle21(c) {
|
|
|
151948
151963
|
response5.headers.set(GAP_HEADER, "1");
|
|
151949
151964
|
return response5;
|
|
151950
151965
|
}
|
|
151951
|
-
const
|
|
151966
|
+
const text25 = method2 === "GET" ? "" : await c.req.text();
|
|
151952
151967
|
let body6 = {};
|
|
151953
|
-
if (
|
|
151968
|
+
if (text25.trim()) {
|
|
151954
151969
|
let parsed3;
|
|
151955
151970
|
try {
|
|
151956
|
-
parsed3 = JSON.parse(
|
|
151971
|
+
parsed3 = JSON.parse(text25);
|
|
151957
151972
|
} catch {
|
|
151958
151973
|
throw new KalshiError(400, "invalid_parameters", "invalid parameters", "the request body is not valid JSON");
|
|
151959
151974
|
}
|
|
@@ -152036,11 +152051,11 @@ var unsupported26 = (what) => {
|
|
|
152036
152051
|
throw new IntercomError(400, "not_implemented", `ancha: not implemented: ${what}`, true);
|
|
152037
152052
|
};
|
|
152038
152053
|
var json23 = (status4, body6, headers = {}) => new Response(body6 === void 0 ? null : JSON.stringify(body6), { status: status4, headers: { "content-type": "application/json; charset=utf-8", ...headers } });
|
|
152039
|
-
var requestId3 = (c,
|
|
152040
|
-
${
|
|
152054
|
+
var requestId3 = (c, text25) => createHash45("sha256").update(`${c.req.method} ${c.req.url}
|
|
152055
|
+
${text25}`).digest("hex").replace(/^(.{8})(.{4})(.{4})(.{4})(.{12}).*$/, "$1-$2-$3-$4-$5");
|
|
152041
152056
|
function handle22(route12) {
|
|
152042
152057
|
return async (c) => {
|
|
152043
|
-
const ctx = c.env.ctx,
|
|
152058
|
+
const ctx = c.env.ctx, text25 = route12.method === "GET" ? "" : await c.req.text(), rid = requestId3(c, text25);
|
|
152044
152059
|
const error64 = (e) => json23(e.status, { type: "error.list", request_id: rid, errors: [{ code: e.code, message: e.message }] }, { "x-request-id": rid, ...e.gap && { [GAP_HEADER]: "1" } });
|
|
152045
152060
|
try {
|
|
152046
152061
|
const token4 = /^Bearer\s+(\S+)$/i.exec(c.req.header("authorization") ?? "")?.[1];
|
|
@@ -152055,9 +152070,9 @@ function handle22(route12) {
|
|
|
152055
152070
|
fail3(400, "intercom_version_invalid", `The requested version ${version5} does not exist.`);
|
|
152056
152071
|
}
|
|
152057
152072
|
let body6 = void 0;
|
|
152058
|
-
if (
|
|
152073
|
+
if (text25.trim()) {
|
|
152059
152074
|
try {
|
|
152060
|
-
body6 = JSON.parse(
|
|
152075
|
+
body6 = JSON.parse(text25);
|
|
152061
152076
|
} catch {
|
|
152062
152077
|
fail3(400, "parameter_invalid", "The request body is not valid JSON.");
|
|
152063
152078
|
}
|
|
@@ -152080,9 +152095,9 @@ function unknownRoute15(c) {
|
|
|
152080
152095
|
// packages/server/src/twins/intercom/routes.ts
|
|
152081
152096
|
var now8 = (r2) => Math.floor(r2.ctx.clock.nowMs() / 1e3);
|
|
152082
152097
|
var escape7 = (s2) => s2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
152083
|
-
var html = (
|
|
152098
|
+
var html = (text25) => /<[a-z][^>]*>/i.test(text25) ? text25 : text25.split(/\n\s*\n/).map((p2) => `<p>${escape7(p2).replace(/\n/g, "<br>")}</p>`).join("");
|
|
152084
152099
|
var plain2 = (body6) => body6 === null ? null : body6.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>\s*<p>/gi, "\n\n").replace(/<[^>]+>/g, "").replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").trim();
|
|
152085
|
-
var
|
|
152100
|
+
var text23 = (r2, body6) => r2.plaintext ? plain2(body6) : body6;
|
|
152086
152101
|
function cursorOf(value4) {
|
|
152087
152102
|
if (value4 === void 0 || value4 === null || value4 === "") return 0;
|
|
152088
152103
|
try {
|
|
@@ -152258,7 +152273,7 @@ function partShape2(r2, conv, p2) {
|
|
|
152258
152273
|
type: "conversation_part",
|
|
152259
152274
|
id: p2.id,
|
|
152260
152275
|
part_type: p2.type,
|
|
152261
|
-
body:
|
|
152276
|
+
body: text23(r2, p2.body),
|
|
152262
152277
|
created_at: p2.at,
|
|
152263
152278
|
updated_at: p2.at,
|
|
152264
152279
|
notified_at: p2.at,
|
|
@@ -152297,7 +152312,7 @@ function conversationShape(r2, conv, withParts = true) {
|
|
|
152297
152312
|
id: conv.source_id,
|
|
152298
152313
|
delivered_as: "customer_initiated",
|
|
152299
152314
|
subject: "",
|
|
152300
|
-
body:
|
|
152315
|
+
body: text23(r2, conv.body),
|
|
152301
152316
|
author: authorOf2(r2, { type: "user", id: conv.contact_id }),
|
|
152302
152317
|
attachments: [],
|
|
152303
152318
|
url: null,
|
|
@@ -153231,7 +153246,7 @@ var STATUSES2 = ["new", "open", "pending", "hold", "solved", "closed"];
|
|
|
153231
153246
|
var PRIORITIES2 = ["low", "normal", "high", "urgent"];
|
|
153232
153247
|
var iso15 = (ms) => new Date(ms).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
153233
153248
|
var tagsOf = (value4) => JSON.parse(value4);
|
|
153234
|
-
var escape8 = (
|
|
153249
|
+
var escape8 = (text25) => text25.replace(/[&<>"]/g, (char) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[char]);
|
|
153235
153250
|
var htmlBody = (body6) => `<div class="zd-comment" dir="auto">${body6.split(/\n{2,}/).map((part) => `<p dir="auto">${escape8(part).replace(/\n/g, "<br>")}</p>`).join("")}</div>`;
|
|
153236
153251
|
var getUser7 = (ctx, id14) => ctx.store.db.prepare("SELECT * FROM zd_users WHERE id = ?").get(id14);
|
|
153237
153252
|
var userByEmail = (ctx, email11) => ctx.store.db.prepare("SELECT * FROM zd_users WHERE email = ?").get(email11.toLowerCase());
|
|
@@ -153419,8 +153434,8 @@ function ticket2(ctx, args) {
|
|
|
153419
153434
|
group: row2.group_id === null ? null : getGroup2(ctx, row2.group_id)?.name ?? row2.group_id,
|
|
153420
153435
|
public_comments: comments.map((comment10) => comment10.body)
|
|
153421
153436
|
};
|
|
153422
|
-
const
|
|
153423
|
-
const passed = (args.status === void 0 || row2.status === args.status) && (args.status_in === void 0 || args.status_in.includes(row2.status)) && (args.status_not_in === void 0 || !args.status_not_in.includes(row2.status)) && (args.priority === void 0 || row2.priority === args.priority) && (args.assignee === void 0 || (typeof args.assignee === "number" ? row2.assignee_id : actual.assignee) === args.assignee) && (args.group === void 0 || (typeof args.group === "number" ? row2.group_id : actual.group) === args.group) && (args.tags?.has === void 0 || args.tags.has.every((tag3) => actual.tags.includes(tag3))) && (args.tags?.lacks === void 0 || args.tags.lacks.every((tag3) => !actual.tags.includes(tag3))) && (args.public_comment === void 0 || comments.some((comment10) =>
|
|
153437
|
+
const text25 = typeof args.public_comment === "object" ? args.public_comment.contains : void 0;
|
|
153438
|
+
const passed = (args.status === void 0 || row2.status === args.status) && (args.status_in === void 0 || args.status_in.includes(row2.status)) && (args.status_not_in === void 0 || !args.status_not_in.includes(row2.status)) && (args.priority === void 0 || row2.priority === args.priority) && (args.assignee === void 0 || (typeof args.assignee === "number" ? row2.assignee_id : actual.assignee) === args.assignee) && (args.group === void 0 || (typeof args.group === "number" ? row2.group_id : actual.group) === args.group) && (args.tags?.has === void 0 || args.tags.has.every((tag3) => actual.tags.includes(tag3))) && (args.tags?.lacks === void 0 || args.tags.lacks.every((tag3) => !actual.tags.includes(tag3))) && (args.public_comment === void 0 || comments.some((comment10) => text25 === void 0 || comment10.body.includes(text25)));
|
|
153424
153439
|
return checkOutcome(passed, expected, JSON.stringify(actual));
|
|
153425
153440
|
}
|
|
153426
153441
|
function unchanged2(ctx, args) {
|
|
@@ -153491,8 +153506,8 @@ function ticketMatches(world4, ticket3, term2) {
|
|
|
153491
153506
|
const tags4 = tagsOf(ticket3.tags);
|
|
153492
153507
|
switch (term2.key) {
|
|
153493
153508
|
case null: {
|
|
153494
|
-
const
|
|
153495
|
-
return contains2(
|
|
153509
|
+
const text25 = [ticket3.subject, ticket3.description, ...commentsOf2(world4.ctx, ticket3.id).map((comment10) => comment10.body), ...tags4].join("\n");
|
|
153510
|
+
return contains2(text25, term2.value);
|
|
153496
153511
|
}
|
|
153497
153512
|
case "status":
|
|
153498
153513
|
return ordered(STATUSES2, ticket3.status, term2);
|
|
@@ -153940,13 +153955,13 @@ function commentFrom(ctx, input5, me4) {
|
|
|
153940
153955
|
const comment10 = input5.comment;
|
|
153941
153956
|
if (comment10 === void 0 || comment10 === null) return null;
|
|
153942
153957
|
if (!isObject4(comment10)) throw invalid24("comment", "Comment: must be an object");
|
|
153943
|
-
const
|
|
153944
|
-
if (!
|
|
153958
|
+
const text25 = typeof comment10.body === "string" ? comment10.body : typeof comment10.html_body === "string" ? comment10.html_body.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n\n").replace(/<[^>]+>/g, "").trim() : "";
|
|
153959
|
+
if (!text25.trim()) throw invalid24("comment", "Comment: cannot be blank", "BlankValue");
|
|
153945
153960
|
const author = comment10.author_id === void 0 ? me4 : typeof comment10.author_id === "number" ? getUser7(ctx, comment10.author_id) : void 0;
|
|
153946
153961
|
if (!author) throw invalid24("comment", "Comment: author is invalid");
|
|
153947
153962
|
const isPublic = comment10.public === void 0 ? true : comment10.public === true;
|
|
153948
153963
|
if (!isPublic && !isAgent(author)) throw invalid24("comment", "Comment: only agents can add private comments");
|
|
153949
|
-
return { body:
|
|
153964
|
+
return { body: text25, public: isPublic, author };
|
|
153950
153965
|
}
|
|
153951
153966
|
function dueFrom(value4, type) {
|
|
153952
153967
|
if (value4 === void 0) return void 0;
|
|
@@ -154092,7 +154107,7 @@ function applyMacro(call2) {
|
|
|
154092
154107
|
const ticket3 = ticketBy(call2), macro2 = call2.ctx.store.db.prepare("SELECT * FROM zd_macros WHERE id = ?").get(numericId2(call2.ids[1]));
|
|
154093
154108
|
if (!macro2) throw notFound16();
|
|
154094
154109
|
const result = { id: ticket3.id, url: `${api2(call2.ctx)}/tickets/${ticket3.id}.json` };
|
|
154095
|
-
let tags4 = tagsOf(ticket3.tags),
|
|
154110
|
+
let tags4 = tagsOf(ticket3.tags), text25 = null, isPublic = true;
|
|
154096
154111
|
for (const action of JSON.parse(macro2.actions)) {
|
|
154097
154112
|
switch (action.field) {
|
|
154098
154113
|
case "status":
|
|
@@ -154121,15 +154136,15 @@ function applyMacro(call2) {
|
|
|
154121
154136
|
break;
|
|
154122
154137
|
}
|
|
154123
154138
|
case "comment_value":
|
|
154124
|
-
|
|
154139
|
+
text25 = String(action.value);
|
|
154125
154140
|
break;
|
|
154126
154141
|
case "comment_mode_is_public":
|
|
154127
154142
|
isPublic = action.value === true;
|
|
154128
154143
|
break;
|
|
154129
154144
|
}
|
|
154130
154145
|
}
|
|
154131
|
-
if (
|
|
154132
|
-
return json24({ result: { ticket: result, ...
|
|
154146
|
+
if (text25 !== null) result.comment = { body: text25, html_body: `<p>${text25}</p>`, scoped_body: [["channel:all", text25]], public: isPublic };
|
|
154147
|
+
return json24({ result: { ticket: result, ...text25 !== null && { comment: result.comment } } });
|
|
154133
154148
|
}
|
|
154134
154149
|
function world3(call2) {
|
|
154135
154150
|
const db3 = call2.ctx.store.db;
|
|
@@ -154425,12 +154440,12 @@ async function handle23(c) {
|
|
|
154425
154440
|
response5.headers.set(GAP_HEADER, "1");
|
|
154426
154441
|
return response5;
|
|
154427
154442
|
}
|
|
154428
|
-
const
|
|
154443
|
+
const text25 = method2 === "GET" || method2 === "DELETE" ? "" : await c.req.text();
|
|
154429
154444
|
let body6 = {};
|
|
154430
|
-
if (
|
|
154445
|
+
if (text25.trim()) {
|
|
154431
154446
|
let parsed3;
|
|
154432
154447
|
try {
|
|
154433
|
-
parsed3 = JSON.parse(
|
|
154448
|
+
parsed3 = JSON.parse(text25);
|
|
154434
154449
|
} catch {
|
|
154435
154450
|
throw new ZendeskError(400, { error: "InvalidValue", description: "The request body is not valid JSON" });
|
|
154436
154451
|
}
|
|
@@ -154522,7 +154537,7 @@ function errorResponse15(e) {
|
|
|
154522
154537
|
}
|
|
154523
154538
|
function handle24(route12) {
|
|
154524
154539
|
return async (c) => {
|
|
154525
|
-
const ctx = c.env.ctx,
|
|
154540
|
+
const ctx = c.env.ctx, text25 = route12.method === "GET" || route12.method === "DELETE" ? "" : await c.req.text();
|
|
154526
154541
|
try {
|
|
154527
154542
|
const token4 = /^Bearer\s+(\S+)$/i.exec(c.req.header("authorization") ?? "")?.[1] ?? new URL(c.req.url).searchParams.get("access_token") ?? void 0;
|
|
154528
154543
|
if (!token4) fail4(401, "required", `Request is missing required authentication credential. ${AUTH_HINT2}`);
|
|
@@ -154530,9 +154545,9 @@ function handle24(route12) {
|
|
|
154530
154545
|
if (!scopes3) fail4(401, "authError", `Request had invalid authentication credentials. ${AUTH_HINT2}`);
|
|
154531
154546
|
if (!route12.scopes.some((s2) => JSON.parse(scopes3).includes(s2))) fail4(403, "insufficientPermissions", "Request had insufficient authentication scopes.");
|
|
154532
154547
|
let body6 = {};
|
|
154533
|
-
if (
|
|
154548
|
+
if (text25.trim()) {
|
|
154534
154549
|
try {
|
|
154535
|
-
body6 = JSON.parse(
|
|
154550
|
+
body6 = JSON.parse(text25);
|
|
154536
154551
|
} catch {
|
|
154537
154552
|
fail4(400, "parseError", "Parse Error");
|
|
154538
154553
|
}
|
|
@@ -154592,10 +154607,10 @@ function readWhen(value4, field5, fallbackZone) {
|
|
|
154592
154607
|
if (typeof v.date !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(v.date)) fail4(400, "invalid", "Bad Request");
|
|
154593
154608
|
return { ms: Date.parse(`${v.date}T00:00:00Z`), date: v.date, tz };
|
|
154594
154609
|
}
|
|
154595
|
-
const
|
|
154596
|
-
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/.test(
|
|
154597
|
-
const ms = /(Z|[+-]\d{2}:\d{2})$/.test(
|
|
154598
|
-
const [d, t] =
|
|
154610
|
+
const text25 = String(v.dateTime);
|
|
154611
|
+
if (!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?$/.test(text25)) fail4(400, "invalid", "Bad Request");
|
|
154612
|
+
const ms = /(Z|[+-]\d{2}:\d{2})$/.test(text25) ? Date.parse(text25) : (() => {
|
|
154613
|
+
const [d, t] = text25.split("T");
|
|
154599
154614
|
const [y, m, dd] = d.split("-").map(Number);
|
|
154600
154615
|
const [h, mi, s2] = t.split(":").map(Number);
|
|
154601
154616
|
return localToUtc2(y, m, dd, h, mi, Math.floor(s2 ?? 0), tz);
|
|
@@ -156197,9 +156212,9 @@ var membershipsOf2 = (ctx, task2) => ctx.store.db.prepare("SELECT m.* FROM as_me
|
|
|
156197
156212
|
var followersOf = (ctx, task2) => ctx.store.db.prepare("SELECT user FROM as_followers WHERE task = ? ORDER BY user").all(task2).map((row2) => row2.user);
|
|
156198
156213
|
var subtasksOf = (ctx, task2) => ctx.store.db.prepare("SELECT * FROM as_tasks WHERE parent = ? AND deleted_ms IS NULL ORDER BY created_ms, gid").all(task2);
|
|
156199
156214
|
var sectionsOf = (ctx, project12) => ctx.store.db.prepare("SELECT * FROM as_sections WHERE project = ? ORDER BY position").all(project12);
|
|
156200
|
-
function addStory(ctx, task2, author, type, subtype,
|
|
156215
|
+
function addStory(ctx, task2, author, type, subtype, text25, at3) {
|
|
156201
156216
|
const gid2 = nextGid(ctx, "story");
|
|
156202
|
-
ctx.store.db.prepare("INSERT INTO as_stories (gid, task, created_by, created_ms, type, subtype, text) VALUES (?, ?, ?, ?, ?, ?, ?)").run(gid2, task2, author, at3, type, subtype,
|
|
156217
|
+
ctx.store.db.prepare("INSERT INTO as_stories (gid, task, created_by, created_ms, type, subtype, text) VALUES (?, ?, ?, ?, ?, ?, ?)").run(gid2, task2, author, at3, type, subtype, text25);
|
|
156203
156218
|
return gid2;
|
|
156204
156219
|
}
|
|
156205
156220
|
function placeTask(ctx, task2, project12, section2, anchor2) {
|
|
@@ -156332,7 +156347,7 @@ var errorBody5 = (message7) => ({ errors: [{ message: message7, help: HELP }] })
|
|
|
156332
156347
|
var json27 = (body6, status4 = 200) => new Response(JSON.stringify(body6), { status: status4, headers: { "content-type": "application/json; charset=utf-8" } });
|
|
156333
156348
|
var bad = (message7) => new AsanaError(400, message7);
|
|
156334
156349
|
var unknownId = (kind, gid2) => new AsanaError(404, `${kind}: Not a recognized ID: ${gid2}`);
|
|
156335
|
-
var escape9 = (
|
|
156350
|
+
var escape9 = (text25) => text25.replace(/[&<>]/g, (char) => ({ "&": "&", "<": "<", ">": ">" })[char]);
|
|
156336
156351
|
var userCompact = (user8) => ({ gid: user8.gid, name: user8.name, resource_type: "user" });
|
|
156337
156352
|
var workspaceCompact = (ctx) => ({ ...workspace2(ctx), resource_type: "workspace" });
|
|
156338
156353
|
var projectCompact = (project12) => ({ gid: project12.gid, name: project12.name, resource_type: "project" });
|
|
@@ -156749,7 +156764,7 @@ function updateTask(call2) {
|
|
|
156749
156764
|
}
|
|
156750
156765
|
}
|
|
156751
156766
|
ctx.store.db.prepare("UPDATE as_tasks SET name = ?, notes = ?, assignee = ?, due_on = ?, due_at_ms = ?, start_on = ?, completed_ms = ?, completed_by = ?, modified_ms = ? WHERE gid = ?").run(next2.name, next2.notes, next2.assignee, next2.due_on, next2.due_at_ms, next2.start_on, next2.completed_ms, next2.completed_by, stories.length ? now11 : task2.modified_ms, task2.gid);
|
|
156752
|
-
for (const [subtype,
|
|
156767
|
+
for (const [subtype, text25] of stories) addStory(ctx, task2.gid, call2.me.gid, "system", subtype, text25, now11);
|
|
156753
156768
|
return one5(call2, taskFull(ctx, getTask(ctx, task2.gid)));
|
|
156754
156769
|
}
|
|
156755
156770
|
function deleteTask(call2) {
|
|
@@ -156771,10 +156786,10 @@ function listStories(call2) {
|
|
|
156771
156786
|
}
|
|
156772
156787
|
function addComment2(call2) {
|
|
156773
156788
|
const task2 = taskBy(call2), data5 = call2.body, now11 = call2.ctx.clock.nowMs();
|
|
156774
|
-
const
|
|
156775
|
-
if (!
|
|
156789
|
+
const text25 = typeof data5.text === "string" ? data5.text : typeof data5.html_text === "string" ? data5.html_text.replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]+>/g, "") : "";
|
|
156790
|
+
if (!text25.trim()) throw bad("text: Missing input");
|
|
156776
156791
|
if (data5.sticker_name !== void 0) unsupported30("stickers");
|
|
156777
|
-
const gid2 = addStory(call2.ctx, task2.gid, call2.me.gid, "comment", "comment_added",
|
|
156792
|
+
const gid2 = addStory(call2.ctx, task2.gid, call2.me.gid, "comment", "comment_added", text25, now11);
|
|
156778
156793
|
call2.ctx.store.db.prepare("UPDATE as_tasks SET modified_ms = ? WHERE gid = ?").run(now11, task2.gid);
|
|
156779
156794
|
call2.ctx.store.db.prepare("INSERT OR IGNORE INTO as_followers (task, user) VALUES (?, ?)").run(task2.gid, call2.me.gid);
|
|
156780
156795
|
return json27({ data: storyFull(call2.ctx, call2.ctx.store.db.prepare("SELECT * FROM as_stories WHERE gid = ?").get(gid2)) }, 201);
|
|
@@ -156830,7 +156845,7 @@ function searchTasks(call2) {
|
|
|
156830
156845
|
const users5 = (name5) => params10.get(name5)?.split(",").map((value4) => userRef3(call2, value4.trim(), name5).gid);
|
|
156831
156846
|
const ids2 = (name5) => params10.get(name5)?.split(",").map((value4) => value4.trim());
|
|
156832
156847
|
const assignees = users5("assignee.any"), excluded = users5("assignee.not"), projects = ids2("projects.any"), notProjects = ids2("projects.not"), sections = ids2("sections.any");
|
|
156833
|
-
const
|
|
156848
|
+
const text25 = params10.get("text")?.toLowerCase(), completed = params10.get("completed"), subtask = params10.get("is_subtask"), sortBy2 = params10.get("sort_by") ?? "modified_at";
|
|
156834
156849
|
if (!["due_date", "created_at", "completed_at", "likes", "modified_at"].includes(sortBy2)) throw bad("sort_by: Not one of due_date, created_at, completed_at, likes, modified_at");
|
|
156835
156850
|
const time7 = (name5) => {
|
|
156836
156851
|
const value4 = params10.get(name5);
|
|
@@ -156844,7 +156859,7 @@ function searchTasks(call2) {
|
|
|
156844
156859
|
if (!Number.isInteger(limit) || limit < 1 || limit > 100) throw bad("limit: Value must be between 1 and 100");
|
|
156845
156860
|
const tasks = liveTasks(ctx).filter((task2) => {
|
|
156846
156861
|
const memberships = membershipsOf2(ctx, task2.gid);
|
|
156847
|
-
return (!
|
|
156862
|
+
return (!text25 || task2.name.toLowerCase().includes(text25) || task2.notes.toLowerCase().includes(text25)) && (!assignees || task2.assignee !== null && assignees.includes(task2.assignee)) && (!excluded || task2.assignee === null || !excluded.includes(task2.assignee)) && (!projects || memberships.some((membership) => projects.includes(membership.project))) && (!notProjects || !memberships.some((membership) => notProjects.includes(membership.project))) && (!sections || memberships.some((membership) => sections.includes(membership.section))) && (completed === null || task2.completed_ms !== null === (completed === "true")) && (subtask === null || task2.parent !== null === (subtask === "true")) && (params10.get("due_on") === null || task2.due_on === params10.get("due_on")) && (params10.get("due_on.before") === null || task2.due_on !== null && task2.due_on < params10.get("due_on.before")) && (params10.get("due_on.after") === null || task2.due_on !== null && task2.due_on > params10.get("due_on.after")) && (createdAfter === null || task2.created_ms > createdAfter) && (createdBefore === null || task2.created_ms < createdBefore) && (modifiedAfter === null || task2.modified_ms > modifiedAfter) && (modifiedBefore === null || task2.modified_ms < modifiedBefore);
|
|
156848
156863
|
});
|
|
156849
156864
|
const key4 = (task2) => sortBy2 === "due_date" ? task2.due_on ?? "9999" : sortBy2 === "created_at" ? task2.created_ms : sortBy2 === "completed_at" ? task2.completed_ms ?? 0 : sortBy2 === "likes" ? 0 : task2.modified_ms;
|
|
156850
156865
|
const ascending = params10.get("sort_ascending") === "true";
|
|
@@ -156930,16 +156945,16 @@ function authenticate13(ctx, header3) {
|
|
|
156930
156945
|
return getUser8(ctx, ctx.store.meta.get("asana.me"));
|
|
156931
156946
|
}
|
|
156932
156947
|
async function readBody2(c) {
|
|
156933
|
-
const type = c.req.header("content-type") ?? "",
|
|
156934
|
-
if (!
|
|
156948
|
+
const type = c.req.header("content-type") ?? "", text25 = await c.req.text();
|
|
156949
|
+
if (!text25.trim()) return {};
|
|
156935
156950
|
if (/^application\/x-www-form-urlencoded/i.test(type)) {
|
|
156936
156951
|
const out = {};
|
|
156937
|
-
for (const [name5, value4] of new URLSearchParams(
|
|
156952
|
+
for (const [name5, value4] of new URLSearchParams(text25)) out[name5] = name5 in out ? [...[out[name5]].flat(), value4] : value4;
|
|
156938
156953
|
return out;
|
|
156939
156954
|
}
|
|
156940
156955
|
let parsed3;
|
|
156941
156956
|
try {
|
|
156942
|
-
parsed3 = JSON.parse(
|
|
156957
|
+
parsed3 = JSON.parse(text25);
|
|
156943
156958
|
} catch {
|
|
156944
156959
|
throw new AsanaError(400, "Could not parse request data, invalid JSON");
|
|
156945
156960
|
}
|
|
@@ -157607,13 +157622,13 @@ async function handle27(c) {
|
|
|
157607
157622
|
response5.headers.set(GAP_HEADER, "1");
|
|
157608
157623
|
return response5;
|
|
157609
157624
|
}
|
|
157610
|
-
const
|
|
157625
|
+
const text25 = method2 === "GET" || method2 === "DELETE" ? "" : await c.req.text();
|
|
157611
157626
|
if (/^multipart\/form-data/i.test(c.req.header("content-type") ?? "")) unsupported31("file uploads");
|
|
157612
157627
|
let body6 = {};
|
|
157613
|
-
if (
|
|
157628
|
+
if (text25.trim()) {
|
|
157614
157629
|
let parsed3;
|
|
157615
157630
|
try {
|
|
157616
|
-
parsed3 = JSON.parse(
|
|
157631
|
+
parsed3 = JSON.parse(text25);
|
|
157617
157632
|
} catch {
|
|
157618
157633
|
throw new DiscordError(400, 50109, "The request body contains invalid JSON.");
|
|
157619
157634
|
}
|
|
@@ -157791,7 +157806,7 @@ var base3 = (ctx) => ctx.serviceUrl ?? "";
|
|
|
157791
157806
|
function handle28(route12) {
|
|
157792
157807
|
return async (c) => {
|
|
157793
157808
|
const ctx = c.env.ctx;
|
|
157794
|
-
const
|
|
157809
|
+
const text25 = route12.method === "GET" || route12.method === "DELETE" ? "" : await c.req.text();
|
|
157795
157810
|
try {
|
|
157796
157811
|
const token4 = /^Bearer\s+(\S+)$/i.exec(c.req.header("authorization") ?? "")?.[1];
|
|
157797
157812
|
if (!token4) return json29(401, { detail: "Authentication credentials were not provided." });
|
|
@@ -157802,9 +157817,9 @@ function handle28(route12) {
|
|
|
157802
157817
|
if (!auth) return json29(401, { detail: "Invalid token" });
|
|
157803
157818
|
if (!route12.scopes.some((s2) => auth.scopes.includes(s2))) fail5(403, "You do not have permission to perform this action.");
|
|
157804
157819
|
let body6 = {};
|
|
157805
|
-
if (
|
|
157820
|
+
if (text25.trim()) {
|
|
157806
157821
|
try {
|
|
157807
|
-
body6 = JSON.parse(
|
|
157822
|
+
body6 = JSON.parse(text25);
|
|
157808
157823
|
} catch {
|
|
157809
157824
|
fail5(400, "JSON parse error - Expecting value: line 1 column 1 (char 0)");
|
|
157810
157825
|
}
|
|
@@ -158624,8 +158639,8 @@ function apply(ctx, i, by2, c, ms) {
|
|
|
158624
158639
|
saveIssue2(ctx, i);
|
|
158625
158640
|
return delta2;
|
|
158626
158641
|
}
|
|
158627
|
-
function comment9(ctx, i, by2,
|
|
158628
|
-
activity(ctx, i, "note", by2, { text:
|
|
158642
|
+
function comment9(ctx, i, by2, text25, ms) {
|
|
158643
|
+
activity(ctx, i, "note", by2, { text: text25 }, ms);
|
|
158629
158644
|
saveIssue2(ctx, i);
|
|
158630
158645
|
return i.activity.at(-1);
|
|
158631
158646
|
}
|
|
@@ -158690,7 +158705,7 @@ function bodyDate(field5, value4) {
|
|
|
158690
158705
|
if (!Number.isFinite(t)) invalid25(field5, "Datetime has wrong format. Use one of these formats instead: YYYY-MM-DDThh:mm[:ss[.uuuuuu]][+HH:MM|-HH:MM|Z].");
|
|
158691
158706
|
return t;
|
|
158692
158707
|
}
|
|
158693
|
-
var
|
|
158708
|
+
var text24 = (field5, value4, max = 200) => {
|
|
158694
158709
|
if (value4 === null || value4 === void 0) return null;
|
|
158695
158710
|
if (typeof value4 !== "string") invalid25(field5, "Not a valid string.");
|
|
158696
158711
|
if (value4.length > max) invalid25(field5, `Ensure this field has no more than ${max} characters.`);
|
|
@@ -158803,8 +158818,8 @@ var orgRoutes = [
|
|
|
158803
158818
|
project_ids: projects.map((p2) => p2.id),
|
|
158804
158819
|
created_ms: r2.now,
|
|
158805
158820
|
released_ms: bodyDate("dateReleased", b.dateReleased),
|
|
158806
|
-
ref:
|
|
158807
|
-
url:
|
|
158821
|
+
ref: text24("ref", b.ref),
|
|
158822
|
+
url: text24("url", b.url, 1e3),
|
|
158808
158823
|
status: b.status ?? "open"
|
|
158809
158824
|
}));
|
|
158810
158825
|
}
|
|
@@ -158821,8 +158836,8 @@ var orgRoutes = [
|
|
|
158821
158836
|
if (b.status !== void 0 && !["open", "archived"].includes(b.status)) invalid25("status", `"${b.status}" is not a valid choice.`);
|
|
158822
158837
|
return releaseShape(r2.ctx, saveRelease(r2.ctx, {
|
|
158823
158838
|
...rel,
|
|
158824
|
-
..."ref" in b && { ref:
|
|
158825
|
-
..."url" in b && { url:
|
|
158839
|
+
..."ref" in b && { ref: text24("ref", b.ref) },
|
|
158840
|
+
..."url" in b && { url: text24("url", b.url, 1e3) },
|
|
158826
158841
|
..."dateReleased" in b && { released_ms: bodyDate("dateReleased", b.dateReleased) },
|
|
158827
158842
|
...b.status !== void 0 && { status: b.status }
|
|
158828
158843
|
}));
|
|
@@ -158851,8 +158866,8 @@ var orgRoutes = [
|
|
|
158851
158866
|
id: next(r2.ctx, "deploy", 58210001),
|
|
158852
158867
|
release_id: rel.id,
|
|
158853
158868
|
environment: b.environment,
|
|
158854
|
-
name:
|
|
158855
|
-
url:
|
|
158869
|
+
name: text24("name", b.name, 64),
|
|
158870
|
+
url: text24("url", b.url, 1e3),
|
|
158856
158871
|
started_ms: bodyDate("dateStarted", b.dateStarted),
|
|
158857
158872
|
finished_ms: finished,
|
|
158858
158873
|
project_ids: projects.length ? projects.map((p2) => p2.id) : rel.project_ids
|
|
@@ -158891,7 +158906,7 @@ function parseSearch2(query10, where2) {
|
|
|
158891
158906
|
tokens3.push(query10.slice(i, j));
|
|
158892
158907
|
i = j;
|
|
158893
158908
|
}
|
|
158894
|
-
const filters = [],
|
|
158909
|
+
const filters = [], text25 = [];
|
|
158895
158910
|
for (const token4 of tokens3) {
|
|
158896
158911
|
if (token4 === "OR" || token4 === "AND") {
|
|
158897
158912
|
if (where2 === "issues") fail5(400, 'Error parsing search query: Boolean statements containing "OR" or "AND" are not supported in this search');
|
|
@@ -158899,7 +158914,7 @@ function parseSearch2(query10, where2) {
|
|
|
158899
158914
|
}
|
|
158900
158915
|
const m = KEY2.exec(token4);
|
|
158901
158916
|
if (!m) {
|
|
158902
|
-
|
|
158917
|
+
text25.push(unquote2(token4));
|
|
158903
158918
|
continue;
|
|
158904
158919
|
}
|
|
158905
158920
|
const [, bang, key4, rest2] = m;
|
|
@@ -158913,7 +158928,7 @@ function parseSearch2(query10, where2) {
|
|
|
158913
158928
|
const values2 = value4.startsWith("[") && value4.endsWith("]") ? value4.slice(1, -1).split(",").map((v) => unquote2(v.trim())).filter(Boolean) : [unquote2(value4)];
|
|
158914
158929
|
filters.push({ key: key4, negated: bang === "!", op, values: values2 });
|
|
158915
158930
|
}
|
|
158916
|
-
return { filters, text:
|
|
158931
|
+
return { filters, text: text25.join(" ") };
|
|
158917
158932
|
}
|
|
158918
158933
|
function glob2(pattern, value4, caseless = false) {
|
|
158919
158934
|
if (!pattern.includes("*")) return caseless ? pattern.toLowerCase() === value4.toLowerCase() : pattern === value4;
|
|
@@ -159021,7 +159036,7 @@ function matches7(f2, value4, now11) {
|
|
|
159021
159036
|
if (f2.key === "message" || f2.key === "title") return f2.values.some((v) => v.includes("*") ? glob2(v, value4, true) : value4.toLowerCase().includes(v.toLowerCase()));
|
|
159022
159037
|
return f2.values.some((v) => glob2(v, value4, caseless));
|
|
159023
159038
|
}
|
|
159024
|
-
function eventTest(filters,
|
|
159039
|
+
function eventTest(filters, text25, lookup5, now11, resolve7 = (f2) => f2) {
|
|
159025
159040
|
return (e) => filters.every((raw3) => {
|
|
159026
159041
|
const f2 = resolve7(raw3, e);
|
|
159027
159042
|
if (f2.key === "has") return f2.values.every((k) => {
|
|
@@ -159029,7 +159044,7 @@ function eventTest(filters, text24, lookup5, now11, resolve7 = (f2) => f2) {
|
|
|
159029
159044
|
return v !== null && v !== "" && !(Array.isArray(v) && !v.length);
|
|
159030
159045
|
}) !== f2.negated;
|
|
159031
159046
|
return matches7(f2, eventValue(e, f2.key, lookup5), now11) !== f2.negated;
|
|
159032
|
-
}) && (!
|
|
159047
|
+
}) && (!text25 || [e.title, e.message, e.culprit].some((s2) => typeof s2 === "string" && s2.toLowerCase().includes(text25.toLowerCase())));
|
|
159033
159048
|
}
|
|
159034
159049
|
|
|
159035
159050
|
// packages/server/src/twins/sentry/issues.ts
|
|
@@ -159778,12 +159793,12 @@ var dateFormatOption = (name5) => ({ format: DATE_FORMATS[name5] ?? "YYYY-MM-DD"
|
|
|
159778
159793
|
var timeFormatOption = (name5) => ({ format: TIME_FORMATS[name5] ?? "HH:mm", name: TIME_FORMATS[name5] ? name5 : "24hour" });
|
|
159779
159794
|
var iso19 = (ms) => new Date(ms).toISOString();
|
|
159780
159795
|
var parsed2 = /* @__PURE__ */ new Map();
|
|
159781
|
-
function parse12(
|
|
159782
|
-
let node5 = parsed2.get(
|
|
159796
|
+
function parse12(text25) {
|
|
159797
|
+
let node5 = parsed2.get(text25);
|
|
159783
159798
|
if (!node5) {
|
|
159784
|
-
node5 = airtable_formula_exports.parseFormula(
|
|
159799
|
+
node5 = airtable_formula_exports.parseFormula(text25);
|
|
159785
159800
|
if (parsed2.size > 2e3) parsed2.clear();
|
|
159786
|
-
parsed2.set(
|
|
159801
|
+
parsed2.set(text25, node5);
|
|
159787
159802
|
}
|
|
159788
159803
|
return node5;
|
|
159789
159804
|
}
|
|
@@ -160141,9 +160156,9 @@ var AirtableBase = class _AirtableBase {
|
|
|
160141
160156
|
let n2;
|
|
160142
160157
|
if (typeof value4 === "number" && Number.isFinite(value4)) n2 = value4;
|
|
160143
160158
|
else if (typecast && typeof value4 === "string") {
|
|
160144
|
-
const
|
|
160145
|
-
if (!
|
|
160146
|
-
if (cleaned && Number.isFinite(Number(cleaned))) n2 = field5.type === "percent" &&
|
|
160159
|
+
const text25 = value4.trim(), cleaned = text25.replace(/[^0-9eE.+-]/g, "");
|
|
160160
|
+
if (!text25) return void 0;
|
|
160161
|
+
if (cleaned && Number.isFinite(Number(cleaned))) n2 = field5.type === "percent" && text25.endsWith("%") ? Number(cleaned) / 100 : Number(cleaned);
|
|
160147
160162
|
}
|
|
160148
160163
|
if (n2 === void 0) throw bad4();
|
|
160149
160164
|
if (field5.type === "rating" && n2 === 0) return void 0;
|
|
@@ -160153,9 +160168,9 @@ var AirtableBase = class _AirtableBase {
|
|
|
160153
160168
|
switch (field5.type) {
|
|
160154
160169
|
case "checkbox": {
|
|
160155
160170
|
if (typeof value4 === "boolean") return value4 ? true : void 0;
|
|
160156
|
-
const
|
|
160157
|
-
if (
|
|
160158
|
-
if (
|
|
160171
|
+
const text25 = typecast ? String(value4).trim().toLowerCase() : null;
|
|
160172
|
+
if (text25 !== null && ["true", "yes", "checked", "x", "1", "on"].includes(text25)) return true;
|
|
160173
|
+
if (text25 !== null && ["false", "no", "unchecked", "", "0", "off"].includes(text25)) return void 0;
|
|
160159
160174
|
throw bad4();
|
|
160160
160175
|
}
|
|
160161
160176
|
case "singleSelect": {
|
|
@@ -160175,9 +160190,9 @@ var AirtableBase = class _AirtableBase {
|
|
|
160175
160190
|
case "date":
|
|
160176
160191
|
case "dateTime": {
|
|
160177
160192
|
if (typeof value4 !== "string") throw bad4();
|
|
160178
|
-
const
|
|
160179
|
-
if (!
|
|
160180
|
-
const date10 = /^\d{4}-\d{2}-\d{2}($|[T ])/.test(
|
|
160193
|
+
const text25 = value4.trim();
|
|
160194
|
+
if (!text25) return void 0;
|
|
160195
|
+
const date10 = /^\d{4}-\d{2}-\d{2}($|[T ])/.test(text25) || typecast ? airtable_formula_exports.parseFormulaDate(text25) : null;
|
|
160181
160196
|
if (!date10) throw bad4();
|
|
160182
160197
|
return field5.type === "date" ? iso19(date10.ms).slice(0, 10) : iso19(date10.ms);
|
|
160183
160198
|
}
|
|
@@ -160212,7 +160227,7 @@ var AirtableBase = class _AirtableBase {
|
|
|
160212
160227
|
}
|
|
160213
160228
|
}
|
|
160214
160229
|
#person(value4, typecast, bad4) {
|
|
160215
|
-
const all9 = this.users(), lower4 = (
|
|
160230
|
+
const all9 = this.users(), lower4 = (text25) => String(text25).trim().toLowerCase();
|
|
160216
160231
|
let found;
|
|
160217
160232
|
if (value4 && typeof value4 === "object" && !Array.isArray(value4)) {
|
|
160218
160233
|
const ref22 = value4;
|
|
@@ -160571,9 +160586,9 @@ function commentText(body6) {
|
|
|
160571
160586
|
return body6.text;
|
|
160572
160587
|
}
|
|
160573
160588
|
function createComment2(call2) {
|
|
160574
|
-
const { model, record: record9 } = commentsOf3(call2, true),
|
|
160589
|
+
const { model, record: record9 } = commentsOf3(call2, true), text25 = commentText(call2.body), parent2 = call2.body.parentCommentId;
|
|
160575
160590
|
if (parent2 !== void 0 && (typeof parent2 !== "string" || !liveComments(call2.ctx, record9.id).some((row3) => row3.id === parent2))) throw notFound20();
|
|
160576
|
-
const row2 = { id: newId8(call2.ctx, "com"), record_id: record9.id, author_id: meId(call2.ctx), text:
|
|
160591
|
+
const row2 = { id: newId8(call2.ctx, "com"), record_id: record9.id, author_id: meId(call2.ctx), text: text25, parent_id: parent2 ?? null, created_ms: call2.ctx.clock.nowMs(), updated_ms: null, deleted_ms: null };
|
|
160577
160592
|
call2.ctx.store.db.prepare("INSERT INTO at_comments (id, record_id, author_id, text, parent_id, created_ms) VALUES (?, ?, ?, ?, ?, ?)").run(row2.id, row2.record_id, row2.author_id, row2.text, row2.parent_id, row2.created_ms);
|
|
160578
160593
|
return json30(commentJson2(model, row2));
|
|
160579
160594
|
}
|
|
@@ -160584,9 +160599,9 @@ function ownComment(call2) {
|
|
|
160584
160599
|
return { model, comment: comment10 };
|
|
160585
160600
|
}
|
|
160586
160601
|
function updateComment2(call2) {
|
|
160587
|
-
const { model, comment: comment10 } = ownComment(call2),
|
|
160588
|
-
call2.ctx.store.db.prepare("UPDATE at_comments SET text = ?, updated_ms = ? WHERE id = ?").run(
|
|
160589
|
-
return json30(commentJson2(model, { ...comment10, text:
|
|
160602
|
+
const { model, comment: comment10 } = ownComment(call2), text25 = commentText(call2.body), now11 = call2.ctx.clock.nowMs();
|
|
160603
|
+
call2.ctx.store.db.prepare("UPDATE at_comments SET text = ?, updated_ms = ? WHERE id = ?").run(text25, now11, comment10.id);
|
|
160604
|
+
return json30(commentJson2(model, { ...comment10, text: text25, updated_ms: now11 }));
|
|
160590
160605
|
}
|
|
160591
160606
|
function deleteComment2(call2) {
|
|
160592
160607
|
const { comment: comment10 } = ownComment(call2);
|
|
@@ -160642,10 +160657,10 @@ function addField(model, table4, input5) {
|
|
|
160642
160657
|
if (field5?.type !== "multipleRecordLinks") throw invalidRequest(`Invalid request: options.${key4} must be a link field in ${table4.name}`);
|
|
160643
160658
|
return field5;
|
|
160644
160659
|
};
|
|
160645
|
-
const formula = (
|
|
160646
|
-
if (typeof
|
|
160660
|
+
const formula = (text25, hasField, vars = []) => {
|
|
160661
|
+
if (typeof text25 !== "string" || !text25.trim()) throw invalidRequest("Invalid request: options.formula is required");
|
|
160647
160662
|
try {
|
|
160648
|
-
const node5 = airtable_formula_exports.parseFormula(
|
|
160663
|
+
const node5 = airtable_formula_exports.parseFormula(text25);
|
|
160649
160664
|
airtable_formula_exports.checkFormula(node5, hasField, vars);
|
|
160650
160665
|
return node5;
|
|
160651
160666
|
} catch (error64) {
|
|
@@ -160920,8 +160935,8 @@ function seed40(ctx) {
|
|
|
160920
160935
|
continue;
|
|
160921
160936
|
}
|
|
160922
160937
|
if (field5.type === "dateTime") {
|
|
160923
|
-
const
|
|
160924
|
-
cells[key4] = iso19(/^-?\d/.test(
|
|
160938
|
+
const text25 = value4;
|
|
160939
|
+
cells[key4] = iso19(/^-?\d/.test(text25) && !/^\d{4}-/.test(text25) ? at3(text25) : Date.parse(text25));
|
|
160925
160940
|
continue;
|
|
160926
160941
|
}
|
|
160927
160942
|
if (value4 === "" || Array.isArray(value4) && !value4.length) continue;
|
|
@@ -160949,7 +160964,7 @@ function seed40(ctx) {
|
|
|
160949
160964
|
}
|
|
160950
160965
|
}
|
|
160951
160966
|
}
|
|
160952
|
-
const mention = (
|
|
160967
|
+
const mention = (text25) => text25.replace(/@\[([^\]]+)\]/g, (_match, who2) => `@[${person4(who2)}]`);
|
|
160953
160968
|
const positions2 = /* @__PURE__ */ new Map();
|
|
160954
160969
|
for (const row2 of rows7) {
|
|
160955
160970
|
const position = positions2.get(row2.tableId) ?? 0;
|
|
@@ -160963,7 +160978,7 @@ function seed40(ctx) {
|
|
|
160963
160978
|
}
|
|
160964
160979
|
function dumpState39(ctx) {
|
|
160965
160980
|
const people3 = new Map(users4(ctx).map((user8) => [user8.id, user8]));
|
|
160966
|
-
const readable2 = (
|
|
160981
|
+
const readable2 = (text25) => text25.replace(/@\[(usr[A-Za-z0-9]+)\]/g, (match3, id14) => people3.has(id14) ? `@[${people3.get(id14).name}]` : match3);
|
|
160967
160982
|
return {
|
|
160968
160983
|
user: people3.get(meId(ctx))?.email ?? null,
|
|
160969
160984
|
bases: bases(ctx).map((row2) => {
|
|
@@ -161027,11 +161042,11 @@ async function handle29(c) {
|
|
|
161027
161042
|
return response5;
|
|
161028
161043
|
}
|
|
161029
161044
|
let body6 = {};
|
|
161030
|
-
const
|
|
161031
|
-
if (
|
|
161045
|
+
const text25 = method2 === "GET" || method2 === "DELETE" ? "" : await c.req.text();
|
|
161046
|
+
if (text25.trim()) {
|
|
161032
161047
|
let parsed3;
|
|
161033
161048
|
try {
|
|
161034
|
-
parsed3 = JSON.parse(
|
|
161049
|
+
parsed3 = JSON.parse(text25);
|
|
161035
161050
|
} catch {
|
|
161036
161051
|
throw new AirtableError(400, "INVALID_REQUEST_UNKNOWN", "Invalid request: the request body is not valid JSON");
|
|
161037
161052
|
}
|
|
@@ -161224,8 +161239,8 @@ var checks = {
|
|
|
161224
161239
|
|
|
161225
161240
|
// packages/server/src/twins/carrier-portal/pdf.ts
|
|
161226
161241
|
var winAnsi = new Map([..."\u20AC\u201A\u0192\u201E\u2026\u2020\u2021\u02C6\u2030\u0160\u2039\u0152\u017D\u2018\u2019\u201C\u201D\u2022\u2013\u2014\u02DC\u2122\u0161\u203A\u0153\u017E\u0178"].map((c, i) => [c, [128, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 142, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 158, 159][i]]));
|
|
161227
|
-
function encodeText(
|
|
161228
|
-
return [...
|
|
161242
|
+
function encodeText(text25) {
|
|
161243
|
+
return [...text25.normalize("NFC")].map((c) => {
|
|
161229
161244
|
const code2 = c.codePointAt(0);
|
|
161230
161245
|
if (code2 >= 32 && code2 <= 126 || code2 >= 160 && code2 <= 255) return c;
|
|
161231
161246
|
if (winAnsi.has(c)) return String.fromCharCode(winAnsi.get(c));
|
|
@@ -161233,7 +161248,7 @@ function encodeText(text24) {
|
|
|
161233
161248
|
return /^[\x20-\x7e]+$/.test(base4) ? base4 : "?";
|
|
161234
161249
|
}).join("");
|
|
161235
161250
|
}
|
|
161236
|
-
var pdfString = (
|
|
161251
|
+
var pdfString = (text25) => text25.replace(/[\\()\x80-\xff]/g, (c) => c.charCodeAt(0) >= 128 ? `\\${c.charCodeAt(0).toString(8).padStart(3, "0")}` : `\\${c}`);
|
|
161237
161252
|
function carrierPdf(lines) {
|
|
161238
161253
|
const wrapped = lines.flatMap((line2) => encodeText(line2).match(/.{1,88}/g) ?? [""]);
|
|
161239
161254
|
const pages = [];
|
|
@@ -162293,7 +162308,7 @@ var TYPE_NAMES = {
|
|
|
162293
162308
|
ExpRept: "Expense Report"
|
|
162294
162309
|
};
|
|
162295
162310
|
var DISPLAY = {
|
|
162296
|
-
status: Object.fromEntries(Object.entries(STATUS2).map(([key4,
|
|
162311
|
+
status: Object.fromEntries(Object.entries(STATUS2).map(([key4, text25]) => [key4, `${TYPE_NAMES[key4.split(":")[0]]} : ${text25}`])),
|
|
162297
162312
|
itemtype: { Service: "Service", NonInvtPart: "Non-inventory Item", InvtPart: "Inventory Item", OthCharge: "Other Charge" },
|
|
162298
162313
|
accttype: {
|
|
162299
162314
|
Bank: "Bank",
|
|
@@ -162642,9 +162657,9 @@ function assertion(ctx, base4, header3, form2) {
|
|
|
162642
162657
|
const access3 = issue7(ctx, "access", { client: creds.consumerKey, scope: JSON.stringify(scopes3), role: ADMINISTRATOR, entity: administrator(ctx), chain, origin }, ACCESS_SECONDS);
|
|
162643
162658
|
return json31({ access_token: access3, expires_in: ACCESS_SECONDS, token_type: "bearer" });
|
|
162644
162659
|
}
|
|
162645
|
-
function token3(ctx, base4, header3, contentType,
|
|
162660
|
+
function token3(ctx, base4, header3, contentType, text25) {
|
|
162646
162661
|
if (!/^\s*application\/x-www-form-urlencoded\s*(?:;.*)?$/i.test(contentType ?? "")) return oauthError(ctx, "invalid_request");
|
|
162647
|
-
const form2 = new URLSearchParams(
|
|
162662
|
+
const form2 = new URLSearchParams(text25);
|
|
162648
162663
|
for (const key4 of new Set(form2.keys())) if (form2.getAll(key4).length > 1) return oauthError(ctx, "invalid_request");
|
|
162649
162664
|
const grant = form2.get("grant_type");
|
|
162650
162665
|
if (!grant) return oauthError(ctx, "invalid_request");
|
|
@@ -162681,9 +162696,9 @@ function token3(ctx, base4, header3, contentType, text24) {
|
|
|
162681
162696
|
db2(ctx).prepare(`UPDATE ns_oauth SET used = 1 WHERE token = ? AND kind = 'refresh'`).run(refresh);
|
|
162682
162697
|
return json31({ access_token: access3, refresh_token: issue7(ctx, "refresh", row2, refreshSeconds), expires_in: String(ACCESS_SECONDS), token_type: "bearer" });
|
|
162683
162698
|
}
|
|
162684
|
-
function revoke2(ctx, header3, contentType,
|
|
162699
|
+
function revoke2(ctx, header3, contentType, text25) {
|
|
162685
162700
|
if (!/^\s*application\/x-www-form-urlencoded\s*(?:;.*)?$/i.test(contentType ?? "")) return oauthError(ctx, "invalid_request");
|
|
162686
|
-
const form2 = new URLSearchParams(
|
|
162701
|
+
const form2 = new URLSearchParams(text25), who2 = client(ctx, header3, form2);
|
|
162687
162702
|
if (who2 instanceof Response) return who2;
|
|
162688
162703
|
const value4 = form2.get("token");
|
|
162689
162704
|
if (!value4 || form2.getAll("token").length > 1) return oauthError(ctx, "invalid_request");
|
|
@@ -162691,12 +162706,12 @@ function revoke2(ctx, header3, contentType, text24) {
|
|
|
162691
162706
|
if (row2 && row2.client === who2.id) revokeChain(ctx, row2.chain);
|
|
162692
162707
|
return new Response(null, { status: 200, headers: NO_STORE });
|
|
162693
162708
|
}
|
|
162694
|
-
function oauth2(ctx, method2, url4, path4, headers,
|
|
162709
|
+
function oauth2(ctx, method2, url4, path4, headers, text25) {
|
|
162695
162710
|
const base4 = ctx.serviceUrl ?? url4.origin;
|
|
162696
162711
|
const only4 = (allowed2, run3) => method2 === allowed2 ? withMutation(ctx, run3) : new Response(null, { status: 405, headers: { allow: allowed2 } });
|
|
162697
162712
|
if (path4 === AUTHORIZE_PATH) return only4("GET", () => authorize3(ctx, url4));
|
|
162698
|
-
if (path4 === `${OAUTH2_ROOT}/token`) return only4("POST", () => token3(ctx, base4, headers.authorization, headers.contentType,
|
|
162699
|
-
if (path4 === `${OAUTH2_ROOT}/revoke`) return only4("POST", () => revoke2(ctx, headers.authorization, headers.contentType,
|
|
162713
|
+
if (path4 === `${OAUTH2_ROOT}/token`) return only4("POST", () => token3(ctx, base4, headers.authorization, headers.contentType, text25));
|
|
162714
|
+
if (path4 === `${OAUTH2_ROOT}/revoke`) return only4("POST", () => revoke2(ctx, headers.authorization, headers.contentType, text25));
|
|
162700
162715
|
if (path4 === `${OAUTH2_ROOT}/keys`) return only4("GET", () => json31({ keys: [{ ...createPublicKey3(signingKey(ctx)).export({ format: "jwk" }), kid: KID, use: "sig", alg: "RS256" }] }));
|
|
162701
162716
|
return void 0;
|
|
162702
162717
|
}
|
|
@@ -164883,7 +164898,7 @@ var r = (kind, target5) => ({ kind, ...target5 && { target: target5 } });
|
|
|
164883
164898
|
var w = (kind, more = {}) => ({ kind, write: true, ...more });
|
|
164884
164899
|
var ref21 = (target5, label7) => w("ref", { target: target5, ...label7 && { label: label7 } });
|
|
164885
164900
|
var HOLD = { AUTO: "Auto", ON: "On", OFF: "Off" };
|
|
164886
|
-
var statusOptions = (code2) => Object.fromEntries(Object.entries(STATUS2).filter(([key4]) => key4.startsWith(`${code2}:`)).map(([key4,
|
|
164901
|
+
var statusOptions = (code2) => Object.fromEntries(Object.entries(STATUS2).filter(([key4]) => key4.startsWith(`${code2}:`)).map(([key4, text25]) => [key4.split(":")[1], text25]));
|
|
164887
164902
|
var MONEY = r("number");
|
|
164888
164903
|
var SEGMENTS2 = { department: ref21("department"), location: ref21("location"), class: ref21("classification") };
|
|
164889
164904
|
var DATED = { dateCreated: r("datetime"), lastModifiedDate: r("datetime") };
|
|
@@ -165272,9 +165287,9 @@ var today = (ctx) => ctx.clock.now().toISOString().slice(0, 10);
|
|
|
165272
165287
|
var stamp5 = (ctx) => ctx.clock.now().toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
165273
165288
|
var qty = (value4) => Math.round(value4 * 1e8) / 1e8;
|
|
165274
165289
|
var addDays = (date10, days) => new Date(Date.parse(`${date10}T00:00:00Z`) + days * 864e5).toISOString().slice(0, 10);
|
|
165275
|
-
var json32 = (
|
|
165290
|
+
var json32 = (text25) => {
|
|
165276
165291
|
try {
|
|
165277
|
-
return
|
|
165292
|
+
return text25 ? JSON.parse(text25) : {};
|
|
165278
165293
|
} catch {
|
|
165279
165294
|
return {};
|
|
165280
165295
|
}
|
|
@@ -166136,12 +166151,12 @@ function tokenize8(input5) {
|
|
|
166136
166151
|
}
|
|
166137
166152
|
if (ch === "'" || ch === '"') {
|
|
166138
166153
|
const quote2 = ch;
|
|
166139
|
-
let
|
|
166154
|
+
let text25 = "", closed = false;
|
|
166140
166155
|
i++;
|
|
166141
166156
|
while (i < input5.length) {
|
|
166142
166157
|
if (input5[i] === quote2) {
|
|
166143
166158
|
if (input5[i + 1] === quote2) {
|
|
166144
|
-
|
|
166159
|
+
text25 += quote2;
|
|
166145
166160
|
i += 2;
|
|
166146
166161
|
} else {
|
|
166147
166162
|
i++;
|
|
@@ -166149,12 +166164,12 @@ function tokenize8(input5) {
|
|
|
166149
166164
|
break;
|
|
166150
166165
|
}
|
|
166151
166166
|
} else {
|
|
166152
|
-
|
|
166167
|
+
text25 += input5[i++];
|
|
166153
166168
|
}
|
|
166154
166169
|
}
|
|
166155
166170
|
if (!closed) invalid26("Unterminated quoted value.");
|
|
166156
|
-
if (
|
|
166157
|
-
out.push({ kind: quote2 === "'" ? "string" : "quoted", text:
|
|
166171
|
+
if (text25.includes("\0")) invalid26("Invalid character in quoted value.");
|
|
166172
|
+
out.push({ kind: quote2 === "'" ? "string" : "quoted", text: text25 });
|
|
166158
166173
|
} else {
|
|
166159
166174
|
const tail = input5.slice(i);
|
|
166160
166175
|
const number7 = /^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/.exec(tail);
|
|
@@ -166188,17 +166203,17 @@ var Parser = class {
|
|
|
166188
166203
|
constructor(input5) {
|
|
166189
166204
|
this.tokens = tokenize8(input5);
|
|
166190
166205
|
}
|
|
166191
|
-
peek(
|
|
166206
|
+
peek(text25) {
|
|
166192
166207
|
const t = this.tokens[this.at];
|
|
166193
|
-
return t.kind !== "quoted" && t.kind !== "string" && t.text ===
|
|
166208
|
+
return t.kind !== "quoted" && t.kind !== "string" && t.text === text25;
|
|
166194
166209
|
}
|
|
166195
|
-
eat(
|
|
166196
|
-
if (!this.peek(
|
|
166210
|
+
eat(text25) {
|
|
166211
|
+
if (!this.peek(text25)) return false;
|
|
166197
166212
|
this.at++;
|
|
166198
166213
|
return true;
|
|
166199
166214
|
}
|
|
166200
|
-
need(
|
|
166201
|
-
if (!this.eat(
|
|
166215
|
+
need(text25) {
|
|
166216
|
+
if (!this.eat(text25)) invalid26(`Expected ${text25.toUpperCase()}.`);
|
|
166202
166217
|
}
|
|
166203
166218
|
identifier() {
|
|
166204
166219
|
const t = this.tokens[this.at++];
|
|
@@ -167286,11 +167301,11 @@ function calendar3(y, m, d) {
|
|
|
167286
167301
|
if (y < 1 || y > 9999 || date10.getUTCFullYear() !== y || date10.getUTCMonth() + 1 !== m || date10.getUTCDate() !== d) invalid26("Invalid date value.");
|
|
167287
167302
|
return date10;
|
|
167288
167303
|
}
|
|
167289
|
-
function isoDate(
|
|
167290
|
-
const match3 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(
|
|
167304
|
+
function isoDate(text25) {
|
|
167305
|
+
const match3 = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text25);
|
|
167291
167306
|
if (!match3) invalid26("Expected a YYYY-MM-DD world date.");
|
|
167292
167307
|
calendar3(+match3[1], +match3[2], +match3[3]);
|
|
167293
|
-
return
|
|
167308
|
+
return text25;
|
|
167294
167309
|
}
|
|
167295
167310
|
function dateModel(model) {
|
|
167296
167311
|
if (!model || model.length > 200) invalid26("Invalid date format model.");
|
|
@@ -167341,10 +167356,10 @@ function parseDate2(value4, model) {
|
|
|
167341
167356
|
return tokens3.some((t) => t.startsWith("HH") || ["MI", "SS"].includes(t)) ? date10.toISOString() : date10.toISOString().slice(0, 10);
|
|
167342
167357
|
}
|
|
167343
167358
|
function readDate(value4) {
|
|
167344
|
-
const
|
|
167345
|
-
if (!/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/.test(
|
|
167346
|
-
isoDate(
|
|
167347
|
-
const date10 = new Date(
|
|
167359
|
+
const text25 = String(value4);
|
|
167360
|
+
if (!/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/.test(text25)) invalid26("Invalid date value.");
|
|
167361
|
+
isoDate(text25.slice(0, 10));
|
|
167362
|
+
const date10 = new Date(text25.length === 10 ? `${text25}T00:00:00Z` : /(?:Z|[+-]\d{2}:\d{2})$/.test(text25) ? text25 : `${text25}Z`);
|
|
167348
167363
|
if (!Number.isFinite(date10.getTime())) invalid26("Invalid date value.");
|
|
167349
167364
|
return date10;
|
|
167350
167365
|
}
|
|
@@ -167438,11 +167453,11 @@ function like(value4, pattern, ...escape11) {
|
|
|
167438
167453
|
mask2.push({ char: next2 });
|
|
167439
167454
|
} else mask2.push(chars[k] === "%" ? { any: true } : chars[k] === "_" ? { one: true } : { char: chars[k] });
|
|
167440
167455
|
}
|
|
167441
|
-
const
|
|
167456
|
+
const text25 = Array.from(String(value4));
|
|
167442
167457
|
let i = 0, j = 0, percent = -1, retry = 0;
|
|
167443
|
-
while (i <
|
|
167458
|
+
while (i < text25.length) {
|
|
167444
167459
|
const m = mask2[j];
|
|
167445
|
-
if (m && ("one" in m || "char" in m && m.char ===
|
|
167460
|
+
if (m && ("one" in m || "char" in m && m.char === text25[i])) {
|
|
167446
167461
|
i++;
|
|
167447
167462
|
j++;
|
|
167448
167463
|
} else if (m && "any" in m) {
|
|
@@ -168244,11 +168259,11 @@ function parseQuery3(q) {
|
|
|
168244
168259
|
return node5;
|
|
168245
168260
|
}
|
|
168246
168261
|
function day7(value4) {
|
|
168247
|
-
const
|
|
168248
|
-
const iso22 = us ? `${us[3]}-${us[1].padStart(2, "0")}-${us[2].padStart(2, "0")}` :
|
|
168262
|
+
const text25 = String(value4), us = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(text25);
|
|
168263
|
+
const iso22 = us ? `${us[3]}-${us[1].padStart(2, "0")}-${us[2].padStart(2, "0")}` : text25;
|
|
168249
168264
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(iso22) || (/* @__PURE__ */ new Date(`${iso22}T00:00:00Z`)).toISOString().slice(0, 10) !== iso22) {
|
|
168250
|
-
if (/^[a-z]+$/i.test(
|
|
168251
|
-
throw bad2(`${
|
|
168265
|
+
if (/^[a-z]+$/i.test(text25)) throw gap6(`relative date ${text25} in q`);
|
|
168266
|
+
throw bad2(`${text25} is not a date; use M/D/YYYY.`);
|
|
168252
168267
|
}
|
|
168253
168268
|
return iso22;
|
|
168254
168269
|
}
|
|
@@ -169199,10 +169214,10 @@ function reportList(ctx) {
|
|
|
169199
169214
|
});
|
|
169200
169215
|
}
|
|
169201
169216
|
function day8(value4, name5) {
|
|
169202
|
-
const
|
|
169217
|
+
const text25 = typeof value4 === "string" ? value4.trim() : "";
|
|
169203
169218
|
let iso22;
|
|
169204
|
-
const us = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(
|
|
169205
|
-
if (/^\d{4}-\d{2}-\d{2}$/.test(
|
|
169219
|
+
const us = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(text25);
|
|
169220
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(text25)) iso22 = text25;
|
|
169206
169221
|
else if (us) iso22 = `${us[3]}-${us[1].padStart(2, "0")}-${us[2].padStart(2, "0")}`;
|
|
169207
169222
|
if (!iso22 || Number.isNaN(Date.parse(`${iso22}T00:00:00Z`)) || (/* @__PURE__ */ new Date(`${iso22}T00:00:00Z`)).toISOString().slice(0, 10) !== iso22) {
|
|
169208
169223
|
throw new ToolError("INVALID_PARAMETER", `${name5} must be a date such as 2026-01-31 or 1/31/2026.`);
|
|
@@ -169255,7 +169270,7 @@ function runReport(ctx, args) {
|
|
|
169255
169270
|
|
|
169256
169271
|
// packages/server/src/twins/netsuite/searches.ts
|
|
169257
169272
|
var f = (sql5, kind = "text") => ({ sql: sql5, kind });
|
|
169258
|
-
var select3 = (sql5,
|
|
169273
|
+
var select3 = (sql5, text25 = `BUILTIN.DF(${sql5})`) => ({ sql: sql5, kind: "select", text: text25 });
|
|
169259
169274
|
var entity2 = (a) => ({
|
|
169260
169275
|
internalid: select3(`${a}.id`, `${a}.id`),
|
|
169261
169276
|
entityid: f(`${a}.entityid`),
|
|
@@ -169522,13 +169537,13 @@ function field4(ctx, type, name5, error64, plan4, formula) {
|
|
|
169522
169537
|
var iso20 = (d) => d.toISOString().slice(0, 10);
|
|
169523
169538
|
var at2 = (y, m, d) => new Date(Date.UTC(y, m, d));
|
|
169524
169539
|
function dateRange(ctx, value4) {
|
|
169525
|
-
const
|
|
169540
|
+
const text25 = String(value4 ?? "").trim().toLowerCase(), now11 = /* @__PURE__ */ new Date(`${today(ctx)}T00:00:00Z`);
|
|
169526
169541
|
const y = now11.getUTCFullYear(), m = now11.getUTCMonth(), d = now11.getUTCDate(), dow = now11.getUTCDay(), q = Math.floor(m / 3) * 3;
|
|
169527
169542
|
const one7 = (date10) => [iso20(date10), iso20(date10)];
|
|
169528
|
-
const us = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(
|
|
169543
|
+
const us = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(text25);
|
|
169529
169544
|
if (us) return one7(at2(Number(us[3]), Number(us[1]) - 1, Number(us[2])));
|
|
169530
|
-
if (/^\d{4}-\d{2}-\d{2}$/.test(
|
|
169531
|
-
const ago = /^(days|weeks|months|quarters|years)(ago|fromnow)(\d{1,4})$/.exec(
|
|
169545
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(text25)) return [text25, text25];
|
|
169546
|
+
const ago = /^(days|weeks|months|quarters|years)(ago|fromnow)(\d{1,4})$/.exec(text25);
|
|
169532
169547
|
if (ago) {
|
|
169533
169548
|
const n2 = Number(ago[3]) * (ago[2] === "ago" ? -1 : 1);
|
|
169534
169549
|
if (ago[1] === "days") return one7(at2(y, m, d + n2));
|
|
@@ -169559,7 +169574,7 @@ function dateRange(ctx, value4) {
|
|
|
169559
169574
|
ranges2.thisfiscalyear = ranges2.thisyear;
|
|
169560
169575
|
ranges2.lastfiscalyear = ranges2.lastyear;
|
|
169561
169576
|
ranges2.thisfiscalyeartodate = ranges2.thisyeartodate;
|
|
169562
|
-
const range2 = ranges2[
|
|
169577
|
+
const range2 = ranges2[text25];
|
|
169563
169578
|
if (!range2) throw new ToolError("SSS_INVALID_SRCH_FILTER", `An nlobjSearchFilter contains an invalid date value: ${String(value4)}.`);
|
|
169564
169579
|
return [iso20(range2[0]), iso20(range2[1])];
|
|
169565
169580
|
}
|
|
@@ -169756,8 +169771,8 @@ async function runSearch(ctx, args) {
|
|
|
169756
169771
|
return;
|
|
169757
169772
|
}
|
|
169758
169773
|
if (c.def.kind === "select") {
|
|
169759
|
-
const
|
|
169760
|
-
values2[key5] = value4 === void 0 ? [] : [{ value: value4, text:
|
|
169774
|
+
const text25 = c.name === "type" && search10.type === "transaction" ? TYPE_NAMES[value4 ?? ""] : c.name === "status" ? STATUS2[value4 ?? ""] : row2[`c${index}t`] ?? value4;
|
|
169775
|
+
values2[key5] = value4 === void 0 ? [] : [{ value: value4, text: text25 ?? value4 }];
|
|
169761
169776
|
} else if (c.def.kind === "checkbox") values2[key5] = value4 === "T";
|
|
169762
169777
|
else if (c.def.kind === "currency") values2[key5] = money13(value4);
|
|
169763
169778
|
else values2[key5] = value4 ?? "";
|
|
@@ -169790,11 +169805,11 @@ function typeNamed(name5) {
|
|
|
169790
169805
|
}
|
|
169791
169806
|
var recordNamed = (ctx, name5) => withRead(ctx, () => plainType(ctx, String(name5).trim())) ?? typeNamed(name5);
|
|
169792
169807
|
var invalid28 = (message7) => new ToolError("INVALID_PARAMETER", message7);
|
|
169793
|
-
function jsonObject(
|
|
169794
|
-
if (
|
|
169808
|
+
function jsonObject(text25, name5) {
|
|
169809
|
+
if (text25 === void 0 || text25 === null || typeof text25 === "string" && text25.trim() === "") return {};
|
|
169795
169810
|
let value4;
|
|
169796
169811
|
try {
|
|
169797
|
-
value4 = JSON.parse(String(
|
|
169812
|
+
value4 = JSON.parse(String(text25));
|
|
169798
169813
|
} catch {
|
|
169799
169814
|
value4 = void 0;
|
|
169800
169815
|
}
|
|
@@ -170027,7 +170042,7 @@ var MCP_TOOLS = [
|
|
|
170027
170042
|
targetRecordTypeFilter: s("A comma-separated list of target record types, for example invoice,itemfulfillment. Matching is case-insensitive.").optional()
|
|
170028
170043
|
}),
|
|
170029
170044
|
run: (_ctx, a) => {
|
|
170030
|
-
const list16 = (
|
|
170045
|
+
const list16 = (text25) => text25?.split(",").map((t) => t.trim().toLowerCase()).filter(Boolean);
|
|
170031
170046
|
const sources = list16(a.sourceRecordTypeFilter), targets = list16(a.targetRecordTypeFilter);
|
|
170032
170047
|
const pairs = netsuiteRecordTypes.flatMap((source) => transformTargets(source).map((target5) => ({ sourceRecordType: source.toLowerCase(), targetRecordType: target5.toLowerCase() })));
|
|
170033
170048
|
pairs.push(...["cashsale", "estimate", "invoice", "salesorder"].map((targetRecordType) => ({ sourceRecordType: "opportunity", targetRecordType })));
|
|
@@ -170335,7 +170350,7 @@ var rpcError = (id14, code2, message7, status4 = 200) => ({
|
|
|
170335
170350
|
headers: { "content-type": "application/json" },
|
|
170336
170351
|
body: JSON.stringify({ jsonrpc: "2.0", id: id14 ?? null, error: { code: code2, message: message7 } })
|
|
170337
170352
|
});
|
|
170338
|
-
async function mcpEndpoint(ctx, method2,
|
|
170353
|
+
async function mcpEndpoint(ctx, method2, text25, base4, serve3, caller2, headers = {}) {
|
|
170339
170354
|
if (headers.origin !== void 0 && headers.origin !== new URL(base4).origin) return rpcError(null, -32600, "Invalid Origin", 403);
|
|
170340
170355
|
if (headers.protocolVersion !== void 0 && !PROTOCOLS.includes(headers.protocolVersion)) return rpcError(null, -32600, "Invalid MCP-Protocol-Version", 400);
|
|
170341
170356
|
if (method2 !== "POST") return { status: 405, headers: { allow: "POST", "content-type": "application/json" }, body: JSON.stringify({
|
|
@@ -170345,7 +170360,7 @@ async function mcpEndpoint(ctx, method2, text24, base4, serve3, caller2, headers
|
|
|
170345
170360
|
}) };
|
|
170346
170361
|
let message7;
|
|
170347
170362
|
try {
|
|
170348
|
-
message7 = JSON.parse(
|
|
170363
|
+
message7 = JSON.parse(text25);
|
|
170349
170364
|
} catch {
|
|
170350
170365
|
return rpcError(null, -32700, "Parse error", 400);
|
|
170351
170366
|
}
|
|
@@ -170531,7 +170546,7 @@ function runJob(ctx, serve3, job) {
|
|
|
170531
170546
|
return true;
|
|
170532
170547
|
}
|
|
170533
170548
|
var progress = (tasks) => tasks.some((t) => t.completed === null) ? "pending" : tasks.some((t) => (t.status ?? 0) >= 400) ? "failed" : "succeeded";
|
|
170534
|
-
var local = (
|
|
170549
|
+
var local = (text25, base4) => text25.split(ORIGIN).join(base4);
|
|
170535
170550
|
function readJob(ctx, base4, method2, segments3) {
|
|
170536
170551
|
if (method2 !== "GET") throw gap6(`${method2} on an asynchronous job`);
|
|
170537
170552
|
const [kind, jobKey, part, taskKey, leaf] = segments3;
|
|
@@ -171514,7 +171529,7 @@ function bearerError(ctx, kind) {
|
|
|
171514
171529
|
error64.headers["www-authenticate"] = `Bearer realm="${config10(ctx).account.id}", error="${kind}", error_description="${kind === "invalid_token" ? "Invalid login attempt." : "The request could not be understood by the server due to malformed syntax."}"`;
|
|
171515
171530
|
return error64;
|
|
171516
171531
|
}
|
|
171517
|
-
function authenticate16(ctx, c, url4,
|
|
171532
|
+
function authenticate16(ctx, c, url4, text25, nonceSeen) {
|
|
171518
171533
|
const saved = ctx.store.meta.get("netsuite.credentials"), header3 = c.req.header("authorization") ?? "";
|
|
171519
171534
|
if (!saved) throw badLogin();
|
|
171520
171535
|
const creds = JSON.parse(saved);
|
|
@@ -171526,7 +171541,7 @@ function authenticate16(ctx, c, url4, text24, nonceSeen) {
|
|
|
171526
171541
|
}
|
|
171527
171542
|
const clocksMs = [Date.now(), ctx.clock.nowMs()];
|
|
171528
171543
|
const check3 = checkTba(
|
|
171529
|
-
{ method: c.req.method, url: `${ctx.serviceUrl ?? url4.origin}${url4.pathname}${url4.search}`, contentType: c.req.header("content-type"), body:
|
|
171544
|
+
{ method: c.req.method, url: `${ctx.serviceUrl ?? url4.origin}${url4.pathname}${url4.search}`, contentType: c.req.header("content-type"), body: text25, authorization: header3 },
|
|
171530
171545
|
creds,
|
|
171531
171546
|
{ nonceSeen: (nonce, timestamp4) => nonceSeen(nonce, timestamp4, clocksMs), nowMs: clocksMs }
|
|
171532
171547
|
);
|
|
@@ -171581,7 +171596,7 @@ var failure4 = (error64) => ({
|
|
|
171581
171596
|
});
|
|
171582
171597
|
var BATCH = /;\s*type\s*=\s*"?collection"?/i;
|
|
171583
171598
|
function serve(ctx, request) {
|
|
171584
|
-
const { method: method2, url: url4, text:
|
|
171599
|
+
const { method: method2, url: url4, text: text25 } = request, path4 = url4.pathname.replace(/\/+$/, "");
|
|
171585
171600
|
try {
|
|
171586
171601
|
const validation2 = (name5) => {
|
|
171587
171602
|
const value4 = (request.header(name5) ?? "warning").toLowerCase();
|
|
@@ -171594,12 +171609,12 @@ function serve(ctx, request) {
|
|
|
171594
171609
|
throw new NetsuiteError(400, "INVALID_REQUEST", "A batch request runs asynchronously. Send it with the header Prefer: respond-async.", { header: "Prefer" });
|
|
171595
171610
|
}
|
|
171596
171611
|
let body6;
|
|
171597
|
-
if (
|
|
171612
|
+
if (text25.trim() !== "") {
|
|
171598
171613
|
if (!JSON_BODY.test(request.header("content-type") ?? "application/json")) {
|
|
171599
171614
|
throw new NetsuiteError(415, "INVALID_CONTENT", "Invalid content type. Send the request body as application/json or application/vnd.oracle.resource+json.", { header: "Content-Type" });
|
|
171600
171615
|
}
|
|
171601
171616
|
try {
|
|
171602
|
-
body6 = JSON.parse(
|
|
171617
|
+
body6 = JSON.parse(text25);
|
|
171603
171618
|
} catch {
|
|
171604
171619
|
throw new NetsuiteError(400, "INVALID_CONTENT", "The request body is not valid JSON.");
|
|
171605
171620
|
}
|
|
@@ -171639,18 +171654,18 @@ function netsuiteTwin(nonces = new TbaNonceCache(), poolOptions = {}) {
|
|
|
171639
171654
|
const ctx = c.env.ctx, url4 = new URL(c.req.url), method2 = c.req.method;
|
|
171640
171655
|
const send2 = (served) => new Response(served.body, { status: served.status, headers: served.headers });
|
|
171641
171656
|
try {
|
|
171642
|
-
const
|
|
171657
|
+
const text25 = method2 === "GET" || method2 === "DELETE" || method2 === "HEAD" ? "" : await c.req.text();
|
|
171643
171658
|
ctx.signal?.throwIfAborted();
|
|
171644
|
-
if (
|
|
171659
|
+
if (text25.length > 104e6) throw new NetsuiteError(413, "REQUEST_TOO_LARGE", "The request body exceeds 104 MB.");
|
|
171645
171660
|
const path4 = url4.pathname.replace(/\/+$/, "");
|
|
171646
|
-
const issued = oauth2(ctx, method2, url4, path4, { authorization: c.req.header("authorization"), contentType: c.req.header("content-type") },
|
|
171661
|
+
const issued = oauth2(ctx, method2, url4, path4, { authorization: c.req.header("authorization"), contentType: c.req.header("content-type") }, text25);
|
|
171647
171662
|
if (issued) return issued;
|
|
171648
171663
|
if (MCP_PATHS.includes(path4)) {
|
|
171649
171664
|
const caller2 = withRead(ctx, () => mcpCaller(ctx, c.req.header("authorization") ?? ""));
|
|
171650
|
-
return send2(await mcpEndpoint(ctx, method2,
|
|
171665
|
+
return send2(await mcpEndpoint(ctx, method2, text25, ctx.serviceUrl ?? url4.origin, serve, caller2, { origin: c.req.header("origin"), protocolVersion: c.req.header("mcp-protocol-version") }));
|
|
171651
171666
|
}
|
|
171652
|
-
withRead(ctx, () => authenticate16(ctx, c, url4,
|
|
171653
|
-
const request = { method: method2, url: url4, header: (name5) => c.req.header(name5), text:
|
|
171667
|
+
withRead(ctx, () => authenticate16(ctx, c, url4, text25, (nonce, timestamp4, clocksMs) => nonces.seen(ctx.store, nonce, timestamp4, clocksMs)));
|
|
171668
|
+
const request = { method: method2, url: url4, header: (name5) => c.req.header(name5), text: text25 };
|
|
171654
171669
|
if (wantsAsync(c.req.header("prefer")) && !path4.startsWith(`${ASYNC_ROOT}/`)) return send2(submit(ctx, ctx.serviceUrl ?? url4.origin, request));
|
|
171655
171670
|
return send2(await serve(ctx, request));
|
|
171656
171671
|
} catch (error64) {
|
|
@@ -172524,11 +172539,11 @@ function slackName(env, id14) {
|
|
|
172524
172539
|
const row2 = env.store.db.prepare("SELECT COALESCE(real_name, name) AS name FROM slack_users WHERE id = ?").get(id14);
|
|
172525
172540
|
return row2?.name ?? id14;
|
|
172526
172541
|
}
|
|
172527
|
-
function slackText(env,
|
|
172528
|
-
return
|
|
172542
|
+
function slackText(env, text25) {
|
|
172543
|
+
return text25.replace(/<@([A-Z0-9]+)(?:\|[^>]*)?>/g, (_match, id14) => `@${slackName(env, id14)}`);
|
|
172529
172544
|
}
|
|
172530
|
-
var oneLine3 = (
|
|
172531
|
-
const flat2 =
|
|
172545
|
+
var oneLine3 = (text25) => {
|
|
172546
|
+
const flat2 = text25.replace(/\s+/g, " ").trim();
|
|
172532
172547
|
return flat2.length > LINE_LIMIT ? `${flat2.slice(0, LINE_LIMIT - 1)}\u2026` : flat2;
|
|
172533
172548
|
};
|
|
172534
172549
|
function addressedEvent(env, event3) {
|
|
@@ -173124,10 +173139,10 @@ function sessionRoutes(opts, sessions) {
|
|
|
173124
173139
|
return c.json(await sessions.prepare(opts.manager.get(c.req.param("id")), parseOptions(input5.options)), 201);
|
|
173125
173140
|
});
|
|
173126
173141
|
app2.post("/envs/:id/trials/:sid/start", async (c) => {
|
|
173127
|
-
const
|
|
173142
|
+
const text25 = await c.req.text();
|
|
173128
173143
|
let input5 = {};
|
|
173129
173144
|
try {
|
|
173130
|
-
if (
|
|
173145
|
+
if (text25) input5 = JSON.parse(text25);
|
|
173131
173146
|
} catch {
|
|
173132
173147
|
throw new AnchaError("USAGE", "request must be a JSON object");
|
|
173133
173148
|
}
|
|
@@ -173309,11 +173324,11 @@ function controlRoutes(opts) {
|
|
|
173309
173324
|
return c.json(env.world.read(() => Object.fromEntries(env.twins.map((twin) => [twin.name, twin.dumpState(env.ctxFor(twin.name))]))));
|
|
173310
173325
|
});
|
|
173311
173326
|
control.post("/envs/:id/checks", async (c) => {
|
|
173312
|
-
const
|
|
173327
|
+
const text25 = await c.req.text();
|
|
173313
173328
|
let payload2 = {};
|
|
173314
|
-
if (
|
|
173329
|
+
if (text25.trim() !== "") {
|
|
173315
173330
|
try {
|
|
173316
|
-
payload2 = JSON.parse(
|
|
173331
|
+
payload2 = JSON.parse(text25);
|
|
173317
173332
|
} catch {
|
|
173318
173333
|
throw new AnchaError("USAGE", "request body must be JSON", { hint: `POST { "checks"?: [ \u2026 ] } with content-type: application/json, or an empty body to run the scene's checks` });
|
|
173319
173334
|
}
|
|
@@ -173383,15 +173398,15 @@ function errorResponse20(c, e) {
|
|
|
173383
173398
|
if (!(e instanceof AnchaError)) console.error(e);
|
|
173384
173399
|
return c.json({ error: toErrorJson(e) }, status4);
|
|
173385
173400
|
}
|
|
173386
|
-
function parseBody2(
|
|
173387
|
-
if (
|
|
173401
|
+
function parseBody2(text25, contentType) {
|
|
173402
|
+
if (text25 === "") return void 0;
|
|
173388
173403
|
if (contentType?.split(";")[0].trim().toLowerCase() === "application/x-www-form-urlencoded") {
|
|
173389
|
-
return Object.fromEntries(new URLSearchParams(
|
|
173404
|
+
return Object.fromEntries(new URLSearchParams(text25));
|
|
173390
173405
|
}
|
|
173391
173406
|
try {
|
|
173392
|
-
return JSON.parse(
|
|
173407
|
+
return JSON.parse(text25);
|
|
173393
173408
|
} catch {
|
|
173394
|
-
return
|
|
173409
|
+
return text25;
|
|
173395
173410
|
}
|
|
173396
173411
|
}
|
|
173397
173412
|
function bearerToken(c, url4) {
|
|
@@ -174501,8 +174516,8 @@ var fact = external_exports.preprocess((value4) => {
|
|
|
174501
174516
|
confidential: external_exports.boolean()
|
|
174502
174517
|
}));
|
|
174503
174518
|
var optionId = (value4) => {
|
|
174504
|
-
const
|
|
174505
|
-
return typeof
|
|
174519
|
+
const text25 = typeof value4 === "string" ? value4 : value4 && typeof value4 === "object" ? value4.id ?? value4.name ?? value4.value : value4;
|
|
174520
|
+
return typeof text25 === "string" ? text25.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") : text25;
|
|
174506
174521
|
};
|
|
174507
174522
|
var decision = external_exports.object({
|
|
174508
174523
|
id: external_exports.string().regex(/^[a-z][a-z0-9_]{0,40}$/),
|