@mintplayer/ng-spark 22.11.0 → 22.12.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/fesm2022/mintplayer-ng-spark-client-operations.mjs +113 -5
- package/fesm2022/mintplayer-ng-spark-client-operations.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-grid.mjs +24 -1
- package/fesm2022/mintplayer-ng-spark-grid.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-models.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-pipes.mjs +6 -0
- package/fesm2022/mintplayer-ng-spark-pipes.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-po-detail.mjs +110 -4
- package/fesm2022/mintplayer-ng-spark-po-detail.mjs.map +1 -1
- package/fesm2022/mintplayer-ng-spark-services.mjs +23 -5
- package/fesm2022/mintplayer-ng-spark-services.mjs.map +1 -1
- package/package.json +1 -1
- package/types/mintplayer-ng-spark-client-operations.d.ts +86 -6
- package/types/mintplayer-ng-spark-grid.d.ts +13 -0
- package/types/mintplayer-ng-spark-models.d.ts +32 -0
- package/types/mintplayer-ng-spark-po-detail.d.ts +33 -0
- package/types/mintplayer-ng-spark-services.d.ts +21 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, inject, Injectable, signal, ChangeDetectionStrategy, Component, makeEnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
3
4
|
|
|
4
5
|
// Wire types matching MintPlayer.Spark.Abstractions.ClientOperations on the server.
|
|
5
6
|
// Discriminator is the `type` field. Unknown operation types are silently dropped
|
|
@@ -145,6 +146,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
145
146
|
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".spark-toast-container{position:fixed;top:1rem;right:1rem;z-index:9999;display:flex;flex-direction:column;gap:.5rem;pointer-events:none}.spark-toast{padding:.75rem 1rem;border-radius:4px;box-shadow:0 2px 8px #00000026;cursor:pointer;min-width:220px;max-width:400px;color:#fff;font-size:.95rem;pointer-events:auto;animation:spark-toast-in .18s ease-out}.spark-toast--info{background:#0d6efd}.spark-toast--success{background:#198754}.spark-toast--warning{background:#ffc107;color:#000}.spark-toast--error{background:#dc3545}@keyframes spark-toast-in{0%{opacity:0;transform:translate(8px)}to{opacity:1;transform:translate(0)}}\n"] }]
|
|
146
147
|
}] });
|
|
147
148
|
|
|
149
|
+
class SparkAttributeRefreshService {
|
|
150
|
+
tokens = signal({}, /* @ts-ignore */
|
|
151
|
+
...(ngDevMode ? [{ debugName: "tokens" }] : /* istanbul ignore next */ []));
|
|
152
|
+
patches = signal({}, /* @ts-ignore */
|
|
153
|
+
...(ngDevMode ? [{ debugName: "patches" }] : /* istanbul ignore next */ []));
|
|
154
|
+
/**
|
|
155
|
+
* Objects are keyed by type AND id: the same id can exist under two types, and a detail page
|
|
156
|
+
* only ever wants the attributes meant for the object it is showing.
|
|
157
|
+
*/
|
|
158
|
+
static keyFor(objectTypeId, id) {
|
|
159
|
+
return `${objectTypeId}${id}`;
|
|
160
|
+
}
|
|
161
|
+
/** Bumped every time the server patches an attribute of this object. */
|
|
162
|
+
tokenFor(objectTypeId, id) {
|
|
163
|
+
if (!objectTypeId || !id)
|
|
164
|
+
return 0;
|
|
165
|
+
return this.tokens()[SparkAttributeRefreshService.keyFor(objectTypeId, id)] ?? 0;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The newest value the server sent for each patched attribute of this object.
|
|
169
|
+
*
|
|
170
|
+
* Cumulative rather than drained on read: a detail page that mounts after the operation arrived
|
|
171
|
+
* still sees the value, and two pages showing the same object both get it. Values are overwritten
|
|
172
|
+
* by later patches, so this holds one entry per attribute, not a history.
|
|
173
|
+
*/
|
|
174
|
+
patchesFor(objectTypeId, id) {
|
|
175
|
+
if (!objectTypeId || !id)
|
|
176
|
+
return {};
|
|
177
|
+
return this.patches()[SparkAttributeRefreshService.keyFor(objectTypeId, id)] ?? {};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Record a new value for one attribute and wake whoever is showing the object.
|
|
181
|
+
*
|
|
182
|
+
* Callers patching several attributes for one user action should do so in one synchronous run:
|
|
183
|
+
* the signals coalesce within a tick into a single effect run, and patches split across an await
|
|
184
|
+
* become one run each.
|
|
185
|
+
*/
|
|
186
|
+
request(objectTypeId, id, attributeName, patch) {
|
|
187
|
+
const key = SparkAttributeRefreshService.keyFor(objectTypeId, id);
|
|
188
|
+
this.patches.update(current => ({
|
|
189
|
+
...current,
|
|
190
|
+
[key]: { ...(current[key] ?? {}), [attributeName]: patch },
|
|
191
|
+
}));
|
|
192
|
+
this.tokens.update(current => ({ ...current, [key]: (current[key] ?? 0) + 1 }));
|
|
193
|
+
}
|
|
194
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SparkAttributeRefreshService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
195
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SparkAttributeRefreshService, providedIn: 'root' });
|
|
196
|
+
}
|
|
197
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: SparkAttributeRefreshService, decorators: [{
|
|
198
|
+
type: Injectable,
|
|
199
|
+
args: [{ providedIn: 'root' }]
|
|
200
|
+
}] });
|
|
201
|
+
|
|
148
202
|
/**
|
|
149
203
|
* Carries a server-issued `refreshQuery` to whichever grids are showing that query.
|
|
150
204
|
*
|
|
@@ -188,13 +242,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImpor
|
|
|
188
242
|
}] });
|
|
189
243
|
|
|
190
244
|
/**
|
|
191
|
-
* Registers the built-in client-operation handlers: `notify
|
|
192
|
-
* Apps add this once in their bootstrap providers.
|
|
245
|
+
* Registers the built-in client-operation handlers: `notify`, `refreshQuery`,
|
|
246
|
+
* `refreshAttribute` and `navigate`. Apps add this once in their bootstrap providers.
|
|
193
247
|
*
|
|
194
248
|
* Unregistered operation types are dropped SILENTLY by the dispatcher, which is why
|
|
195
249
|
* `refreshQuery` did nothing at all for as long as it went unhandled — the server emitted
|
|
196
|
-
* it, nothing listened, and no error said so.
|
|
197
|
-
*
|
|
250
|
+
* it, nothing listened, and no error said so.
|
|
251
|
+
*
|
|
252
|
+
* That happened twice more before anyone noticed. `refreshAttribute` and `navigate` were both
|
|
253
|
+
* declared wire types with no handler anywhere in the repository: every
|
|
254
|
+
* `IClientAccessor.RefreshAttribute` and `Navigate` call in every Spark application was
|
|
255
|
+
* computed, serialised, sent and discarded. Both are registered below. The remaining gap is
|
|
256
|
+
* `disableAction`, registered purely to log so that it stays visible rather than invisible.
|
|
257
|
+
*
|
|
258
|
+
* The lesson worth keeping: a wire type in `operations.ts` is not a feature. Adding one without
|
|
259
|
+
* a handler here produces a server API that appears to work and does nothing.
|
|
198
260
|
*
|
|
199
261
|
* To register custom operation types alongside the built-ins, add additional
|
|
200
262
|
* `multi: true` providers using <see cref="SPARK_CLIENT_OPERATION_HANDLERS" />.
|
|
@@ -228,6 +290,52 @@ function provideSparkClientOperations() {
|
|
|
228
290
|
},
|
|
229
291
|
multi: true,
|
|
230
292
|
},
|
|
293
|
+
{
|
|
294
|
+
provide: SPARK_CLIENT_OPERATION_HANDLERS,
|
|
295
|
+
useFactory: () => {
|
|
296
|
+
const attributes = inject(SparkAttributeRefreshService);
|
|
297
|
+
return {
|
|
298
|
+
type: 'refreshAttribute',
|
|
299
|
+
handler: (operation) => {
|
|
300
|
+
const patch = operation;
|
|
301
|
+
// Forwarded field by field, not as one value: an AsDetail attribute's rows
|
|
302
|
+
// travel in object/objects and its value is null, so collapsing them here
|
|
303
|
+
// is what made a detail-grid refresh impossible to express.
|
|
304
|
+
attributes.request(patch.objectTypeId, patch.id, patch.attributeName, {
|
|
305
|
+
value: patch.value,
|
|
306
|
+
object: patch.object,
|
|
307
|
+
objects: patch.objects,
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
multi: true,
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
provide: SPARK_CLIENT_OPERATION_HANDLERS,
|
|
316
|
+
useFactory: () => {
|
|
317
|
+
const router = inject(Router);
|
|
318
|
+
return {
|
|
319
|
+
type: 'navigate',
|
|
320
|
+
handler: (operation) => {
|
|
321
|
+
const navigate = operation;
|
|
322
|
+
if (navigate.routeName) {
|
|
323
|
+
void router.navigateByUrl(navigate.routeName.startsWith('/') ? navigate.routeName : `/${navigate.routeName}`);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
// `/po/{type}/{id}` is the convention the grid's row links already assume,
|
|
327
|
+
// and the detail route resolves a type by id as well as by alias, so the
|
|
328
|
+
// operation's objectTypeId can be used verbatim.
|
|
329
|
+
if (navigate.objectTypeId && navigate.id) {
|
|
330
|
+
void router.navigate(['/po', navigate.objectTypeId, navigate.id]);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
console.warn('[spark] navigate operation carried neither routeName nor objectTypeId+id; ignored.');
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
},
|
|
337
|
+
multi: true,
|
|
338
|
+
},
|
|
231
339
|
{
|
|
232
340
|
provide: SPARK_CLIENT_OPERATION_HANDLERS,
|
|
233
341
|
useFactory: () => ({
|
|
@@ -250,5 +358,5 @@ function provideSparkClientOperations() {
|
|
|
250
358
|
* Generated bundle index. Do not edit.
|
|
251
359
|
*/
|
|
252
360
|
|
|
253
|
-
export { NotificationKind, SPARK_CLIENT_OPERATION_HANDLERS, SparkClientOperationDispatcher, SparkNotificationService, SparkQueryRefreshService, SparkToastContainerComponent, provideSparkClientOperations };
|
|
361
|
+
export { NotificationKind, SPARK_CLIENT_OPERATION_HANDLERS, SparkAttributeRefreshService, SparkClientOperationDispatcher, SparkNotificationService, SparkQueryRefreshService, SparkToastContainerComponent, provideSparkClientOperations };
|
|
254
362
|
//# sourceMappingURL=mintplayer-ng-spark-client-operations.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mintplayer-ng-spark-client-operations.mjs","sources":["../../client-operations/src/operations.ts","../../client-operations/src/handlers.token.ts","../../client-operations/src/dispatcher.service.ts","../../client-operations/src/notification.service.ts","../../client-operations/src/toast-container.component.ts","../../client-operations/src/query-refresh.service.ts","../../client-operations/src/provide.ts","../../client-operations/mintplayer-ng-spark-client-operations.ts"],"sourcesContent":["// Wire types matching MintPlayer.Spark.Abstractions.ClientOperations on the server.\n// Discriminator is the `type` field. Unknown operation types are silently dropped\n// by the dispatcher (forward-compat: new types can land server-side without updating\n// older clients).\n\nimport type { PersistentObject } from '@mintplayer/ng-spark/models';\n\nexport enum NotificationKind {\n Info = 0,\n Success = 1,\n Warning = 2,\n Error = 3,\n}\n\nexport interface NavigateOperation {\n type: 'navigate';\n objectTypeId?: string;\n id?: string;\n routeName?: string;\n}\n\nexport interface NotifyOperation {\n type: 'notify';\n message: string;\n kind: NotificationKind;\n durationMs?: number;\n}\n\nexport interface RefreshAttributeOperation {\n type: 'refreshAttribute';\n objectTypeId: string;\n id: string;\n attributeName: string;\n value?: unknown;\n}\n\nexport interface RefreshQueryOperation {\n type: 'refreshQuery';\n queryId: string;\n}\n\nexport type DisableTarget =\n | { kind: 'persistentObject'; objectTypeId: string; id: string }\n | { kind: 'query'; queryId: string }\n | { kind: 'currentResponse' }\n | { kind: 'session' };\n\nexport interface DisableActionOperation {\n type: 'disableAction';\n actionName: string;\n target: DisableTarget;\n}\n\nexport interface RetryOperation {\n type: 'retry';\n step: number;\n title: string;\n options: string[];\n defaultOption?: string | null;\n persistentObject?: PersistentObject | null;\n message?: string | null;\n}\n\n/**\n * Discriminated union of known operation types, plus an open shape for unknown\n * future operations. Handlers should narrow via the `type` discriminator before\n * accessing fields specific to their operation type.\n */\nexport type ClientOperation =\n | NavigateOperation\n | NotifyOperation\n | RefreshAttributeOperation\n | RefreshQueryOperation\n | DisableActionOperation\n | RetryOperation\n | { type: string; [key: string]: unknown };\n\n/**\n * Wire envelope returned by every action endpoint. `result` carries the primary\n * payload (the PersistentObject for a Create, the QueryResult for an Execute,\n * etc.); `operations` carries the side-effects the frontend dispatches.\n */\nexport interface ClientOperationEnvelope<T = unknown> {\n result: T | null;\n operations: ClientOperation[];\n}\n","import { InjectionToken } from '@angular/core';\nimport type { ClientOperation } from './operations';\n\n/**\n * A handler for a specific operation type. Receives the operation and\n * executes the side-effect (e.g. show a toast, navigate, refresh a query).\n * Handlers should `as`-narrow the operation to the type they registered for.\n */\nexport type ClientOperationHandler = (operation: ClientOperation) => void;\n\n/**\n * One entry in the multi-provider registration. Apps can register custom\n * handlers alongside the built-in ones to extend the operation set with\n * app-specific operation types.\n */\nexport interface ClientOperationHandlerRegistration {\n type: string;\n handler: ClientOperationHandler;\n}\n\n/**\n * Multi-provider token. `provideSparkClientOperations()` registers the\n * built-in handlers; apps can add their own with additional `multi: true`\n * providers using this token.\n */\nexport const SPARK_CLIENT_OPERATION_HANDLERS = new InjectionToken<readonly ClientOperationHandlerRegistration[]>(\n 'SPARK_CLIENT_OPERATION_HANDLERS',\n);\n","import { Injectable, inject } from '@angular/core';\nimport type { ClientOperation } from './operations';\nimport { SPARK_CLIENT_OPERATION_HANDLERS, type ClientOperationHandler } from './handlers.token';\n\n/**\n * Routes received operations to registered handlers. Unknown operation types\n * (no matching registration) are silently dropped — this is the forward-compat\n * contract that lets new operation types ship server-side without coordinated\n * client updates.\n *\n * Last-registered-wins on duplicate `type` values, matching standard\n * Angular multi-provider override semantics.\n *\n * R2-H19 — security contract for handler authors:\n * The dispatcher treats handler resolution as allow-list-by-type (unknown\n * types drop). It does NOT validate the *content* of each operation. Handlers\n * that act on URL-shaped fields (navigate, redirect, openWindow) MUST run\n * the value through `sanitizeReturnUrl` from `@mintplayer/ng-spark-auth/models`\n * (or an equivalent same-origin check) before acting on it. Otherwise a\n * single attribute-echo XSS or a single mid-channel byte flip on a non-TLS\n * path lets the server drive client navigation to an attacker host. The\n * built-in `notify` handler renders via Angular interpolation (escaped) so\n * it's safe to pass through, but anything more powerful must validate.\n */\n@Injectable({ providedIn: 'root' })\nexport class SparkClientOperationDispatcher {\n private readonly handlerMap: ReadonlyMap<string, ClientOperationHandler>;\n\n constructor() {\n const registrations = inject(SPARK_CLIENT_OPERATION_HANDLERS, { optional: true }) ?? [];\n const map = new Map<string, ClientOperationHandler>();\n for (const { type, handler } of registrations) {\n map.set(type, handler);\n }\n this.handlerMap = map;\n }\n\n dispatch(operations: readonly ClientOperation[] | null | undefined): void {\n if (!operations || operations.length === 0) return;\n for (const operation of operations) {\n const handler = this.handlerMap.get(operation.type);\n if (handler) {\n handler(operation);\n }\n // Unknown types: silently dropped (forward-compat).\n }\n }\n}\n","import { Injectable, signal } from '@angular/core';\nimport { NotificationKind } from './operations';\n\nexport interface SparkToast {\n id: string;\n message: string;\n kind: NotificationKind;\n durationMs: number;\n}\n\nconst DEFAULT_DURATION_MS = 4000;\n\n/**\n * Holds the active toasts as a signal. The `<spark-toast-container>` component\n * renders them; the built-in `notify` operation handler pushes new toasts here.\n *\n * Auto-dismissal: each toast schedules its own removal after `durationMs`. Pass\n * `0` to make a toast sticky (manual dismissal only).\n */\n@Injectable({ providedIn: 'root' })\nexport class SparkNotificationService {\n private readonly _toasts = signal<readonly SparkToast[]>([]);\n readonly toasts = this._toasts.asReadonly();\n\n show(message: string, kind: NotificationKind = NotificationKind.Info, durationMs?: number): void {\n const id = typeof crypto !== 'undefined' && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random()}`;\n const effectiveDuration = durationMs ?? DEFAULT_DURATION_MS;\n const toast: SparkToast = { id, message, kind, durationMs: effectiveDuration };\n this._toasts.update(toasts => [...toasts, toast]);\n\n if (effectiveDuration > 0) {\n setTimeout(() => this.dismiss(id), effectiveDuration);\n }\n }\n\n dismiss(id: string): void {\n this._toasts.update(toasts => toasts.filter(t => t.id !== id));\n }\n\n clear(): void {\n this._toasts.set([]);\n }\n}\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { SparkNotificationService } from './notification.service';\nimport { NotificationKind } from './operations';\n\n@Component({\n selector: 'spark-toast-container',\n standalone: true,\n template: `\n <div class=\"spark-toast-container\">\n @for (toast of notifications.toasts(); track toast.id) {\n <div\n class=\"spark-toast\"\n [class.spark-toast--info]=\"toast.kind === Kind.Info\"\n [class.spark-toast--success]=\"toast.kind === Kind.Success\"\n [class.spark-toast--warning]=\"toast.kind === Kind.Warning\"\n [class.spark-toast--error]=\"toast.kind === Kind.Error\"\n (click)=\"notifications.dismiss(toast.id)\"\n >\n {{ toast.message }}\n </div>\n }\n </div>\n `,\n styles: [`\n .spark-toast-container {\n position: fixed;\n top: 1rem;\n right: 1rem;\n z-index: 9999;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n pointer-events: none;\n }\n .spark-toast {\n padding: 0.75rem 1rem;\n border-radius: 4px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n cursor: pointer;\n min-width: 220px;\n max-width: 400px;\n color: white;\n font-size: 0.95rem;\n pointer-events: auto;\n animation: spark-toast-in 0.18s ease-out;\n }\n .spark-toast--info { background: #0d6efd; }\n .spark-toast--success { background: #198754; }\n .spark-toast--warning { background: #ffc107; color: #000; }\n .spark-toast--error { background: #dc3545; }\n @keyframes spark-toast-in {\n from { opacity: 0; transform: translateX(8px); }\n to { opacity: 1; transform: translateX(0); }\n }\n `],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SparkToastContainerComponent {\n protected readonly notifications = inject(SparkNotificationService);\n protected readonly Kind = NotificationKind;\n}\n","import { Injectable, signal } from '@angular/core';\n\n/**\n * Carries a server-issued `refreshQuery` to whichever grids are showing that query.\n *\n * A broadcast signal rather than a registry of component handles: grids come and go behind\n * `@if` and lazy routes, and nothing else in ng-spark holds a component reference. A grid\n * reads {@link tokenFor} in an effect and re-fetches when it changes, which is the same\n * declarative shape as the `reloadToken` input a host would use.\n *\n * Until this existed the server could emit the operation and the dispatcher dropped it: only\n * `notify` was registered, and unknown types are ignored silently — so `refreshOnCompleted`\n * on the server had no effect on any grid the action did not happen to be hosted in.\n */\n@Injectable({ providedIn: 'root' })\nexport class SparkQueryRefreshService {\n private readonly tokens = signal<Record<string, number>>({});\n\n /** Bumped every time the server asks for this query to refresh. */\n tokenFor(queryId: string | undefined): number {\n if (!queryId) return 0;\n return this.tokens()[queryId] ?? 0;\n }\n\n /**\n * Ask every grid showing `queryId` to re-fetch.\n *\n * Matched on the EXACT string a grid passes to {@link tokenFor} -- whichever of id or alias\n * its `queryId` input holds. A caller that knows only the other form will not reach it.\n *\n * Callers bumping several keys for one user action should do so in one synchronous run: the\n * signal coalesces bumps within a tick into a single effect run, and bumps split across an\n * await become one re-fetch each.\n */\n request(queryId: string): void {\n this.tokens.update(current => ({ ...current, [queryId]: (current[queryId] ?? 0) + 1 }));\n }\n}\n","import { type EnvironmentProviders, inject, makeEnvironmentProviders } from '@angular/core';\nimport type { ClientOperation, DisableActionOperation, NotifyOperation, RefreshQueryOperation } from './operations';\nimport { SPARK_CLIENT_OPERATION_HANDLERS } from './handlers.token';\nimport { SparkNotificationService } from './notification.service';\nimport { SparkQueryRefreshService } from './query-refresh.service';\n\n/**\n * Registers the built-in client-operation handlers: `notify` and `refreshQuery`.\n * Apps add this once in their bootstrap providers.\n *\n * Unregistered operation types are dropped SILENTLY by the dispatcher, which is why\n * `refreshQuery` did nothing at all for as long as it went unhandled — the server emitted\n * it, nothing listened, and no error said so. `disableAction` is in that state today: it is\n * registered below purely to log, so the gap is visible rather than invisible.\n *\n * To register custom operation types alongside the built-ins, add additional\n * `multi: true` providers using <see cref=\"SPARK_CLIENT_OPERATION_HANDLERS\" />.\n */\nexport function provideSparkClientOperations(): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: SPARK_CLIENT_OPERATION_HANDLERS,\n useFactory: () => {\n const notifications = inject(SparkNotificationService);\n return {\n type: 'notify',\n handler: (operation: ClientOperation) => {\n const notify = operation as NotifyOperation;\n notifications.show(notify.message, notify.kind, notify.durationMs);\n },\n };\n },\n multi: true,\n },\n {\n provide: SPARK_CLIENT_OPERATION_HANDLERS,\n useFactory: () => {\n const refresh = inject(SparkQueryRefreshService);\n return {\n type: 'refreshQuery',\n handler: (operation: ClientOperation) => {\n refresh.request((operation as RefreshQueryOperation).queryId);\n },\n };\n },\n multi: true,\n },\n {\n provide: SPARK_CLIENT_OPERATION_HANDLERS,\n useFactory: () => ({\n type: 'disableAction',\n handler: (operation: ClientOperation) => {\n // Deliberately a no-op with a warning, not silence. The server's\n // IClientAccessor.DisableQueryActions presumes a client that honours it;\n // nothing renders the disabled state yet, and a silently dropped operation\n // reads as \"the server did not send it\" when debugging.\n const disable = operation as DisableActionOperation;\n console.warn(\n `[spark] disableAction('${disable.actionName}') is not implemented by this client; the action stays enabled.`);\n },\n }),\n multi: true,\n },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;IAIY;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AACxB,IAAA,gBAAA,CAAA,gBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,gBAAA,CAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAW;AACX,IAAA,gBAAA,CAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAW;AACX,IAAA,gBAAA,CAAA,gBAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACb,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,GAAA,EAAA,CAAA,CAAA;;ACa5B;;;;AAIG;MACU,+BAA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OAAO,GAAG,MAAM,CAAC,wBAAwB,CAAC;gBAChD,OAAO;AACH,oBAAA,IAAI,EAAE,cAAc;AACpB,oBAAA,OAAO,EAAE,CAAC,SAA0B,KAAI;AACpC,wBAAA,OAAO,CAAC,OAAO,CAAE,SAAmC,CAAC,OAAO,CAAC;oBACjE,CAAC;iBACJ;YACL,CAAC;AACD,YAAA,KAAK,EAAE,IAAI;AACd,SAAA;AACD,QAAA;AACI,YAAA,OAAO,EAAE,+BAA+B;AACxC,YAAA,UAAU,EAAE,OAAO;AACf,gBAAA,IAAI,EAAE,eAAe;AACrB,gBAAA,OAAO,EAAE,CAAC,SAA0B,KAAI;;;;;oBAKpC,MAAM,OAAO,GAAG,SAAmC;oBACnD,OAAO,CAAC,IAAI,CACR,CAAA,uBAAA,EAA0B,OAAO,CAAC,UAAU,CAAA,+DAAA,CAAiE,CAAC;gBACtH,CAAC;aACJ,CAAC;AACF,YAAA,KAAK,EAAE,IAAI;AACd,SAAA;AACJ,KAAA,CAAC;AACN;;AChEA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"mintplayer-ng-spark-client-operations.mjs","sources":["../../client-operations/src/operations.ts","../../client-operations/src/handlers.token.ts","../../client-operations/src/dispatcher.service.ts","../../client-operations/src/notification.service.ts","../../client-operations/src/toast-container.component.ts","../../client-operations/src/attribute-refresh.service.ts","../../client-operations/src/query-refresh.service.ts","../../client-operations/src/provide.ts","../../client-operations/mintplayer-ng-spark-client-operations.ts"],"sourcesContent":["// Wire types matching MintPlayer.Spark.Abstractions.ClientOperations on the server.\n// Discriminator is the `type` field. Unknown operation types are silently dropped\n// by the dispatcher (forward-compat: new types can land server-side without updating\n// older clients).\n\nimport type { PersistentObject } from '@mintplayer/ng-spark/models';\n\nexport enum NotificationKind {\n Info = 0,\n Success = 1,\n Warning = 2,\n Error = 3,\n}\n\nexport interface NavigateOperation {\n type: 'navigate';\n objectTypeId?: string;\n id?: string;\n routeName?: string;\n}\n\nexport interface NotifyOperation {\n type: 'notify';\n message: string;\n kind: NotificationKind;\n durationMs?: number;\n}\n\nexport interface RefreshAttributeOperation {\n type: 'refreshAttribute';\n objectTypeId: string;\n id: string;\n attributeName: string;\n value?: unknown;\n\n /**\n * Nested rows of an `AsDetail` attribute. A loaded AsDetail attribute carries its rows in\n * `object` / `objects` and leaves `value` null, so a patch limited to `value` could never\n * refresh a detail grid -- it always sent null, and a null over a null repaints nothing.\n *\n * An empty `objects` array means the grid is now empty, and is distinct from omitting it.\n */\n object?: unknown;\n objects?: unknown[];\n}\n\nexport interface RefreshQueryOperation {\n type: 'refreshQuery';\n queryId: string;\n}\n\nexport type DisableTarget =\n | { kind: 'persistentObject'; objectTypeId: string; id: string }\n | { kind: 'query'; queryId: string }\n | { kind: 'currentResponse' }\n | { kind: 'session' };\n\nexport interface DisableActionOperation {\n type: 'disableAction';\n actionName: string;\n target: DisableTarget;\n}\n\nexport interface RetryOperation {\n type: 'retry';\n step: number;\n title: string;\n options: string[];\n defaultOption?: string | null;\n persistentObject?: PersistentObject | null;\n message?: string | null;\n}\n\n/**\n * Discriminated union of known operation types, plus an open shape for unknown\n * future operations. Handlers should narrow via the `type` discriminator before\n * accessing fields specific to their operation type.\n */\nexport type ClientOperation =\n | NavigateOperation\n | NotifyOperation\n | RefreshAttributeOperation\n | RefreshQueryOperation\n | DisableActionOperation\n | RetryOperation\n | { type: string; [key: string]: unknown };\n\n/**\n * Wire envelope returned by every action endpoint. `result` carries the primary\n * payload (the PersistentObject for a Create, the QueryResult for an Execute,\n * etc.); `operations` carries the side-effects the frontend dispatches.\n */\nexport interface ClientOperationEnvelope<T = unknown> {\n result: T | null;\n operations: ClientOperation[];\n}\n","import { InjectionToken } from '@angular/core';\nimport type { ClientOperation } from './operations';\n\n/**\n * A handler for a specific operation type. Receives the operation and\n * executes the side-effect (e.g. show a toast, navigate, refresh a query).\n * Handlers should `as`-narrow the operation to the type they registered for.\n */\nexport type ClientOperationHandler = (operation: ClientOperation) => void;\n\n/**\n * One entry in the multi-provider registration. Apps can register custom\n * handlers alongside the built-in ones to extend the operation set with\n * app-specific operation types.\n */\nexport interface ClientOperationHandlerRegistration {\n type: string;\n handler: ClientOperationHandler;\n}\n\n/**\n * Multi-provider token. `provideSparkClientOperations()` registers the\n * built-in handlers; apps can add their own with additional `multi: true`\n * providers using this token.\n */\nexport const SPARK_CLIENT_OPERATION_HANDLERS = new InjectionToken<readonly ClientOperationHandlerRegistration[]>(\n 'SPARK_CLIENT_OPERATION_HANDLERS',\n);\n","import { Injectable, inject } from '@angular/core';\nimport type { ClientOperation } from './operations';\nimport { SPARK_CLIENT_OPERATION_HANDLERS, type ClientOperationHandler } from './handlers.token';\n\n/**\n * Routes received operations to registered handlers. Unknown operation types\n * (no matching registration) are silently dropped — this is the forward-compat\n * contract that lets new operation types ship server-side without coordinated\n * client updates.\n *\n * Last-registered-wins on duplicate `type` values, matching standard\n * Angular multi-provider override semantics.\n *\n * R2-H19 — security contract for handler authors:\n * The dispatcher treats handler resolution as allow-list-by-type (unknown\n * types drop). It does NOT validate the *content* of each operation. Handlers\n * that act on URL-shaped fields (navigate, redirect, openWindow) MUST run\n * the value through `sanitizeReturnUrl` from `@mintplayer/ng-spark-auth/models`\n * (or an equivalent same-origin check) before acting on it. Otherwise a\n * single attribute-echo XSS or a single mid-channel byte flip on a non-TLS\n * path lets the server drive client navigation to an attacker host. The\n * built-in `notify` handler renders via Angular interpolation (escaped) so\n * it's safe to pass through, but anything more powerful must validate.\n */\n@Injectable({ providedIn: 'root' })\nexport class SparkClientOperationDispatcher {\n private readonly handlerMap: ReadonlyMap<string, ClientOperationHandler>;\n\n constructor() {\n const registrations = inject(SPARK_CLIENT_OPERATION_HANDLERS, { optional: true }) ?? [];\n const map = new Map<string, ClientOperationHandler>();\n for (const { type, handler } of registrations) {\n map.set(type, handler);\n }\n this.handlerMap = map;\n }\n\n dispatch(operations: readonly ClientOperation[] | null | undefined): void {\n if (!operations || operations.length === 0) return;\n for (const operation of operations) {\n const handler = this.handlerMap.get(operation.type);\n if (handler) {\n handler(operation);\n }\n // Unknown types: silently dropped (forward-compat).\n }\n }\n}\n","import { Injectable, signal } from '@angular/core';\nimport { NotificationKind } from './operations';\n\nexport interface SparkToast {\n id: string;\n message: string;\n kind: NotificationKind;\n durationMs: number;\n}\n\nconst DEFAULT_DURATION_MS = 4000;\n\n/**\n * Holds the active toasts as a signal. The `<spark-toast-container>` component\n * renders them; the built-in `notify` operation handler pushes new toasts here.\n *\n * Auto-dismissal: each toast schedules its own removal after `durationMs`. Pass\n * `0` to make a toast sticky (manual dismissal only).\n */\n@Injectable({ providedIn: 'root' })\nexport class SparkNotificationService {\n private readonly _toasts = signal<readonly SparkToast[]>([]);\n readonly toasts = this._toasts.asReadonly();\n\n show(message: string, kind: NotificationKind = NotificationKind.Info, durationMs?: number): void {\n const id = typeof crypto !== 'undefined' && crypto.randomUUID ? crypto.randomUUID() : `${Date.now()}-${Math.random()}`;\n const effectiveDuration = durationMs ?? DEFAULT_DURATION_MS;\n const toast: SparkToast = { id, message, kind, durationMs: effectiveDuration };\n this._toasts.update(toasts => [...toasts, toast]);\n\n if (effectiveDuration > 0) {\n setTimeout(() => this.dismiss(id), effectiveDuration);\n }\n }\n\n dismiss(id: string): void {\n this._toasts.update(toasts => toasts.filter(t => t.id !== id));\n }\n\n clear(): void {\n this._toasts.set([]);\n }\n}\n","import { ChangeDetectionStrategy, Component, inject } from '@angular/core';\nimport { SparkNotificationService } from './notification.service';\nimport { NotificationKind } from './operations';\n\n@Component({\n selector: 'spark-toast-container',\n standalone: true,\n template: `\n <div class=\"spark-toast-container\">\n @for (toast of notifications.toasts(); track toast.id) {\n <div\n class=\"spark-toast\"\n [class.spark-toast--info]=\"toast.kind === Kind.Info\"\n [class.spark-toast--success]=\"toast.kind === Kind.Success\"\n [class.spark-toast--warning]=\"toast.kind === Kind.Warning\"\n [class.spark-toast--error]=\"toast.kind === Kind.Error\"\n (click)=\"notifications.dismiss(toast.id)\"\n >\n {{ toast.message }}\n </div>\n }\n </div>\n `,\n styles: [`\n .spark-toast-container {\n position: fixed;\n top: 1rem;\n right: 1rem;\n z-index: 9999;\n display: flex;\n flex-direction: column;\n gap: 0.5rem;\n pointer-events: none;\n }\n .spark-toast {\n padding: 0.75rem 1rem;\n border-radius: 4px;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\n cursor: pointer;\n min-width: 220px;\n max-width: 400px;\n color: white;\n font-size: 0.95rem;\n pointer-events: auto;\n animation: spark-toast-in 0.18s ease-out;\n }\n .spark-toast--info { background: #0d6efd; }\n .spark-toast--success { background: #198754; }\n .spark-toast--warning { background: #ffc107; color: #000; }\n .spark-toast--error { background: #dc3545; }\n @keyframes spark-toast-in {\n from { opacity: 0; transform: translateX(8px); }\n to { opacity: 1; transform: translateX(0); }\n }\n `],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\nexport class SparkToastContainerComponent {\n protected readonly notifications = inject(SparkNotificationService);\n protected readonly Kind = NotificationKind;\n}\n","import { Injectable, signal } from '@angular/core';\n\n/**\n * Carries a server-issued `refreshAttribute` to whichever detail page is showing that object.\n *\n * The same broadcast shape as {@link SparkQueryRefreshService}, and for the same reason: detail\n * pages come and go behind `@if` and lazy routes, and nothing in ng-spark holds a component\n * reference. A page reads {@link tokenFor} in an effect and applies {@link patchesFor} when it\n * changes.\n *\n * Until this existed the operation was declared on the wire and handled by nobody: the server\n * computed the new values, serialised them, sent them, and the dispatcher dropped them silently\n * because unknown types are ignored. `IClientAccessor.RefreshAttribute` was inert in every Spark\n * application. It is what made the Coverage home page's Resync button look dead — it recomputed\n * the account and repository counts correctly on every click and none of them ever arrived.\n *\n * The operation carries the new value, so this is a patch and not a re-fetch: no round trip, and\n * no dependence on an index that may still be stale from the write that triggered it.\n */\n/**\n * The parts of an attribute a server patch may carry.\n *\n * Three fields rather than one value because a loaded attribute does not keep every shape in\n * `value`: an `AsDetail` attribute puts its nested rows in `object` / `objects` and leaves\n * `value` null. A patch limited to `value` was therefore incapable of refreshing a detail grid,\n * and did so silently -- see {@link SparkAttributeRefreshService}.\n *\n * Only the keys the server sent are present, and each is applied on its own. An `objects: []`\n * means the grid is now empty, which is why emptiness has to be distinguishable from absence.\n */\nexport interface SparkAttributePatch {\n value?: unknown;\n object?: unknown;\n objects?: unknown[];\n}\n\n@Injectable({ providedIn: 'root' })\nexport class SparkAttributeRefreshService {\n private readonly tokens = signal<Record<string, number>>({});\n private readonly patches = signal<Record<string, Record<string, SparkAttributePatch>>>({});\n\n /**\n * Objects are keyed by type AND id: the same id can exist under two types, and a detail page\n * only ever wants the attributes meant for the object it is showing.\n */\n private static keyFor(objectTypeId: string, id: string): string {\n return `${objectTypeId}${id}`;\n }\n\n /** Bumped every time the server patches an attribute of this object. */\n tokenFor(objectTypeId: string | undefined | null, id: string | undefined | null): number {\n if (!objectTypeId || !id) return 0;\n return this.tokens()[SparkAttributeRefreshService.keyFor(objectTypeId, id)] ?? 0;\n }\n\n /**\n * The newest value the server sent for each patched attribute of this object.\n *\n * Cumulative rather than drained on read: a detail page that mounts after the operation arrived\n * still sees the value, and two pages showing the same object both get it. Values are overwritten\n * by later patches, so this holds one entry per attribute, not a history.\n */\n patchesFor(objectTypeId: string | undefined | null, id: string | undefined | null): Record<string, SparkAttributePatch> {\n if (!objectTypeId || !id) return {};\n return this.patches()[SparkAttributeRefreshService.keyFor(objectTypeId, id)] ?? {};\n }\n\n /**\n * Record a new value for one attribute and wake whoever is showing the object.\n *\n * Callers patching several attributes for one user action should do so in one synchronous run:\n * the signals coalesce within a tick into a single effect run, and patches split across an await\n * become one run each.\n */\n request(objectTypeId: string, id: string, attributeName: string, patch: SparkAttributePatch): void {\n const key = SparkAttributeRefreshService.keyFor(objectTypeId, id);\n this.patches.update(current => ({\n ...current,\n [key]: { ...(current[key] ?? {}), [attributeName]: patch },\n }));\n this.tokens.update(current => ({ ...current, [key]: (current[key] ?? 0) + 1 }));\n }\n}\n","import { Injectable, signal } from '@angular/core';\n\n/**\n * Carries a server-issued `refreshQuery` to whichever grids are showing that query.\n *\n * A broadcast signal rather than a registry of component handles: grids come and go behind\n * `@if` and lazy routes, and nothing else in ng-spark holds a component reference. A grid\n * reads {@link tokenFor} in an effect and re-fetches when it changes, which is the same\n * declarative shape as the `reloadToken` input a host would use.\n *\n * Until this existed the server could emit the operation and the dispatcher dropped it: only\n * `notify` was registered, and unknown types are ignored silently — so `refreshOnCompleted`\n * on the server had no effect on any grid the action did not happen to be hosted in.\n */\n@Injectable({ providedIn: 'root' })\nexport class SparkQueryRefreshService {\n private readonly tokens = signal<Record<string, number>>({});\n\n /** Bumped every time the server asks for this query to refresh. */\n tokenFor(queryId: string | undefined): number {\n if (!queryId) return 0;\n return this.tokens()[queryId] ?? 0;\n }\n\n /**\n * Ask every grid showing `queryId` to re-fetch.\n *\n * Matched on the EXACT string a grid passes to {@link tokenFor} -- whichever of id or alias\n * its `queryId` input holds. A caller that knows only the other form will not reach it.\n *\n * Callers bumping several keys for one user action should do so in one synchronous run: the\n * signal coalesces bumps within a tick into a single effect run, and bumps split across an\n * await become one re-fetch each.\n */\n request(queryId: string): void {\n this.tokens.update(current => ({ ...current, [queryId]: (current[queryId] ?? 0) + 1 }));\n }\n}\n","import { type EnvironmentProviders, inject, makeEnvironmentProviders } from '@angular/core';\nimport { Router } from '@angular/router';\nimport type {\n ClientOperation,\n DisableActionOperation,\n NavigateOperation,\n NotifyOperation,\n RefreshAttributeOperation,\n RefreshQueryOperation,\n} from './operations';\nimport { SPARK_CLIENT_OPERATION_HANDLERS } from './handlers.token';\nimport { SparkAttributeRefreshService } from './attribute-refresh.service';\nimport { SparkNotificationService } from './notification.service';\nimport { SparkQueryRefreshService } from './query-refresh.service';\n\n/**\n * Registers the built-in client-operation handlers: `notify`, `refreshQuery`,\n * `refreshAttribute` and `navigate`. Apps add this once in their bootstrap providers.\n *\n * Unregistered operation types are dropped SILENTLY by the dispatcher, which is why\n * `refreshQuery` did nothing at all for as long as it went unhandled — the server emitted\n * it, nothing listened, and no error said so.\n *\n * That happened twice more before anyone noticed. `refreshAttribute` and `navigate` were both\n * declared wire types with no handler anywhere in the repository: every\n * `IClientAccessor.RefreshAttribute` and `Navigate` call in every Spark application was\n * computed, serialised, sent and discarded. Both are registered below. The remaining gap is\n * `disableAction`, registered purely to log so that it stays visible rather than invisible.\n *\n * The lesson worth keeping: a wire type in `operations.ts` is not a feature. Adding one without\n * a handler here produces a server API that appears to work and does nothing.\n *\n * To register custom operation types alongside the built-ins, add additional\n * `multi: true` providers using <see cref=\"SPARK_CLIENT_OPERATION_HANDLERS\" />.\n */\nexport function provideSparkClientOperations(): EnvironmentProviders {\n return makeEnvironmentProviders([\n {\n provide: SPARK_CLIENT_OPERATION_HANDLERS,\n useFactory: () => {\n const notifications = inject(SparkNotificationService);\n return {\n type: 'notify',\n handler: (operation: ClientOperation) => {\n const notify = operation as NotifyOperation;\n notifications.show(notify.message, notify.kind, notify.durationMs);\n },\n };\n },\n multi: true,\n },\n {\n provide: SPARK_CLIENT_OPERATION_HANDLERS,\n useFactory: () => {\n const refresh = inject(SparkQueryRefreshService);\n return {\n type: 'refreshQuery',\n handler: (operation: ClientOperation) => {\n refresh.request((operation as RefreshQueryOperation).queryId);\n },\n };\n },\n multi: true,\n },\n {\n provide: SPARK_CLIENT_OPERATION_HANDLERS,\n useFactory: () => {\n const attributes = inject(SparkAttributeRefreshService);\n return {\n type: 'refreshAttribute',\n handler: (operation: ClientOperation) => {\n const patch = operation as RefreshAttributeOperation;\n // Forwarded field by field, not as one value: an AsDetail attribute's rows\n // travel in object/objects and its value is null, so collapsing them here\n // is what made a detail-grid refresh impossible to express.\n attributes.request(patch.objectTypeId, patch.id, patch.attributeName, {\n value: patch.value,\n object: patch.object,\n objects: patch.objects,\n });\n },\n };\n },\n multi: true,\n },\n {\n provide: SPARK_CLIENT_OPERATION_HANDLERS,\n useFactory: () => {\n const router = inject(Router);\n return {\n type: 'navigate',\n handler: (operation: ClientOperation) => {\n const navigate = operation as NavigateOperation;\n\n if (navigate.routeName) {\n void router.navigateByUrl(\n navigate.routeName.startsWith('/') ? navigate.routeName : `/${navigate.routeName}`);\n return;\n }\n\n // `/po/{type}/{id}` is the convention the grid's row links already assume,\n // and the detail route resolves a type by id as well as by alias, so the\n // operation's objectTypeId can be used verbatim.\n if (navigate.objectTypeId && navigate.id) {\n void router.navigate(['/po', navigate.objectTypeId, navigate.id]);\n return;\n }\n\n console.warn('[spark] navigate operation carried neither routeName nor objectTypeId+id; ignored.');\n },\n };\n },\n multi: true,\n },\n {\n provide: SPARK_CLIENT_OPERATION_HANDLERS,\n useFactory: () => ({\n type: 'disableAction',\n handler: (operation: ClientOperation) => {\n // Deliberately a no-op with a warning, not silence. The server's\n // IClientAccessor.DisableQueryActions presumes a client that honours it;\n // nothing renders the disabled state yet, and a silently dropped operation\n // reads as \"the server did not send it\" when debugging.\n const disable = operation as DisableActionOperation;\n console.warn(\n `[spark] disableAction('${disable.actionName}') is not implemented by this client; the action stays enabled.`);\n },\n }),\n multi: true,\n },\n ]);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;AACA;AACA;AACA;IAIY;AAAZ,CAAA,UAAY,gBAAgB,EAAA;AACxB,IAAA,gBAAA,CAAA,gBAAA,CAAA,MAAA,CAAA,GAAA,CAAA,CAAA,GAAA,MAAQ;AACR,IAAA,gBAAA,CAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAW;AACX,IAAA,gBAAA,CAAA,gBAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAW;AACX,IAAA,gBAAA,CAAA,gBAAA,CAAA,OAAA,CAAA,GAAA,CAAA,CAAA,GAAA,OAAS;AACb,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,GAAA,EAAA,CAAA,CAAA;;ACa5B;;;;AAIG;MACU,+BAA+B,GAAG,IAAI,cAAc,CAC7D,iCAAiC;;ACtBrC;;;;;;;;;;;;;;;;;;;AAmBG;M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evMode ? [{ debugName: "resultCount" }] : /* istanbul ignore next */ []));
|
|
505
505
|
customActions = signal([], /* @ts-ignore */
|
|
506
506
|
...(ngDevMode ? [{ debugName: "customActions" }] : /* istanbul ignore next */ []));
|
|
507
|
+
/** Names the server withheld for this RESULT; see QueryResult.disabledActions. */
|
|
508
|
+
disabledActions = signal([], /* @ts-ignore */
|
|
509
|
+
...(ngDevMode ? [{ debugName: "disabledActions" }] : /* istanbul ignore next */ []));
|
|
510
|
+
/**
|
|
511
|
+
* The actions actually offered for this result.
|
|
512
|
+
*
|
|
513
|
+
* The catalogue at `/spark/actions/{objectTypeId}` is per TYPE and is never told what an
|
|
514
|
+
* execution returned, so an action that applies to only some results cannot be filtered there.
|
|
515
|
+
* A custom query withholds what does not apply via `CustomQueryArgs.DisableActions(...)`, and
|
|
516
|
+
* the answer arrives on the result.
|
|
517
|
+
*
|
|
518
|
+
* An affordance, not a permission -- the action handler still refuses on its own terms.
|
|
519
|
+
*/
|
|
520
|
+
visibleCustomActions = computed(() => {
|
|
521
|
+
const withheld = this.disabledActions();
|
|
522
|
+
if (!withheld.length)
|
|
523
|
+
return this.customActions();
|
|
524
|
+
const lowered = new Set(withheld.map(name => name.toLowerCase()));
|
|
525
|
+
return this.customActions().filter(action => !lowered.has(action.name.toLowerCase()));
|
|
526
|
+
}, /* @ts-ignore */
|
|
527
|
+
...(ngDevMode ? [{ debugName: "visibleCustomActions" }] : /* istanbul ignore next */ []));
|
|
507
528
|
fetchFn = signal(null, /* @ts-ignore */
|
|
508
529
|
...(ngDevMode ? [{ debugName: "fetchFn" }] : /* istanbul ignore next */ []));
|
|
509
530
|
/**
|
|
@@ -759,6 +780,8 @@ class SparkQueryGridComponent {
|
|
|
759
780
|
// ?? [] because a malformed or older response must render an empty grid, not throw inside a
|
|
760
781
|
// computed — where the stack points at the column filter and not at the response that lacked them.
|
|
761
782
|
this.fetchedColumns.set(r.columns ?? []);
|
|
783
|
+
// Per-result, so it is re-read on every page rather than latched from the first.
|
|
784
|
+
this.disabledActions.set(r.disabledActions ?? []);
|
|
762
785
|
return {
|
|
763
786
|
data: r.items,
|
|
764
787
|
totalRecords: r.totalItems,
|
|
@@ -922,7 +945,7 @@ class SparkQueryCardComponent {
|
|
|
922
945
|
return (q?.description ? this.lang.resolve(q.description) : '') || q?.name || '';
|
|
923
946
|
}, /* @ts-ignore */
|
|
924
947
|
...(ngDevMode ? [{ debugName: "caption" }] : /* istanbul ignore next */ []));
|
|
925
|
-
customActions = computed(() => this.grid()?.
|
|
948
|
+
customActions = computed(() => this.grid()?.visibleCustomActions() ?? [], /* @ts-ignore */
|
|
926
949
|
...(ngDevMode ? [{ debugName: "customActions" }] : /* istanbul ignore next */ []));
|
|
927
950
|
selection = computed(() => this.grid()?.selection() ?? [], /* @ts-ignore */
|
|
928
951
|
...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
|