@lotics/app-sdk 0.128.2 → 0.128.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +82 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7694,6 +7694,37 @@ var HELPER_COST = {
|
|
|
7694
7694
|
typeof: "reads",
|
|
7695
7695
|
in: "reads"
|
|
7696
7696
|
};
|
|
7697
|
+
var ELEMENT_DRIVEN_BUILDERS = /* @__PURE__ */ new Set([
|
|
7698
|
+
"filter",
|
|
7699
|
+
"pluck",
|
|
7700
|
+
"sortBy",
|
|
7701
|
+
"sort",
|
|
7702
|
+
"groupBy",
|
|
7703
|
+
"countBy",
|
|
7704
|
+
"unique",
|
|
7705
|
+
"uniqueBy",
|
|
7706
|
+
"compact",
|
|
7707
|
+
"flatten",
|
|
7708
|
+
"flat",
|
|
7709
|
+
"flatMap",
|
|
7710
|
+
"reverse",
|
|
7711
|
+
"slice",
|
|
7712
|
+
"difference",
|
|
7713
|
+
"differenceBy",
|
|
7714
|
+
"intersection",
|
|
7715
|
+
"intersectionBy",
|
|
7716
|
+
"concat",
|
|
7717
|
+
"list",
|
|
7718
|
+
"keys",
|
|
7719
|
+
"values",
|
|
7720
|
+
"pick",
|
|
7721
|
+
"omit",
|
|
7722
|
+
"merge",
|
|
7723
|
+
"nonNullKeys"
|
|
7724
|
+
]);
|
|
7725
|
+
function countsHeldByReference(name, cost) {
|
|
7726
|
+
return cost === "reads" || ELEMENT_DRIVEN_BUILDERS.has(name);
|
|
7727
|
+
}
|
|
7697
7728
|
function helperCost(name) {
|
|
7698
7729
|
return HELPER_COST_BY_NAME.get(name) ?? "builds";
|
|
7699
7730
|
}
|
|
@@ -8967,7 +8998,7 @@ function numberTextLength(value) {
|
|
|
8967
8998
|
for (let rest = Math.abs(value); rest >= 10; rest = Math.floor(rest / 10)) length2 += 1;
|
|
8968
8999
|
return length2;
|
|
8969
9000
|
}
|
|
8970
|
-
function expandedSize(value, max3) {
|
|
9001
|
+
function expandedSize(value, max3, held2, counted = /* @__PURE__ */ new Set()) {
|
|
8971
9002
|
let bytes = 0;
|
|
8972
9003
|
const pending = [value];
|
|
8973
9004
|
while (pending.length > 0 && bytes <= max3) {
|
|
@@ -8977,12 +9008,16 @@ function expandedSize(value, max3) {
|
|
|
8977
9008
|
else if (typeof member === "boolean") bytes += (member ? 4 : 5) * CHAR_BYTES;
|
|
8978
9009
|
else if (typeof member === "bigint") bytes += String(member).length * CHAR_BYTES;
|
|
8979
9010
|
else if (typeof member !== "object" || member === null) continue;
|
|
9011
|
+
else if (held2?.has(member) === true && !counted.has(member)) {
|
|
9012
|
+
counted.add(member);
|
|
9013
|
+
bytes += referenceBytes(member, member === value);
|
|
9014
|
+
} else if (counted.has(member)) bytes += expandedSize(member, max3 - bytes);
|
|
8980
9015
|
else if (member instanceof Map) {
|
|
8981
9016
|
bytes += OBJECT_BYTES + member.size * 2 * SLOT_BYTES;
|
|
8982
|
-
if (bytes <= max3) for (const [key,
|
|
9017
|
+
if (bytes <= max3) for (const [key, held3] of member) pending.push(key, held3);
|
|
8983
9018
|
} else if (member instanceof Set) {
|
|
8984
9019
|
bytes += OBJECT_BYTES + member.size * SLOT_BYTES;
|
|
8985
|
-
if (bytes <= max3) for (const
|
|
9020
|
+
if (bytes <= max3) for (const held3 of member) pending.push(held3);
|
|
8986
9021
|
} else if (Array.isArray(member)) {
|
|
8987
9022
|
bytes += OBJECT_BYTES + member.length * SLOT_BYTES;
|
|
8988
9023
|
if (bytes <= max3) for (let at2 = 0; at2 < member.length; at2++) pending.push(member[at2]);
|
|
@@ -9002,14 +9037,50 @@ function expandedSize(value, max3) {
|
|
|
9002
9037
|
}
|
|
9003
9038
|
return bytes;
|
|
9004
9039
|
}
|
|
9040
|
+
function referenceBytes(held2, atRoot) {
|
|
9041
|
+
if (held2 instanceof Map) return held2.size * 2 * SLOT_BYTES;
|
|
9042
|
+
if (held2 instanceof Set) return held2.size * SLOT_BYTES;
|
|
9043
|
+
if (Array.isArray(held2)) return held2.length * SLOT_BYTES;
|
|
9044
|
+
return (atRoot ? Object.keys(held2).length : 1) * SLOT_BYTES;
|
|
9045
|
+
}
|
|
9046
|
+
var heldByRun = /* @__PURE__ */ new WeakMap();
|
|
9047
|
+
function heldValuesOf(results) {
|
|
9048
|
+
const known = heldByRun.get(results);
|
|
9049
|
+
if (known !== void 0) return known;
|
|
9050
|
+
const made = /* @__PURE__ */ new WeakSet();
|
|
9051
|
+
heldByRun.set(results, made);
|
|
9052
|
+
return made;
|
|
9053
|
+
}
|
|
9054
|
+
function holdValue(results, value) {
|
|
9055
|
+
const held2 = heldValuesOf(results);
|
|
9056
|
+
const pending = [value];
|
|
9057
|
+
while (pending.length > 0) {
|
|
9058
|
+
const member = pending.pop();
|
|
9059
|
+
if (typeof member !== "object" || member === null || held2.has(member)) continue;
|
|
9060
|
+
held2.add(member);
|
|
9061
|
+
if (member instanceof Map) {
|
|
9062
|
+
for (const [key, entry] of member) pending.push(key, entry);
|
|
9063
|
+
} else if (member instanceof Set) {
|
|
9064
|
+
for (const entry of member) pending.push(entry);
|
|
9065
|
+
} else if (Array.isArray(member)) {
|
|
9066
|
+
for (let at2 = 0; at2 < member.length; at2++) pending.push(member[at2]);
|
|
9067
|
+
} else {
|
|
9068
|
+
for (const key of Object.keys(member)) {
|
|
9069
|
+
const stored = Reflect.getOwnPropertyDescriptor(member, key);
|
|
9070
|
+
if (stored !== void 0 && "value" in stored) pending.push(stored.value);
|
|
9071
|
+
}
|
|
9072
|
+
}
|
|
9073
|
+
}
|
|
9074
|
+
}
|
|
9005
9075
|
var ownKeyBytes = /* @__PURE__ */ new WeakMap();
|
|
9006
9076
|
var OBJECT_TEXT_LENGTH = 64;
|
|
9007
|
-
function writtenSize(value, max3) {
|
|
9077
|
+
function writtenSize(value, max3, held2) {
|
|
9008
9078
|
let bytes = 0;
|
|
9009
9079
|
const pending = [value];
|
|
9010
9080
|
while (pending.length > 0 && bytes <= max3) {
|
|
9011
9081
|
const member = pending.pop();
|
|
9012
|
-
if (typeof member === "
|
|
9082
|
+
if (typeof member === "object" && member !== null && held2?.has(member) === true) bytes += referenceBytes(member, member === value);
|
|
9083
|
+
else if (typeof member === "string") bytes += member.length * CHAR_BYTES;
|
|
9013
9084
|
else if (typeof member === "number") bytes += numberTextLength(member) * CHAR_BYTES;
|
|
9014
9085
|
else if (typeof member === "boolean") bytes += (member ? 4 : 5) * CHAR_BYTES;
|
|
9015
9086
|
else if (typeof member === "bigint") bytes += String(member).length * CHAR_BYTES;
|
|
@@ -9066,9 +9137,11 @@ function callbackWorkers() {
|
|
|
9066
9137
|
};
|
|
9067
9138
|
}
|
|
9068
9139
|
function evaluateWorkflowExpression(expr2, ctx, options = {}) {
|
|
9140
|
+
holdValue(ctx.step_outputs, [ctx.trigger, ctx.trigger_record, ctx.trigger_record_prev, ctx.trigger_changes]);
|
|
9069
9141
|
const budget = {
|
|
9070
9142
|
workers: callbackWorkers(),
|
|
9071
9143
|
bounded: options.bounded === true,
|
|
9144
|
+
held: heldValuesOf(ctx.step_outputs),
|
|
9072
9145
|
built: 0,
|
|
9073
9146
|
clock_checks: 0,
|
|
9074
9147
|
nodes: 0,
|
|
@@ -9082,7 +9155,7 @@ function evaluateWorkflowExpression(expr2, ctx, options = {}) {
|
|
|
9082
9155
|
budget.settled = true;
|
|
9083
9156
|
options.onNodes?.(budget.nodes);
|
|
9084
9157
|
}).then((answer) => {
|
|
9085
|
-
if (budget.bounded && expandedSize(answer, MAX_IN_PLACE_BYTES) > MAX_IN_PLACE_BYTES) throw new ExpressionNotCheapError();
|
|
9158
|
+
if (budget.bounded && expandedSize(answer, MAX_IN_PLACE_BYTES, budget.held) > MAX_IN_PLACE_BYTES) throw new ExpressionNotCheapError();
|
|
9086
9159
|
return answer;
|
|
9087
9160
|
}).catch((error) => {
|
|
9088
9161
|
if (budget.bounded && ctx.run_budget.host === "shared") ctx.run_budget.built_bytes -= budget.built;
|
|
@@ -9730,7 +9803,9 @@ async function callAfter(helper, pending, ctx) {
|
|
|
9730
9803
|
return callHelper(helper, values2, ctx);
|
|
9731
9804
|
}
|
|
9732
9805
|
function callHelper({ fn, call, cost }, values2, ctx) {
|
|
9733
|
-
|
|
9806
|
+
const counted = /* @__PURE__ */ new Set();
|
|
9807
|
+
const held2 = countsHeldByReference(fn, cost) ? ctx.evaluation_budget.held : void 0;
|
|
9808
|
+
assertWithin(ctx.evaluation_budget, MAX_IN_PLACE_HELPER_BYTES, values2, cost === "reads" ? (value, max3) => writtenSize(value, max3, held2) : (value, max3) => expandedSize(value, max3, held2, counted));
|
|
9734
9809
|
if (cost === "parses") charge(ctx, parsedSize(values2[0]));
|
|
9735
9810
|
let answer;
|
|
9736
9811
|
try {
|
package/package.json
CHANGED