@gridengine/angular-datagrid-enterprise 0.3.0 → 0.5.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.
|
@@ -308,5 +308,345 @@ declare class FormulaEngine {
|
|
|
308
308
|
isValidFormula(formula: string): boolean;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
|
|
312
|
-
|
|
311
|
+
/** A grid row — an arbitrary keyed record. Alias used across the Pro engines. */
|
|
312
|
+
type GridRow = Record<string, unknown>;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* SSRMEngine — Server-Side Row Model: a block-based LRU cache for server-driven
|
|
316
|
+
* datasets of arbitrary size. Pure logic; the caller supplies a datasource with
|
|
317
|
+
* a single async `getRows()` method. Filter/sort/group models are forwarded to
|
|
318
|
+
* the server. Failed fetches retry up to 3 times with exponential backoff.
|
|
319
|
+
*/
|
|
320
|
+
|
|
321
|
+
interface SSRMGetRowsParams {
|
|
322
|
+
startRow: number;
|
|
323
|
+
endRow: number;
|
|
324
|
+
filterModel: Record<string, unknown>;
|
|
325
|
+
sortModel: {
|
|
326
|
+
field: string;
|
|
327
|
+
direction: 'asc' | 'desc';
|
|
328
|
+
}[];
|
|
329
|
+
groupKeys: string[];
|
|
330
|
+
}
|
|
331
|
+
interface SSRMGetRowsResult {
|
|
332
|
+
rows: GridRow[];
|
|
333
|
+
totalCount: number;
|
|
334
|
+
}
|
|
335
|
+
interface SSRMDataSource {
|
|
336
|
+
getRows(params: SSRMGetRowsParams): Promise<SSRMGetRowsResult>;
|
|
337
|
+
}
|
|
338
|
+
type BlockState = 'idle' | 'loading' | 'loaded' | 'error';
|
|
339
|
+
interface Block {
|
|
340
|
+
/** Zero-based block index (index * blockSize = startRow). */
|
|
341
|
+
index: number;
|
|
342
|
+
state: BlockState;
|
|
343
|
+
rows: GridRow[];
|
|
344
|
+
error?: Error;
|
|
345
|
+
/** Monotonically increasing access counter — higher = more recently used. */
|
|
346
|
+
lastAccessed: number;
|
|
347
|
+
}
|
|
348
|
+
interface SSRMEngineOptions {
|
|
349
|
+
dataSource: SSRMDataSource;
|
|
350
|
+
/** Rows per block. Default: 100 */
|
|
351
|
+
blockSize?: number;
|
|
352
|
+
/** Maximum blocks to keep in memory (LRU eviction). Default: 10 */
|
|
353
|
+
maxBlocksInCache?: number;
|
|
354
|
+
}
|
|
355
|
+
declare class SSRMEngine {
|
|
356
|
+
private readonly _dataSource;
|
|
357
|
+
readonly blockSize: number;
|
|
358
|
+
readonly maxBlocksInCache: number;
|
|
359
|
+
private readonly _blocks;
|
|
360
|
+
private _accessClock;
|
|
361
|
+
private _totalCount;
|
|
362
|
+
private _filterModel;
|
|
363
|
+
private _sortModel;
|
|
364
|
+
private _groupKeys;
|
|
365
|
+
private _onChange?;
|
|
366
|
+
constructor(options: SSRMEngineOptions);
|
|
367
|
+
subscribe(listener: () => void): () => void;
|
|
368
|
+
setFilterModel(model: Record<string, unknown>): void;
|
|
369
|
+
setSortModel(model: {
|
|
370
|
+
field: string;
|
|
371
|
+
direction: 'asc' | 'desc';
|
|
372
|
+
}[]): void;
|
|
373
|
+
setGroupKeys(keys: string[]): void;
|
|
374
|
+
/** Total row count from the last server response (null = not yet known). */
|
|
375
|
+
getTotalCount(): number | null;
|
|
376
|
+
/**
|
|
377
|
+
* Get the row at an absolute zero-based index, fetching the containing block
|
|
378
|
+
* if needed. Returns null while the block is loading.
|
|
379
|
+
*/
|
|
380
|
+
getRow(rowIndex: number): GridRow | null;
|
|
381
|
+
/** Rows for the viewport [startRow, endRow); missing slots are null. */
|
|
382
|
+
getRowSlice(startRow: number, endRow: number): (GridRow | null)[];
|
|
383
|
+
getBlockState(blockIndex: number): BlockState;
|
|
384
|
+
getBlocks(): ReadonlyMap<number, Block>;
|
|
385
|
+
/** Evict all cached blocks and reset total count. */
|
|
386
|
+
invalidateAll(): void;
|
|
387
|
+
/** Evict a specific block (e.g. after a row mutation on that page). */
|
|
388
|
+
invalidateBlock(blockIndex: number): void;
|
|
389
|
+
private _getOrCreateBlock;
|
|
390
|
+
private _fetchBlock;
|
|
391
|
+
private _evictOldest;
|
|
392
|
+
private _invalidateAll;
|
|
393
|
+
private _notify;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* TransactionEngine — stages add / update / remove operations against a row set
|
|
398
|
+
* without mutating the original array. Changes are held until commit (fires
|
|
399
|
+
* `onTransactionCommit` with the delta) or rollback (discards them). Row
|
|
400
|
+
* identity comes from `rowIdField` (default 'id').
|
|
401
|
+
*/
|
|
402
|
+
|
|
403
|
+
interface TransactionDelta {
|
|
404
|
+
added: GridRow[];
|
|
405
|
+
updated: GridRow[];
|
|
406
|
+
removedIds: (string | number)[];
|
|
407
|
+
}
|
|
408
|
+
interface TransactionEngineOptions {
|
|
409
|
+
/** Initial rows loaded from the grid. */
|
|
410
|
+
initialRows: GridRow[];
|
|
411
|
+
/** Field used as the unique row ID. Default: 'id' */
|
|
412
|
+
rowIdField?: string;
|
|
413
|
+
onTransactionCommit?: (delta: TransactionDelta) => void;
|
|
414
|
+
onTransactionRollback?: () => void;
|
|
415
|
+
}
|
|
416
|
+
declare class TransactionEngine {
|
|
417
|
+
private readonly _rowIdField;
|
|
418
|
+
private readonly _onCommit?;
|
|
419
|
+
private readonly _onRollback?;
|
|
420
|
+
private _baseRows;
|
|
421
|
+
private readonly _dirty;
|
|
422
|
+
constructor(opts: TransactionEngineOptions);
|
|
423
|
+
/** Stage new rows; an existing ID is treated as an update instead. */
|
|
424
|
+
addRows(rows: GridRow[]): void;
|
|
425
|
+
/** Stage updates for existing rows; unknown IDs are ignored with a warning. */
|
|
426
|
+
updateRows(rows: GridRow[]): void;
|
|
427
|
+
/** Stage rows for removal by ID; a still-staged add is simply cancelled. */
|
|
428
|
+
removeRows(ids: (string | number)[]): void;
|
|
429
|
+
commitTransaction(): void;
|
|
430
|
+
rollbackTransaction(): void;
|
|
431
|
+
/** True if there are any staged (uncommitted) changes. */
|
|
432
|
+
isDirty(): boolean;
|
|
433
|
+
/** All current staged changes, grouped by kind. */
|
|
434
|
+
getDirtyRows(): {
|
|
435
|
+
added: GridRow[];
|
|
436
|
+
updated: GridRow[];
|
|
437
|
+
removed: GridRow[];
|
|
438
|
+
};
|
|
439
|
+
/** The merged row list: base rows with staged changes applied. */
|
|
440
|
+
getDisplayRows(): GridRow[];
|
|
441
|
+
/** Replace the base rows (e.g. after a refresh); staged changes are kept. */
|
|
442
|
+
resetRows(rows: GridRow[]): void;
|
|
443
|
+
private _rowId;
|
|
444
|
+
private _findBase;
|
|
445
|
+
private _stageUpdate;
|
|
446
|
+
private _buildDelta;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* MasterDetailEngine — manages expand/collapse state and lazy-loaded, cached
|
|
451
|
+
* detail data for master rows. Pure logic. Detail data is fetched once per row
|
|
452
|
+
* ID on first expand; subsequent expands reuse the cache.
|
|
453
|
+
*/
|
|
454
|
+
|
|
455
|
+
type DetailLoadState = 'idle' | 'loading' | 'loaded' | 'error';
|
|
456
|
+
interface DetailEntry {
|
|
457
|
+
state: DetailLoadState;
|
|
458
|
+
data: GridRow[];
|
|
459
|
+
error?: Error;
|
|
460
|
+
}
|
|
461
|
+
interface MasterDetailEngineOptions {
|
|
462
|
+
/** Loads detail rows for a master row; called at most once per row ID. */
|
|
463
|
+
getDetailRowData: (masterRow: GridRow) => Promise<GridRow[]>;
|
|
464
|
+
/** Called when a row's expanded state changes. */
|
|
465
|
+
onExpand?: (masterRow: GridRow, expanded: boolean) => void;
|
|
466
|
+
/** Field used as the row ID. Default: 'id' */
|
|
467
|
+
rowIdField?: string;
|
|
468
|
+
}
|
|
469
|
+
declare class MasterDetailEngine {
|
|
470
|
+
private readonly _getDetailRowData;
|
|
471
|
+
private readonly _onExpand?;
|
|
472
|
+
private readonly _rowIdField;
|
|
473
|
+
private readonly _expanded;
|
|
474
|
+
private readonly _cache;
|
|
475
|
+
private _onChange?;
|
|
476
|
+
constructor(options: MasterDetailEngineOptions);
|
|
477
|
+
/** Subscribe to state changes. Returns an unsubscribe function. */
|
|
478
|
+
subscribe(listener: () => void): () => void;
|
|
479
|
+
isExpanded(rowId: string | number): boolean;
|
|
480
|
+
getLoadState(rowId: string | number): DetailLoadState;
|
|
481
|
+
/** Cached detail rows, or an empty array if not yet loaded. */
|
|
482
|
+
getDetailData(rowId: string | number): GridRow[];
|
|
483
|
+
/** Expand a master row, triggering a load if not already cached. */
|
|
484
|
+
expand(masterRow: GridRow): void;
|
|
485
|
+
/** Collapse a master row; cached data is retained for re-expansion. */
|
|
486
|
+
collapse(masterRow: GridRow): void;
|
|
487
|
+
toggle(masterRow: GridRow): void;
|
|
488
|
+
/** Pre-fetch detail data without expanding (e.g. hover prefetch). */
|
|
489
|
+
prefetch(masterRow: GridRow): void;
|
|
490
|
+
/** Invalidate one row's cache, or the entire cache when rowId is omitted. */
|
|
491
|
+
invalidateCache(rowId?: string | number): void;
|
|
492
|
+
/** Collapse all expanded rows. Cache is preserved. */
|
|
493
|
+
collapseAll(): void;
|
|
494
|
+
/** A read-only snapshot of currently expanded row IDs. */
|
|
495
|
+
getExpandedIds(): ReadonlySet<string | number>;
|
|
496
|
+
private _rowId;
|
|
497
|
+
private _ensureLoaded;
|
|
498
|
+
private _notify;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* CellPermissionEngine — enforces per-cell read/edit permissions from a
|
|
503
|
+
* caller-supplied policy. Unreadable cells are masked ('●●●') everywhere
|
|
504
|
+
* (display, export, clipboard); non-editable cells can't be edited regardless
|
|
505
|
+
* of the column's `editable`. Results are cached per (rowId, field). Pure logic.
|
|
506
|
+
*/
|
|
507
|
+
|
|
508
|
+
interface CellPermission {
|
|
509
|
+
canRead: boolean;
|
|
510
|
+
canEdit: boolean;
|
|
511
|
+
}
|
|
512
|
+
/** Default mask string used for unreadable cells. */
|
|
513
|
+
declare const DEFAULT_MASK = "\u25CF\u25CF\u25CF";
|
|
514
|
+
interface CellPermissionEngineOptions {
|
|
515
|
+
/** Policy returning permissions for a cell; called once per (rowId, field). */
|
|
516
|
+
policy: (row: GridRow, field: string) => CellPermission;
|
|
517
|
+
/** Field used as the unique row ID. Default: 'id' */
|
|
518
|
+
rowIdField?: string;
|
|
519
|
+
/** String shown in place of unreadable cell values. Default: '●●●' */
|
|
520
|
+
maskValue?: string;
|
|
521
|
+
}
|
|
522
|
+
declare class CellPermissionEngine {
|
|
523
|
+
private readonly _policy;
|
|
524
|
+
private readonly _rowIdField;
|
|
525
|
+
private readonly _maskValue;
|
|
526
|
+
private readonly _cache;
|
|
527
|
+
constructor(options: CellPermissionEngineOptions);
|
|
528
|
+
/** The resolved permission for a cell (cached). */
|
|
529
|
+
getPermission(row: GridRow, field: string): CellPermission;
|
|
530
|
+
canRead(row: GridRow, field: string): boolean;
|
|
531
|
+
canEdit(row: GridRow, field: string): boolean;
|
|
532
|
+
/** The display value for a cell, masked when not readable. */
|
|
533
|
+
getDisplayValue(row: GridRow, field: string): unknown;
|
|
534
|
+
/** The value for copy/export; unreadable cells return '' so data never leaks. */
|
|
535
|
+
getExportValue(row: GridRow, field: string): unknown;
|
|
536
|
+
/** True if the given value is the mask placeholder. */
|
|
537
|
+
isMasked(value: unknown): boolean;
|
|
538
|
+
get maskValue(): string;
|
|
539
|
+
/** Clear one row's cached permissions, or the whole cache when omitted. */
|
|
540
|
+
clearCache(rowId?: string | number): void;
|
|
541
|
+
private _key;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* AuditTrailEngine — records an immutable log of every cell edit (who/what/when
|
|
546
|
+
* + prev/next values) in a bounded in-memory ring buffer, emitting each entry
|
|
547
|
+
* via `onEntry` for persistence. Pure logic.
|
|
548
|
+
*/
|
|
549
|
+
interface AuditEntry {
|
|
550
|
+
timestamp: number;
|
|
551
|
+
userId: string | undefined;
|
|
552
|
+
rowId: string | number;
|
|
553
|
+
field: string;
|
|
554
|
+
prevValue: unknown;
|
|
555
|
+
nextValue: unknown;
|
|
556
|
+
}
|
|
557
|
+
interface AuditTrailEngineOptions {
|
|
558
|
+
/** User identifier stamped on every entry. */
|
|
559
|
+
userId?: string;
|
|
560
|
+
/** Called for every new entry — persist to a server here. */
|
|
561
|
+
onEntry?: (entry: AuditEntry) => void;
|
|
562
|
+
/** Maximum entries retained in memory (oldest evicted first). Default: 1000 */
|
|
563
|
+
maxEntries?: number;
|
|
564
|
+
/** Injectable clock for testing. Defaults to Date.now. */
|
|
565
|
+
now?: () => number;
|
|
566
|
+
}
|
|
567
|
+
declare class AuditTrailEngine {
|
|
568
|
+
private readonly _userId?;
|
|
569
|
+
private readonly _onEntry?;
|
|
570
|
+
private readonly _maxEntries;
|
|
571
|
+
private readonly _now;
|
|
572
|
+
private _entries;
|
|
573
|
+
private _onChange?;
|
|
574
|
+
constructor(options?: AuditTrailEngineOptions);
|
|
575
|
+
subscribe(listener: () => void): () => void;
|
|
576
|
+
/** Record a cell edit; no-op edits (prev === next) return null. */
|
|
577
|
+
record(rowId: string | number, field: string, prevValue: unknown, nextValue: unknown): AuditEntry | null;
|
|
578
|
+
/** All entries, oldest first (read-only snapshot). */
|
|
579
|
+
getEntries(): readonly AuditEntry[];
|
|
580
|
+
/** Entries for a specific row, oldest first. */
|
|
581
|
+
getEntriesForRow(rowId: string | number): AuditEntry[];
|
|
582
|
+
/** Entries for a specific cell (row + field), oldest first. */
|
|
583
|
+
getEntriesForCell(rowId: string | number, field: string): AuditEntry[];
|
|
584
|
+
get size(): number;
|
|
585
|
+
/** Discard all entries. */
|
|
586
|
+
clear(): void;
|
|
587
|
+
private _notify;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* RowLockEngine — tracks which rows are locked (by other users) so the grid can
|
|
592
|
+
* show a lock indicator and block edits. Supports an async source of locks
|
|
593
|
+
* (e.g. polled from a collaboration server) plus optimistic local lock/unlock.
|
|
594
|
+
* Pure logic.
|
|
595
|
+
*/
|
|
596
|
+
|
|
597
|
+
interface LockedRow {
|
|
598
|
+
rowId: string | number;
|
|
599
|
+
lockedByUserId: string;
|
|
600
|
+
lockedByDisplayName?: string;
|
|
601
|
+
lockedAt: number;
|
|
602
|
+
}
|
|
603
|
+
interface RowLockEngineOptions {
|
|
604
|
+
/** The current user's ID. Locks held by this user do not block editing. */
|
|
605
|
+
currentUserId?: string;
|
|
606
|
+
/** Async source of currently locked rows (server state). */
|
|
607
|
+
getLockedRows?: () => Promise<LockedRow[]>;
|
|
608
|
+
/** Called when the current user attempts to edit a row locked by someone else. */
|
|
609
|
+
onLockConflict?: (row: GridRow, lockedBy: string) => void;
|
|
610
|
+
/** Field used as the unique row ID. Default: 'id' */
|
|
611
|
+
rowIdField?: string;
|
|
612
|
+
/** Injectable clock for testing. Defaults to Date.now. */
|
|
613
|
+
now?: () => number;
|
|
614
|
+
}
|
|
615
|
+
declare class RowLockEngine {
|
|
616
|
+
private readonly _currentUserId?;
|
|
617
|
+
private readonly _getLockedRows?;
|
|
618
|
+
private readonly _onLockConflict?;
|
|
619
|
+
private readonly _rowIdField;
|
|
620
|
+
private readonly _now;
|
|
621
|
+
private _locks;
|
|
622
|
+
private _onChange?;
|
|
623
|
+
constructor(options?: RowLockEngineOptions);
|
|
624
|
+
subscribe(listener: () => void): () => void;
|
|
625
|
+
/** Load locks from the async source and replace local state. */
|
|
626
|
+
refresh(): Promise<void>;
|
|
627
|
+
/** Optimistically lock a row for a user. */
|
|
628
|
+
lockRow(rowId: string | number, userId: string, displayName?: string): void;
|
|
629
|
+
/** Remove a lock. */
|
|
630
|
+
unlockRow(rowId: string | number): void;
|
|
631
|
+
/** Remove all locks. */
|
|
632
|
+
clear(): void;
|
|
633
|
+
/** The lock for a row, or undefined if unlocked. */
|
|
634
|
+
getLock(rowId: string | number): LockedRow | undefined;
|
|
635
|
+
/** True if the row is locked by anyone. */
|
|
636
|
+
isLocked(rowId: string | number): boolean;
|
|
637
|
+
/** True if the row is locked by someone OTHER than the current user. */
|
|
638
|
+
isLockedByOther(rowId: string | number): boolean;
|
|
639
|
+
/** All current locks. */
|
|
640
|
+
getLocks(): LockedRow[];
|
|
641
|
+
get size(): number;
|
|
642
|
+
/**
|
|
643
|
+
* Whether the row may be edited by the current user. If it's locked by
|
|
644
|
+
* another user, fires `onLockConflict` and returns false.
|
|
645
|
+
*/
|
|
646
|
+
canEditRow(row: GridRow): boolean;
|
|
647
|
+
private _rowId;
|
|
648
|
+
private _notify;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
export { AuditTrailEngine, CellPermissionEngine, ClipboardEngine, DEFAULT_MASK, DataGridPro, FillHandleEngine, FormulaEngine, GridLicenseWatermark, LicenseManager, MasterDetailEngine, PRODUCT_ID, PURCHASE_URL, RangeSelectionEngine, RowLockEngine, SSRMEngine, TransactionEngine, UndoRedoManager, parseTSV, provideGridEngineLicense, toNumber, toTimestamp };
|
|
652
|
+
export type { AuditEntry, AuditTrailEngineOptions, Block, BlockState, CellEditCommand, CellPermission, CellPermissionEngineOptions, CellRange, ClipboardEngineOptions, DeleteCommand, DetailEntry, DetailLoadState, FillCell, FillCommand, FillDirection, FillHandleEngineOptions, FillResult, FormulaEngineOptions, GridRow, LockedRow, MasterDetailEngineOptions, PasteCommand, RangeSelectionEngineOptions, RowLockEngineOptions, SSRMDataSource, SSRMEngineOptions, SSRMGetRowsParams, SSRMGetRowsResult, TransactionDelta, TransactionEngineOptions, UndoRedoCommand, UndoRedoManagerOptions };
|