@ember-lattice/data 0.0.0-stage → 1.1.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 +48 -0
- package/LICENSE.md +21 -0
- package/NOTICE +30 -0
- package/README.md +75 -2
- package/addon-main.cjs +4 -0
- package/declarations/array-source.d.ts +12 -0
- package/declarations/array-source.d.ts.map +1 -0
- package/declarations/base.d.ts +41 -0
- package/declarations/base.d.ts.map +1 -0
- package/declarations/batch.d.ts +14 -0
- package/declarations/batch.d.ts.map +1 -0
- package/declarations/block-cache.d.ts +37 -0
- package/declarations/block-cache.d.ts.map +1 -0
- package/declarations/block.d.ts +61 -0
- package/declarations/block.d.ts.map +1 -0
- package/declarations/client.d.ts +9 -0
- package/declarations/client.d.ts.map +1 -0
- package/declarations/cursor.d.ts +54 -0
- package/declarations/cursor.d.ts.map +1 -0
- package/declarations/index.d.ts +23 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/infinite.d.ts +50 -0
- package/declarations/infinite.d.ts.map +1 -0
- package/declarations/lru.d.ts +23 -0
- package/declarations/lru.d.ts.map +1 -0
- package/declarations/request.d.ts +39 -0
- package/declarations/request.d.ts.map +1 -0
- package/declarations/server.d.ts +100 -0
- package/declarations/server.d.ts.map +1 -0
- package/declarations/types.d.ts +24 -0
- package/declarations/types.d.ts.map +1 -0
- package/declarations/viewport.d.ts +36 -0
- package/declarations/viewport.d.ts.map +1 -0
- package/dist/index.js +1535 -0
- package/dist/index.js.map +1 -0
- package/package.json +88 -3
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { ColumnDef, TableFeatures } from '@ember-lattice/core';
|
|
2
|
+
import { type Aggregate, type PivotColumn, type RowsRequest, type Transaction } from '@ember-lattice/protocol';
|
|
3
|
+
import { BaseRowModel, type RowModelOptions } from './base.ts';
|
|
4
|
+
export interface ServerRowModelOptions<TFeatures extends TableFeatures, Row extends object> extends RowModelOptions<TFeatures, Row> {
|
|
5
|
+
/** Rows in one block of each group node. Default 100. */
|
|
6
|
+
blockSize?: number;
|
|
7
|
+
/** Blocks in the cache of each group node. Default 10. */
|
|
8
|
+
maxBlocks?: number;
|
|
9
|
+
/** The aggregates of group rows and of the grand total. Each value is under its column id. */
|
|
10
|
+
aggregate?: ReadonlyArray<Omit<Aggregate, 'as'>>;
|
|
11
|
+
pivot?: RowsRequest['pivot'];
|
|
12
|
+
/**
|
|
13
|
+
* Tree data (ADR 0022). A row with `$count > 0` has children, which load when the row expands.
|
|
14
|
+
* `key` is the column of the row key (the AG Grid `getServerSideGroupKey`), and `label` is the
|
|
15
|
+
* column that the group cell shows. The table grouping is not used.
|
|
16
|
+
*/
|
|
17
|
+
tree?: {
|
|
18
|
+
key: string;
|
|
19
|
+
label: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare class ServerRowModel<TFeatures extends TableFeatures, Row extends object> extends BaseRowModel<TFeatures, Row> {
|
|
23
|
+
readonly blockSize: number;
|
|
24
|
+
private maxBlocks;
|
|
25
|
+
private options;
|
|
26
|
+
private root;
|
|
27
|
+
/** The aggregates over all rows (the grand total row). */
|
|
28
|
+
grandTotal: Record<string, unknown> | undefined;
|
|
29
|
+
pivotColumns: PivotColumn[] | undefined;
|
|
30
|
+
private groupIds;
|
|
31
|
+
private key;
|
|
32
|
+
/** The node of each expanded group row that rendered, by group row ID. */
|
|
33
|
+
private childNodes;
|
|
34
|
+
/** The expanded state when the table has no row expanding feature. */
|
|
35
|
+
private ownExpanded;
|
|
36
|
+
/**
|
|
37
|
+
* The columns that the model adds after the columns of the table: one header group for each
|
|
38
|
+
* pivot key. A template-form grid reads them, because its table reads its columns from the
|
|
39
|
+
* declarations (ADR 0028).
|
|
40
|
+
*/
|
|
41
|
+
addedColumns: ReadonlyArray<ColumnDef<TFeatures, Row>>;
|
|
42
|
+
/**
|
|
43
|
+
* A function that makes the model from a table, for `@rowModel` of a grid in the template form:
|
|
44
|
+
* the grid makes the table from its declarations, then calls the function (ADR 0028). The grid
|
|
45
|
+
* gives that table the `manual*` options. Give it the features of the query in `@features`.
|
|
46
|
+
* The model has the row type of `source`, so the grid has it too.
|
|
47
|
+
*/
|
|
48
|
+
static forGrid<TFeatures extends TableFeatures, Row extends object>(options: Omit<ServerRowModelOptions<TFeatures, Row>, 'table'>): (table: object) => ServerRowModel<TFeatures, Row>;
|
|
49
|
+
constructor(options: ServerRowModelOptions<TFeatures, Row>);
|
|
50
|
+
/** The expanded group rows: `table.state.expanded` when the table has the feature. */
|
|
51
|
+
private get expanded();
|
|
52
|
+
private get hasExpanding();
|
|
53
|
+
private isExpanded;
|
|
54
|
+
private setExpanded;
|
|
55
|
+
private loadedGroupIds;
|
|
56
|
+
/** The child nodes of the expanded group rows that `node` has loaded. */
|
|
57
|
+
private childrenOf;
|
|
58
|
+
private get groupBy();
|
|
59
|
+
get tree(): boolean;
|
|
60
|
+
/** The group key and label of a row that can expand, or undefined. */
|
|
61
|
+
private groupOf;
|
|
62
|
+
private node;
|
|
63
|
+
/** The grand total as an engine row, so the columns of the table read and format it. */
|
|
64
|
+
get totalRow(): import("@ember-lattice/core").Row<TFeatures, Row> | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* The pivot result columns become leaf columns of the table, after its own columns: one
|
|
67
|
+
* header group for each pivot key, with a leaf for each value. The leaf ID is the field.
|
|
68
|
+
*/
|
|
69
|
+
private setPivotColumns;
|
|
70
|
+
/** The display rows of a node: its own rows and the rows of its expanded children. */
|
|
71
|
+
private lengthOf;
|
|
72
|
+
private countsKnown;
|
|
73
|
+
/** The node and the index in the node of a display row. */
|
|
74
|
+
private locate;
|
|
75
|
+
get displayCount(): number;
|
|
76
|
+
get rowCount(): number | null;
|
|
77
|
+
rowAt(index: number): import("@ember-lattice/core").Row<TFeatures, Row> | undefined;
|
|
78
|
+
protected rowId(original: Row): string;
|
|
79
|
+
failedAt(index: number): boolean;
|
|
80
|
+
levelAt(index: number): number;
|
|
81
|
+
groupAt(index: number): {
|
|
82
|
+
level: number;
|
|
83
|
+
expanded: boolean;
|
|
84
|
+
label: string;
|
|
85
|
+
} | undefined;
|
|
86
|
+
/** Expand or collapse the group row at a display index. Its rows load when they come in view. */
|
|
87
|
+
toggleGroup(index: number): void;
|
|
88
|
+
protected flush(): void;
|
|
89
|
+
private reset;
|
|
90
|
+
private clear;
|
|
91
|
+
private nodes;
|
|
92
|
+
/** Load the rows again. Without `purge` the old rows stay on screen until the new rows come. */
|
|
93
|
+
refresh({ purge }?: {
|
|
94
|
+
purge?: boolean;
|
|
95
|
+
}): void;
|
|
96
|
+
retryFailed(): void;
|
|
97
|
+
/** Apply a transaction to the node of its route. Adds and removes reload that node. */
|
|
98
|
+
applyTransaction(tx: Transaction<Row>): void;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAiB,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAClF,OAAO,EAEL,KAAK,SAAS,EAEd,KAAK,WAAW,EAChB,KAAK,WAAW,EAEhB,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAK9D,MAAM,WAAW,qBAAqB,CACpC,SAAS,SAAS,aAAa,EAC/B,GAAG,SAAS,MAAM,CAClB,SAAQ,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC;IACvC,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8FAA8F;IAC9F,SAAS,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAA;IAChD,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,C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IAMtB,yEAAyE;IACzE,OAAO,CAAC,UAAU,CAajB;IAED,OAAO,KAAK,OAAO,GAElB;IAED,IAAI,IAAI,YAEP;IAED,sEAAsE;IACtE,OAAO,CAAC,OAAO;IAaf,OAAO,CAAC,IAAI;IA6CZ,wFAAwF;IACxF,IAAI,QAAQ,kEAGX;IAED;;;OAGG;IACH,OAAO,CAAC,eAAe;IA2BvB,sFAAsF;IACtF,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,WAAW;IAInB,2DAA2D;IAC3D,OAAO,CAAC,MAAM;IAed,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAE5B;IAED,KAAK,CAAC,KAAK,EAAE,MAAM;cAMA,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM;IAI/C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAKhC,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI9B,OAAO,CAAC,KAAK,EAAE,MAAM;;;;;IAarB,iGAAiG;IACjG,WAAW,CAAC,KAAK,EAAE,MAAM;IAezB,SAAS,CAAC,KAAK;IAiBf,OAAO,CAAC,KAAK;IAOb,OAAO,CAAC,KAAK;IAKb,OAAO,CAAC,KAAK;IAIb,gGAAgG;IAChG,OAAO,CAAC,EAAE,KAAa,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;IAMnD,WAAW;IAIX,uFAAuF;IACvF,gBAAgB,CAAC,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC;CAUtC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { MutateResult, RowOp, RowsRequest, RowsResponse, Transaction } from '@ember-lattice/protocol';
|
|
2
|
+
/** What the server does. The row model does the rest on the client when it can. */
|
|
3
|
+
export interface DataSourceCapabilities {
|
|
4
|
+
sort: boolean;
|
|
5
|
+
filter: boolean;
|
|
6
|
+
group: boolean;
|
|
7
|
+
aggregate: boolean;
|
|
8
|
+
pivot: boolean;
|
|
9
|
+
tree: boolean;
|
|
10
|
+
count: boolean;
|
|
11
|
+
transactions: boolean;
|
|
12
|
+
push: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface DataSource<Row> {
|
|
15
|
+
readonly capabilities: DataSourceCapabilities;
|
|
16
|
+
/** Every request takes a signal. A fast scroll aborts the requests of old blocks. */
|
|
17
|
+
getRows(request: RowsRequest, signal: AbortSignal): Promise<RowsResponse<Row>>;
|
|
18
|
+
/** Live updates. Returns the function that stops them. */
|
|
19
|
+
subscribe?(onChange: (tx: Transaction<Row>) => void): () => void;
|
|
20
|
+
/** Edits, and drag to group. */
|
|
21
|
+
mutate?(ops: RowOp<Row>[]): Promise<MutateResult<Row>>;
|
|
22
|
+
getRowId(row: Row): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,KAAK,EACL,WAAW,EACX,YAAY,EACZ,WAAW,EACZ,MAAM,yBAAyB,CAAA;AAEhC,mFAAmF;AACnF,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,OAAO,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd,YAAY,EAAE,OAAO,CAAA;IACrB,IAAI,EAAE,OAAO,CAAA;CACd;AAED,MAAM,WAAW,UAAU,CAAC,GAAG;IAC7B,QAAQ,CAAC,YAAY,EAAE,sBAAsB,CAAA;IAC7C,qFAAqF;IACrF,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;IAC9E,0DAA0D;IAC1D,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;IAChE,gCAAgC;IAChC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;IACtD,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAA;CAC3B"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { TableFeatures } from '@ember-lattice/core';
|
|
2
|
+
import type { Transaction } from '@ember-lattice/protocol';
|
|
3
|
+
import { BaseRowModel, type RowModelOptions } from './base.ts';
|
|
4
|
+
export interface ViewportRowModelOptions<TFeatures extends TableFeatures, Row extends object> extends RowModelOptions<TFeatures, Row> {
|
|
5
|
+
/** Rows to ask for on each side of the view. Default 10. */
|
|
6
|
+
overscan?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class ViewportRowModel<TFeatures extends TableFeatures, Row extends object> extends BaseRowModel<TFeatures, Row> {
|
|
9
|
+
private count;
|
|
10
|
+
/** The rows of the last response, by display index. */
|
|
11
|
+
private slots;
|
|
12
|
+
private ids;
|
|
13
|
+
private controller;
|
|
14
|
+
private loaded;
|
|
15
|
+
private key;
|
|
16
|
+
private overscan;
|
|
17
|
+
private stop;
|
|
18
|
+
/**
|
|
19
|
+
* A function that makes the model from a table, for `@rowModel` of a grid in the template form:
|
|
20
|
+
* the grid makes the table from its declarations, then calls the function (ADR 0028). The grid
|
|
21
|
+
* gives that table the `manual*` options. Give it the features of the query in `@features`.
|
|
22
|
+
* The model has the row type of `source`, so the grid has it too.
|
|
23
|
+
*/
|
|
24
|
+
static forGrid<TFeatures extends TableFeatures, Row extends object>(options: Omit<ViewportRowModelOptions<TFeatures, Row>, 'table'>): (table: object) => ViewportRowModel<TFeatures, Row>;
|
|
25
|
+
constructor(options: ViewportRowModelOptions<TFeatures, Row>);
|
|
26
|
+
/** Stop the live updates and abort the request in flight. */
|
|
27
|
+
disconnect(): void;
|
|
28
|
+
get rowCount(): number | null;
|
|
29
|
+
get displayCount(): number;
|
|
30
|
+
rowAt(index: number): import("@ember-lattice/core").Row<TFeatures, Row> | undefined;
|
|
31
|
+
protected flush(): void;
|
|
32
|
+
/** Updates change the rows in view in place. Adds and removes ask for the range again. */
|
|
33
|
+
applyTransaction(tx: Transaction<Row>): void;
|
|
34
|
+
refresh(): void;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../src/viewport.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAW9D,MAAM,WAAW,uBAAuB,CACtC,SAAS,SAAS,aAAa,EAC/B,GAAG,SAAS,MAAM,CAClB,SAAQ,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC;IACvC,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,qBAAa,gBAAgB,CAC3B,SAAS,SAAS,aAAa,EAC/B,GAAG,SAAS,MAAM,CAClB,SAAQ,YAAY,CAAC,SAAS,EAAE,GAAG,CAAC;IAC3B,OAAO,CAAC,KAAK,CAAsB;IAC5C,uDAAuD;IAC9C,OAAO,CAAC,KAAK,CAAkC;IACxD,OAAO,CAAC,GAAG,CAA4B;IACvC,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,GAAG,CAAsB;IACjC,O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