@masterteam/client-components 0.0.85 → 0.0.87

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@masterteam/client-components",
3
- "version": "0.0.85",
3
+ "version": "0.0.87",
4
4
  "publishConfig": {
5
5
  "directory": "../../../dist/masterteam/client-components",
6
6
  "linkDirectory": true,
@@ -16,10 +16,10 @@
16
16
  "rxjs": "^7.8.2",
17
17
  "tailwindcss": "^4.2.2",
18
18
  "tailwindcss-primeui": "^0.6.1",
19
- "@masterteam/forms": "^0.0.138",
20
- "@masterteam/dashboard-builder": "^0.0.80",
19
+ "@masterteam/forms": "^0.0.140",
21
20
  "@masterteam/icons": "^0.0.17",
22
- "@masterteam/components": "^0.0.274"
21
+ "@masterteam/components": "^0.0.274",
22
+ "@masterteam/dashboard-builder": "^0.0.81"
23
23
  },
24
24
  "dependencies": {
25
25
  "tslib": "^2.8.1"
@@ -24,6 +24,14 @@ interface Response<T> {
24
24
  type ClientListRuntimeContext = string;
25
25
  type ClientListFetchStateKey = 'escalation';
26
26
  declare const CLIENT_LIST_RECORD_STATE_KEY = "__clientListRecordState";
27
+ /** Record state every list request asks for. */
28
+ declare const CLIENT_LIST_DEFAULT_INCLUDE_STATE: readonly ClientListFetchStateKey[];
29
+ /**
30
+ * `fetch/query` filter key that selects a single record by its own id. Reading
31
+ * one record back after a write filters on this, never on the list's scope
32
+ * filters alone — those match a whole page, not the row that just changed.
33
+ */
34
+ declare const CLIENT_LIST_RECORD_ID_FILTER_KEY = "id";
27
35
  interface ClientListBaseConfiguration {
28
36
  key?: string;
29
37
  title?: string;
@@ -234,6 +242,48 @@ interface ClientListFetchQueryRequest {
234
242
  surfaceKey?: string;
235
243
  display?: ClientListFetchRequestDisplay;
236
244
  }
245
+ /**
246
+ * The query settings a list renders with, in the shape `process-submit` takes
247
+ * as `returnRecord`. Sending these with a write asks the backend to project
248
+ * the written record exactly the way this list would have fetched it, so the
249
+ * list can splice the result straight in.
250
+ *
251
+ * The same object doubles as the spec for reading a single record back through
252
+ * `fetch/query` when the write could not project one — one description of
253
+ * "how this list reads a record", used by both paths so they cannot drift.
254
+ */
255
+ interface ClientListReturnRecordRequest {
256
+ projection: ClientListFetchProjection;
257
+ surfaceKey?: string;
258
+ includeState?: ClientListFetchStateKey[];
259
+ propertyKeys?: string[];
260
+ culture?: string;
261
+ }
262
+ type ClientListRecordProjectionStatus = 'Available' | 'Unavailable';
263
+ /**
264
+ * The part of a `process-submit` response a list needs to apply a write
265
+ * locally. Structural on purpose: `ProcessFormSubmitResponse` from
266
+ * `@masterteam/forms/client-form` satisfies it, and so does any host-owned
267
+ * envelope that carries the same three keys.
268
+ */
269
+ interface ClientListRecordWriteResult {
270
+ /** `PendingApproval` writes nothing yet — the list must stay as it is. */
271
+ status?: string | null;
272
+ recordId?: number | string | null;
273
+ record?: ClientListFetchRecord | null;
274
+ recordProjectionStatus?: ClientListRecordProjectionStatus | string | null;
275
+ }
276
+ /**
277
+ * A table page plus the `propertyKeys` the request actually carried. The keys
278
+ * are not derivable from the response — the backend echoes columns, not the
279
+ * projection it was asked for — and `returnRecord` has to repeat them
280
+ * verbatim, so the request reports them.
281
+ */
282
+ interface ClientListRowsFetchResult {
283
+ response: Response<RuntimeTableRowsResponse>;
284
+ /** `undefined` when the request left the projection to the backend. */
285
+ propertyKeys?: string[];
286
+ }
237
287
  interface ClientListTableSettingsColumn {
238
288
  key?: string;
239
289
  propertyKey?: string;
@@ -487,6 +537,40 @@ declare class ClientListStateService {
487
537
  setTablePaging(key: string, skip: number, take: number): void;
488
538
  setRowsResult(key: string, response: RuntimeTableRowsResponse, config: NormalizedClientListConfiguration, skip: number, take: number): void;
489
539
  setCardsResult(key: string, response: ClientListCardsPayload, config: NormalizedClientListConfiguration, skip?: number, take?: number, append?: boolean): void;
540
+ /**
541
+ * Splices a canonical record into the data the list already holds, so a
542
+ * create or update lands without re-fetching the page.
543
+ *
544
+ * Tables replay the whole page through {@link setRowsResult}: for a table
545
+ * the rendered page *is* the raw response, so replaying it keeps the catalog
546
+ * lookup, the column build and the host `transformResult` hook on exactly
547
+ * one code path — a second mapper for single rows would drift from the one
548
+ * that built the rest of the table. Cards cannot replay: with infinite
549
+ * scroll `rawData` holds only the last page while `cards` holds every page,
550
+ * so a single card is built and merged into the accumulated set instead.
551
+ *
552
+ * Returns `false` when there is nothing to splice into — an informative
553
+ * dashboard, or a list that never completed a load. The caller then falls
554
+ * back to a real fetch rather than inventing state.
555
+ */
556
+ upsertRecord(key: string, record: ClientListFetchRecord, config: NormalizedClientListConfiguration): boolean;
557
+ /**
558
+ * Drops a record the backend has deleted, without re-fetching. Returns
559
+ * `false` when the record is not in the loaded set, so the caller can decide
560
+ * whether a reload is warranted.
561
+ */
562
+ removeRecord(key: string, recordId: number, config: NormalizedClientListConfiguration): boolean;
563
+ private upsertRowRecord;
564
+ private upsertCardRecord;
565
+ /**
566
+ * Overlays the written record on the one being replaced, key by key. A
567
+ * cleared property comes back explicitly (`{ raw: null, value: null }`) and
568
+ * overwrites; only a key the backend left out entirely keeps its previous
569
+ * cell, which beats blanking a value that did not actually change.
570
+ */
571
+ private mergeRecord;
572
+ private withRecords;
573
+ private patchItem;
490
574
  /**
491
575
  * Appends `next` to `current`, dropping any card whose id is already
492
576
  * present. Ids are the grid's `@for` track key, so duplicates are a runtime
@@ -539,6 +623,14 @@ declare class ClientList implements OnDestroy {
539
623
  private readonly inFlightRequestSignatures;
540
624
  private readonly fulfilledRequestSignatures;
541
625
  private readonly runtimeFilters;
626
+ /**
627
+ * The `propertyKeys` the last table request carried, per item. `undefined`
628
+ * means the request left the projection to the backend, which is a distinct
629
+ * state from "not loaded yet" — hence the map rather than a nullable field.
630
+ */
631
+ private readonly requestPropertyKeys;
632
+ /** Single-record read-backs, kept apart from the page loads they must not cancel. */
633
+ private readonly recordSubscriptions;
542
634
  constructor();
543
635
  onLazyLoad(itemKey: string, event: ClientListLazyLoadEvent): void;
544
636
  /**
@@ -556,6 +648,40 @@ declare class ClientList implements OnDestroy {
556
648
  loadMoreCards(itemKey: string): void;
557
649
  reload(itemKey?: string): void;
558
650
  reloadByKey(itemKey: string): void;
651
+ /**
652
+ * The query settings this list renders with, shaped as the `returnRecord`
653
+ * block of a `process-submit` payload. Send it with a create/update so the
654
+ * backend projects the written record the way this list reads records, then
655
+ * hand the response to {@link applyWriteResult} — that pair replaces the
656
+ * full page re-fetch a write used to cost.
657
+ *
658
+ * Returns `null` for an informative dashboard (no records to project) or an
659
+ * unknown key.
660
+ */
661
+ getReturnRecordRequest(itemKey: string): ClientListReturnRecordRequest | null;
662
+ /**
663
+ * Applies a create/update to the list in place, without re-fetching the
664
+ * page. Pass the `process-submit` response as-is.
665
+ *
666
+ * Three outcomes, in the order they are tried:
667
+ * - the write carried a usable record projection → splice it in, no request;
668
+ * - it did not (`recordProjectionStatus: 'Unavailable'`, or the list has
669
+ * nothing to splice into) → read that one record back by id. The write
670
+ * already succeeded; this only reads, and never re-submits;
671
+ * - nothing identifies the record at all → reload the page, as before.
672
+ *
673
+ * An approval-queued submit is a no-op: nothing has been written yet.
674
+ *
675
+ * Note that the list cannot know where the backend would have sorted a new
676
+ * record, so an insert lands at the top of the page in view.
677
+ */
678
+ applyWriteResult(itemKey: string, result: ClientListRecordWriteResult | null | undefined): void;
679
+ /**
680
+ * Drops a deleted record from the list in place. Falls back to a reload when
681
+ * the record is not part of the loaded set, so a stale list still corrects
682
+ * itself.
683
+ */
684
+ removeRecord(itemKey: string, recordId: number): void;
559
685
  toggleExpanded(key: string): void;
560
686
  onTableRowClick(item: ClientListState, row: RuntimeTableDisplayRow): void;
561
687
  onCardClick(item: ClientListState, card: ClientListCard): void;
@@ -592,6 +718,31 @@ declare class ClientList implements OnDestroy {
592
718
  private normalizeActionKey;
593
719
  private toFiniteNumber;
594
720
  private executeRuntimeAction;
721
+ /**
722
+ * A submit that only queued an approval request has written nothing — the
723
+ * record it describes does not exist yet, so the list must not move.
724
+ */
725
+ private isPendingApprovalWrite;
726
+ /**
727
+ * The canonical record from a write response, or `null` when there is none
728
+ * to trust. A backend that has not shipped the canonical projection yet
729
+ * answers with neither `recordProjectionStatus: 'Available'` nor `values`,
730
+ * and falls through to the read-back path — which is why this is a plain
731
+ * shape check and not a parse of alternative record shapes.
732
+ */
733
+ private toWriteRecord;
734
+ /**
735
+ * Reads one record back through `fetch/query` with this list's own settings.
736
+ * Taken when the write could not project the record itself — the write has
737
+ * already happened, so this reads and never re-submits.
738
+ */
739
+ private readRecordBack;
740
+ /**
741
+ * Runs the tail of a load for a list that changed without one: the row
742
+ * action cache is stale (a written record's available actions follow its new
743
+ * state), and hosts hang work off `dataLoaded` / `loaded`.
744
+ */
745
+ private afterRecordApplied;
595
746
  private toRuntimeActionsContext;
596
747
  private resolveRecordId;
597
748
  templateContext(item: ClientListState): ClientListContentTemplateContext;
@@ -635,7 +786,19 @@ declare class ClientListApiService {
635
786
  private readonly http;
636
787
  private readonly runtimeFetchBaseUrl;
637
788
  private readonly informativeBaseUrl;
638
- getRows(contextKey: ClientListRuntimeContext, query: ClientListTableQuery, filters?: ClientListFetchRequestFilter[]): Observable<Response<RuntimeTableRowsResponse>>;
789
+ /**
790
+ * Fetches a table page. Resolves to the response **and** the `propertyKeys`
791
+ * the request carried, because a write that wants its record projected the
792
+ * same way has to repeat them and cannot recover them from the response.
793
+ */
794
+ getRows(contextKey: ClientListRuntimeContext, query: ClientListTableQuery, filters?: ClientListFetchRequestFilter[]): Observable<ClientListRowsFetchResult>;
795
+ /**
796
+ * Reads a single record back with the list's own query settings — the path
797
+ * taken when a write reports `recordProjectionStatus: 'Unavailable'`. The
798
+ * write itself already succeeded; this only reads, and must never be served
799
+ * by re-submitting.
800
+ */
801
+ getRecord(contextKey: ClientListRuntimeContext, request: ClientListReturnRecordRequest, filters: ClientListFetchRequestFilter[]): Observable<Response<ClientListFetchQueryResponse>>;
639
802
  getCards(contextKey: ClientListRuntimeContext, filters?: ClientListFetchRequestFilter[], skip?: number, take?: number): Observable<Response<ClientListCardsPayload>>;
640
803
  getInformativeDashboard(levelId: number, moduleId: number): Observable<Response<ClientListInformativeDashboardPayload>>;
641
804
  private queryRuntime;
@@ -710,5 +873,5 @@ declare class ClientListToolbarService {
710
873
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<ClientListToolbarService>;
711
874
  }
712
875
 
713
- export { CLIENT_LIST_RECORD_STATE_KEY, ClientList, ClientListApiService, ClientListRuntimeActionsService, ClientListStateService, ClientListToolbarService, defaultResolveRecordId };
714
- export type { ClientListAreaType, ClientListBaseConfiguration, ClientListBaseState, ClientListCard, ClientListCardModule, ClientListCardProperty, ClientListCardsPayload, ClientListCardsState, ClientListClickableItem, ClientListCollapseConfig, ClientListConfiguration, ClientListContentTemplateContext, ClientListDataLoadedHandler, ClientListFetchCardDisplayOrderItem, ClientListFetchCardGroup, ClientListFetchCatalog, ClientListFetchProjection, ClientListFetchProjectionMeta, ClientListFetchPropertyMeta, ClientListFetchQueryRequest, ClientListFetchQueryResponse, ClientListFetchRecord, ClientListFetchRecordState, ClientListFetchRequestDisplay, ClientListFetchRequestFilter, ClientListFetchSchema, ClientListFetchStateKey, ClientListFetchTableColumn, ClientListFetchValueCell, ClientListFormConfiguration, ClientListInformativeChartLink, ClientListInformativeConfiguration, ClientListInformativeDashboardPayload, ClientListInformativeState, ClientListItemClickedEvent, ClientListLayoutConfig, ClientListLazyLoadEvent, ClientListMode, ClientListRecordEscalationState, ClientListRuntimeContext, ClientListRuntimeRecordActionsConfig, ClientListRuntimeRecordActionsContext, ClientListState, ClientListTableDisplayConfig, ClientListTablePersistStateKey, ClientListTableQuery, ClientListTableSettingsCatalogResponse, ClientListTableSettingsColumn, ClientListTableState, ClientListTableTransform, ClientListTableTransformResult, ClientListToolbarBucket, ClientListType, NormalizedClientListConfiguration, NormalizedClientListTableDisplayConfig, Response, RuntimeEntityColumnDef, RuntimeTableDisplayRow, RuntimeTableRowsResponse };
876
+ export { CLIENT_LIST_DEFAULT_INCLUDE_STATE, CLIENT_LIST_RECORD_ID_FILTER_KEY, CLIENT_LIST_RECORD_STATE_KEY, ClientList, ClientListApiService, ClientListRuntimeActionsService, ClientListStateService, ClientListToolbarService, defaultResolveRecordId };
877
+ export type { ClientListAreaType, ClientListBaseConfiguration, ClientListBaseState, ClientListCard, ClientListCardModule, ClientListCardProperty, ClientListCardsPayload, ClientListCardsState, ClientListClickableItem, ClientListCollapseConfig, ClientListConfiguration, ClientListContentTemplateContext, ClientListDataLoadedHandler, ClientListFetchCardDisplayOrderItem, ClientListFetchCardGroup, ClientListFetchCatalog, ClientListFetchProjection, ClientListFetchProjectionMeta, ClientListFetchPropertyMeta, ClientListFetchQueryRequest, ClientListFetchQueryResponse, ClientListFetchRecord, ClientListFetchRecordState, ClientListFetchRequestDisplay, ClientListFetchRequestFilter, ClientListFetchSchema, ClientListFetchStateKey, ClientListFetchTableColumn, ClientListFetchValueCell, ClientListFormConfiguration, ClientListInformativeChartLink, ClientListInformativeConfiguration, ClientListInformativeDashboardPayload, ClientListInformativeState, ClientListItemClickedEvent, ClientListLayoutConfig, ClientListLazyLoadEvent, ClientListMode, ClientListRecordEscalationState, ClientListRecordProjectionStatus, ClientListRecordWriteResult, ClientListReturnRecordRequest, ClientListRowsFetchResult, ClientListRuntimeContext, ClientListRuntimeRecordActionsConfig, ClientListRuntimeRecordActionsContext, ClientListState, ClientListTableDisplayConfig, ClientListTablePersistStateKey, ClientListTableQuery, ClientListTableSettingsCatalogResponse, ClientListTableSettingsColumn, ClientListTableState, ClientListTableTransform, ClientListTableTransformResult, ClientListToolbarBucket, ClientListType, NormalizedClientListConfiguration, NormalizedClientListTableDisplayConfig, Response, RuntimeEntityColumnDef, RuntimeTableDisplayRow, RuntimeTableRowsResponse };