@ember-lattice/protocol 0.0.0-stage → 1.0.0
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/CHANGELOG.md +11 -0
- package/LICENSE.md +21 -0
- package/NOTICE +30 -0
- package/README.md +82 -2
- package/conformance/cases.v1.json +7433 -0
- package/dist/ag-grid/index.d.ts +42 -0
- package/dist/ag-grid/types.d.ts +126 -0
- package/dist/conformance/dataset.d.ts +11 -0
- package/dist/conformance/index.d.ts +54 -0
- package/dist/evaluate.d.ts +21 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2557 -0
- package/dist/index.js.map +1 -0
- package/dist/limits.d.ts +31 -0
- package/dist/parse.d.ts +24 -0
- package/dist/schema.d.ts +91 -0
- package/dist/types.d.ts +207 -0
- package/package.json +48 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @ember-lattice/protocol
|
|
2
|
+
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 7ce4af2: Lattice 1.0: one grid for every collection in Ember. Lists, feeds, tables, boards and
|
|
8
|
+
spreadsheets come from one headless engine, a port of TanStack Table. It has 80 of the 81
|
|
9
|
+
AG Grid features in the parity matrix; the external filter runs after grouping. The release has the client row models, the Lattice wire protocol with servers for Node,
|
|
10
|
+
Rails and Python, an IronCalc spreadsheet with live collaboration, themes, test harnesses, Jig
|
|
11
|
+
stories and Marquetry catalog entries.
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joe Gaudet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Lattice
|
|
2
|
+
Copyright (c) 2026 Joe Gaudet. MIT licensed; see LICENSE.md.
|
|
3
|
+
|
|
4
|
+
Lattice ports code from two MIT-licensed TanStack projects into Ember-native code. Lattice does
|
|
5
|
+
not depend on either package. PORT_MAP.md names each ported file and its source.
|
|
6
|
+
|
|
7
|
+
TanStack Table (@tanstack/table-core 9.3.1)
|
|
8
|
+
https://github.com/TanStack/table
|
|
9
|
+
Copyright (c) 2016 Tanner Linsley
|
|
10
|
+
|
|
11
|
+
TanStack Virtual (@tanstack/virtual-core 3.19.16)
|
|
12
|
+
https://github.com/TanStack/virtual
|
|
13
|
+
Copyright (c) 2021-present Tanner Linsley
|
|
14
|
+
|
|
15
|
+
Both are licensed under the MIT License:
|
|
16
|
+
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
18
|
+
and associated documentation files (the "Software"), to deal in the Software without
|
|
19
|
+
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
|
20
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
|
21
|
+
Software is furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
24
|
+
substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
27
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
28
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
29
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ember-lattice/protocol
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Lattice wire protocol, version 1. Plain TypeScript, no framework and no runtime
|
|
4
|
+
dependencies, so servers and workers can share it. The design and every rule are in
|
|
5
|
+
[ADR 0005](../../docs/adr/0005-wire-protocol.md).
|
|
6
|
+
|
|
7
|
+
Part of [Lattice](https://joegaudet.com/ember-lattice/). Not released yet.
|
|
8
|
+
|
|
9
|
+
## Contents
|
|
10
|
+
|
|
11
|
+
- Types: `RowsRequest`, `RowsResponse`, `FilterNode`, `RowOp`, `Transaction`, `MutateResult`,
|
|
12
|
+
`ColumnSchema`.
|
|
13
|
+
- `parseRowsRequest(input, allowList)`: the trust boundary. Every server calls it first.
|
|
14
|
+
- `LIMITS`: the hard limits on a request.
|
|
15
|
+
- JSON Schema (draft 2020-12): `rowsRequestSchema`, `rowsResponseSchema`, `rowOpSchema`,
|
|
16
|
+
`transactionSchema`, `mutateResultSchema`.
|
|
17
|
+
- `evaluate(request, rows, allowList)`: the reference implementation over rows in memory.
|
|
18
|
+
- `matchesFilter(node, row, allowList)`: the row test of `evaluate`. A client filter uses it, so
|
|
19
|
+
the client and the server keep the same rows.
|
|
20
|
+
- `conformanceCases()`, `checkCase()`, `compareResponse()`: the conformance suite.
|
|
21
|
+
- `fromAgGrid()` and `toAgGrid()`: the AG Grid server-side row model translator.
|
|
22
|
+
|
|
23
|
+
## A server
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { parseRowsRequest, type AllowList } from '@ember-lattice/protocol'
|
|
27
|
+
|
|
28
|
+
const columns: AllowList = [
|
|
29
|
+
{ name: 'id', type: 'number', key: true, sort: true },
|
|
30
|
+
{ name: 'name', type: 'string', filter: ['eq', 'contains'], sort: true, search: true },
|
|
31
|
+
{ name: 'salary', type: 'number', filter: ['gt', 'lt'], aggregate: ['sum', 'avg'] },
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
const result = parseRowsRequest(JSON.parse(body), columns)
|
|
35
|
+
if (!result.ok) return reply(400, { errors: result.errors })
|
|
36
|
+
// result.value holds only allow-listed columns, ops and functions. Bind every value as a parameter.
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Limit the request body size before you parse it.
|
|
40
|
+
|
|
41
|
+
## Limits
|
|
42
|
+
|
|
43
|
+
| Limit | Value |
|
|
44
|
+
| -------------------------------------------- | --------------- |
|
|
45
|
+
| Filter depth | 16 |
|
|
46
|
+
| Filter nodes in one tree | 256 |
|
|
47
|
+
| Items in one list | 1000 |
|
|
48
|
+
| Sort items | 16 |
|
|
49
|
+
| `group.by` and `pivot.by` | 16 |
|
|
50
|
+
| Rows in one page | 10000 |
|
|
51
|
+
| String value, search and cursor (characters) | 1024, 256, 4096 |
|
|
52
|
+
| Distinct pivot values in the scope | 200 |
|
|
53
|
+
|
|
54
|
+
No string in a request can contain U+0000 (error code `bad_string`). A date has a year from
|
|
55
|
+
0001 to 9999. The pivot limit depends on the data, so `evaluate` checks it at run time (error
|
|
56
|
+
code `pivot_too_wide`). A server counts the distinct pivot values before it builds the SQL.
|
|
57
|
+
|
|
58
|
+
## Conformance
|
|
59
|
+
|
|
60
|
+
The suite is in `conformance/cases.v1.json`, which the package ships. It has more than one
|
|
61
|
+
dataset: each case names its dataset. The Node server can use
|
|
62
|
+
`checkCase(case, handler)`. The Ruby and Python ports read the JSON file and follow these
|
|
63
|
+
rules:
|
|
64
|
+
|
|
65
|
+
- A case with `expected`: send `request`, and compare the response.
|
|
66
|
+
- A case with `pages`: send `request`, then send it again with `range.after` set to
|
|
67
|
+
`cursor.next` until `cursor.next` is absent. Compare each page. The last page has `count`.
|
|
68
|
+
- A case with `error`: reject the request. One of the errors must have that code.
|
|
69
|
+
- Rows come in the same order, with the same keys.
|
|
70
|
+
- Numbers match within 1e-9, relative to the larger value.
|
|
71
|
+
- Cursor values are opaque. Only the presence of `cursor.next` and `cursor.prev` must match.
|
|
72
|
+
- `count`, `total`, `pivotColumns` and `cursor` are present exactly when expected.
|
|
73
|
+
- Pivot fields are compact JSON arrays, for example `["east","sum(salary)"]`.
|
|
74
|
+
|
|
75
|
+
To write the file again after a change to the cases, run
|
|
76
|
+
`pnpm --filter @ember-lattice/protocol conformance:export`.
|
|
77
|
+
|
|
78
|
+
## AG Grid
|
|
79
|
+
|
|
80
|
+
`fromAgGrid(request, { columns })` translates an AG Grid `IServerSideGetRowsRequest`, with
|
|
81
|
+
either filter grammar, into a `RowsRequest`. Give it the allow-list, so it can change string
|
|
82
|
+
group keys and set values into numbers and booleans. Then call `parseRowsRequest` on the
|
|
83
|
+
result. `toAgGrid(response)` gives the `LoadSuccessParams` for `params.success()`.
|