@lotics/app-sdk 0.134.1 → 0.134.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.
@@ -1263,7 +1263,10 @@ var AGGREGATE_COUNT_COLUMN = "__count";
1263
1263
  var AGGREGATE_SUM_COLUMN = "__sum";
1264
1264
  var AGGREGATE_AVG_COLUMN = "__avg";
1265
1265
  var AGGREGATE_DAY_COLUMN = "__day";
1266
- function dayOf(cell) {
1266
+ var AGGREGATE_MAX_COLUMN = "__max";
1267
+ var AGGREGATE_MIN_COLUMN = "__min";
1268
+ function dayOf(cell, hour) {
1269
+ if (hour) return typeof cell === "string" && cell.length >= 13 ? `${cell.slice(0, 10)}T${cell.slice(11, 13)}:00` : null;
1267
1270
  return typeof cell === "string" && cell !== "" ? cell.slice(0, 10) : null;
1268
1271
  }
1269
1272
  function aggregateRows(rows, aggregate) {
@@ -1271,6 +1274,10 @@ function aggregateRows(rows, aggregate) {
1271
1274
  const day = aggregate.day;
1272
1275
  const sum = aggregate.sum;
1273
1276
  const avg = aggregate.avg;
1277
+ const extremes = (column, members, pick) => {
1278
+ const held = column === void 0 ? [] : members.flatMap((member) => typeof member[column] === "number" ? [member[column]] : []);
1279
+ return held.length === 0 ? null : held.reduce((a, b) => pick(a, b));
1280
+ };
1274
1281
  const keyOf = (row, column) => {
1275
1282
  const tiers = aggregate.bands?.[column];
1276
1283
  const cell = row[column] ?? null;
@@ -1280,7 +1287,7 @@ function aggregateRows(rows, aggregate) {
1280
1287
  const keyed = /* @__PURE__ */ new Map();
1281
1288
  for (const row of rows) {
1282
1289
  const keys = by.map((column) => keyOf(row, column));
1283
- const key = JSON.stringify([...keys, ...day === void 0 ? [] : [dayOf(row[day])]]);
1290
+ const key = JSON.stringify([...keys, ...day === void 0 ? [] : [dayOf(row[day], aggregate.hour === true)]]);
1284
1291
  keyed.set(key, { keys, members: [...keyed.get(key)?.members ?? [], row] });
1285
1292
  }
1286
1293
  return [...keyed.values()].map(({ keys, members }) => {
@@ -1293,10 +1300,12 @@ function aggregateRows(rows, aggregate) {
1293
1300
  return {
1294
1301
  [RECORD_ID_COLUMN]: null,
1295
1302
  ...Object.fromEntries(by.map((column, at) => [column, keys[at] ?? null])),
1296
- ...day === void 0 ? {} : { [AGGREGATE_DAY_COLUMN]: dayOf(first2?.[day]) },
1303
+ ...day === void 0 ? {} : { [AGGREGATE_DAY_COLUMN]: dayOf(first2?.[day], aggregate.hour === true) },
1297
1304
  [AGGREGATE_COUNT_COLUMN]: members.length,
1298
1305
  ...sum === void 0 ? {} : { [AGGREGATE_SUM_COLUMN]: figures.length === 0 ? null : sumDecimal(figures) },
1299
- ...avg === void 0 ? {} : { [AGGREGATE_AVG_COLUMN]: averaged.length === 0 ? null : divideDecimal(sumDecimal(averaged), averaged.length) }
1306
+ ...avg === void 0 ? {} : { [AGGREGATE_AVG_COLUMN]: averaged.length === 0 ? null : divideDecimal(sumDecimal(averaged), averaged.length) },
1307
+ ...aggregate.max === void 0 ? {} : { [AGGREGATE_MAX_COLUMN]: extremes(aggregate.max, members, Math.max) },
1308
+ ...aggregate.min === void 0 ? {} : { [AGGREGATE_MIN_COLUMN]: extremes(aggregate.min, members, Math.min) }
1300
1309
  };
1301
1310
  });
1302
1311
  }
@@ -2038,6 +2047,7 @@ function rpcStandalone(op, payload) {
2038
2047
  case "comments.update":
2039
2048
  case "comments.delete":
2040
2049
  case "comments.counts":
2050
+ case "history":
2041
2051
  return rejectCommentsStandalone();
2042
2052
  case "outsideLink.list":
2043
2053
  case "outsideLink.create":
@@ -2073,7 +2083,7 @@ async function standaloneFolderSet(payload) {
2073
2083
  }
2074
2084
  function rejectCommentsStandalone() {
2075
2085
  return Promise.reject(
2076
- new Error("Comments are available only in embedded apps \u2014 a signed-in member is required.")
2086
+ new Error("Comments and a record's history are available only in embedded apps \u2014 a signed-in member is required.")
2077
2087
  );
2078
2088
  }
2079
2089
  async function standaloneMembers(p) {