@lotics/app-sdk 0.102.2 → 0.102.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 CHANGED
@@ -23826,6 +23826,9 @@ var queryAggregateColumnSchema = zod_default.object({
23826
23826
  input_column: zod_default.string().optional().describe(
23827
23827
  "Input column to aggregate. Required for non-count operations; ignored for count."
23828
23828
  ),
23829
+ filter: tableRecordFiltersSchema.optional().describe(
23830
+ "Aggregates only the input rows that match (SQL `FILTER`). Conditions name input columns and take `{{params.x}}`; aggregates with different filters in one node read the input once."
23831
+ ),
23829
23832
  separator: zod_default.string().max(8).optional().describe('string_agg only. Joins the values. Defaults to ", ".'),
23830
23833
  distinct: zod_default.boolean().optional().describe(
23831
23834
  "string_agg only. Collapses repeats \u2014 a group of containers sized 40HC/40HC/20DC aggregates to '20DC, 40HC'. Defaults to true, which is almost always what a summary column wants."
package/docs/mutations.md CHANGED
@@ -531,8 +531,9 @@ every read before the request answers:
531
531
  - **Totals.** A `total`, a count per value (`total: { by }`), a group asked with `aggregate` or
532
532
  declared by the query, and a parent's count or sum rollup move by exactly what the written row adds
533
533
  or takes away; a group the last row leaves is gone, and a count per value gains the value a row
534
- first holds. A mean, an extreme, a distinct count, a group by day, a group none of the read's rows
535
- counted in yet, a read whose rows a search or a cap decides, or a row the app never read is left
534
+ first holds. A mean, an extreme, a distinct count, a group by day, an aggregate with its own
535
+ `filter`, a group none of the read's rows counted in yet, a read whose rows a search or a cap
536
+ decides, or a row the app never read is left
536
537
  as the server said it until a read asked after the write answers.
537
538
  - **A refusal takes it back**, and `result` says why, as always. A success keeps it until a read
538
539
  asked after the write settled answers — the stored value then replaces the prediction, whatever
package/docs/queries.md CHANGED
@@ -277,7 +277,7 @@ came from.
277
277
 
278
278
  Full semantics in §8. `by` may be empty (a single-row aggregate); `aggregates` needs ≥ 1 entry.
279
279
  Aggregate operation × input-column type is validated at bind. Grouping collapses rows —
280
- addressing is dropped.
280
+ addressing is dropped. An aggregate's `filter` limits it to the rows that match (§8).
281
281
 
282
282
  ### `window` — aggregate without collapsing
283
283
 
@@ -679,6 +679,25 @@ everything else requires an `input_column` whose type must be compatible — che
679
679
  ¹ opaque `json` columns support only the presence-counting six (`empty`/`filled`/`unique` and
680
680
  their `percent_*` forms).
681
681
 
682
+ **`filter` — aggregate a subset.** Any aggregate, in `group` or `window`, takes a `filter` over its
683
+ input columns — the same tree as a `filter` node, `{{params.x}}` included, with a condition on an
684
+ omitted optional param dropped. The aggregate reads only the rows it matches (SQL `FILTER`), and
685
+ the rest of the node is unaffected, so several figures over one table cost one read of it:
686
+
687
+ ```jsonc
688
+ { "kind": "group", "from": { "kind": "from_table", "table_id": "…" }, "by": [],
689
+ "aggregates": [
690
+ { "output": "open", "type": "number", "operation": "count",
691
+ "filter": { "node_type": "condition", "field_key": "closed_at", "operator": "is_empty" } },
692
+ { "output": "closed_today", "type": "number", "operation": "count",
693
+ "filter": { "node_type": "condition", "field_key": "closed_at", "operator": "on",
694
+ "value": { "type": "period", "period": "day", "boundary": "start", "offset": 0 } } } ] }
695
+ ```
696
+
697
+ A relative date resolves in its field's timezone while the column still names one field — over a
698
+ `from_table`, or a `project` of one. Over a `union` of different tables it names none; count per
699
+ table, then combine.
700
+
682
701
  **`string_agg` — a summary column, not a dataset.** Every other operation counts or reduces to a
683
702
  number; this one joins the values, so a child set answers "which ones?" in the parent row (the
684
703
  sizes on a shipment, the tags on a ticket) without a second query.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.102.2",
3
+ "version": "0.102.3",
4
4
  "description": "The SDK a Lotics custom-code app reads and writes through \u2014 typed hooks over the host bridge, cell readers, mount() and AppRouter",
5
5
  "type": "module",
6
6
  "exports": {