@proulr/sdui-contract 0.1.21 → 0.1.22
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
|
@@ -408,6 +408,18 @@ export type SduiScreenChromeMetaWire = {
|
|
|
408
408
|
|
|
409
409
|
export type SduiScreenMetaWire = {
|
|
410
410
|
cache_ttl_ms?: number;
|
|
411
|
+
/**
|
|
412
|
+
* Intervalo mínimo (ms) entre fetches desta tela — throttle do prefetch forçado
|
|
413
|
+
* (resume/focus), onde o `cache_ttl_ms` não chega porque o app revalida por
|
|
414
|
+
* evento, não por expiração.
|
|
415
|
+
*/
|
|
416
|
+
min_fetch_interval_ms?: number;
|
|
417
|
+
/**
|
|
418
|
+
* Revisão do wire, calculada pelo bff-core a partir do mesmo digest que gera o
|
|
419
|
+
* ETag. Serve para o app comparar conteúdo entre fetches guardados no disco
|
|
420
|
+
* (onde o header HTTP não sobrevive) sem manter o ETag como estado de produto.
|
|
421
|
+
*/
|
|
422
|
+
rev?: string;
|
|
411
423
|
offline_policy?: SduiOfflinePolicy;
|
|
412
424
|
bff?: string;
|
|
413
425
|
chrome?: SduiScreenChromeMetaWire;
|
|
@@ -478,6 +490,9 @@ export type SduiScreenChromeMeta = {
|
|
|
478
490
|
|
|
479
491
|
export type SduiScreenMeta = {
|
|
480
492
|
cacheTtlMs: number;
|
|
493
|
+
minFetchIntervalMs?: number;
|
|
494
|
+
/** Revisão do wire (digest do bff-core) — mesma origem do ETag da resposta. */
|
|
495
|
+
rev?: string;
|
|
481
496
|
offlinePolicy: SduiOfflinePolicy;
|
|
482
497
|
bff?: string;
|
|
483
498
|
chrome?: SduiScreenChromeMeta;
|
|
@@ -42,6 +42,25 @@ describe('decodeSduiScreenWire', () => {
|
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
+
it('maps meta.rev and throttles min_fetch_interval_ms to positive numbers', () => {
|
|
46
|
+
const screen = decodeSduiScreenWire({
|
|
47
|
+
schema_version: 1,
|
|
48
|
+
screen_id: 'chat.inbox',
|
|
49
|
+
blocks: [],
|
|
50
|
+
meta: { rev: 'abc123', min_fetch_interval_ms: 30_000 },
|
|
51
|
+
});
|
|
52
|
+
expect(screen.meta).toMatchObject({ rev: 'abc123', minFetchIntervalMs: 30_000 });
|
|
53
|
+
|
|
54
|
+
const junk = decodeSduiScreenWire({
|
|
55
|
+
schema_version: 1,
|
|
56
|
+
screen_id: 'chat.inbox',
|
|
57
|
+
blocks: [],
|
|
58
|
+
meta: { rev: '', min_fetch_interval_ms: 0 },
|
|
59
|
+
});
|
|
60
|
+
expect(junk.meta).not.toHaveProperty('rev');
|
|
61
|
+
expect(junk.meta).not.toHaveProperty('minFetchIntervalMs');
|
|
62
|
+
});
|
|
63
|
+
|
|
45
64
|
it('decodes native_capability actions with capability_id', () => {
|
|
46
65
|
const screen = decodeSduiScreenWire({
|
|
47
66
|
schema_version: 1,
|
package/src/sdui-screen-codec.ts
CHANGED
|
@@ -86,8 +86,14 @@ function mapChromeMetaWire(
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
function mapMetaWire(wire: SduiScreenMetaWire | undefined): SduiScreenMeta {
|
|
89
|
+
const minFetchIntervalMs =
|
|
90
|
+
typeof wire?.min_fetch_interval_ms === 'number' && wire.min_fetch_interval_ms > 0
|
|
91
|
+
? wire.min_fetch_interval_ms
|
|
92
|
+
: undefined;
|
|
89
93
|
return {
|
|
90
94
|
cacheTtlMs: wire?.cache_ttl_ms ?? DEFAULT_CACHE_TTL_MS,
|
|
95
|
+
...(minFetchIntervalMs === undefined ? {} : { minFetchIntervalMs }),
|
|
96
|
+
...(typeof wire?.rev === 'string' && wire.rev ? { rev: wire.rev } : {}),
|
|
91
97
|
offlinePolicy: wire?.offline_policy ?? DEFAULT_OFFLINE_POLICY,
|
|
92
98
|
bff: wire?.bff,
|
|
93
99
|
chrome: mapChromeMetaWire(wire?.chrome),
|