* Serialize a SessionState via the SDK's `structuredSerialize` (tagged * envelopes for Map/Date). Returns a JSON-safe Record.
(session: SessionState, key?: string)
| 227 | * envelopes for Map/Date). Returns a JSON-safe Record. |
| 228 | */ |
| 229 | function serializeSession(session: SessionState, key?: string): Record<string, unknown> { |
| 230 | const persisted = { |
| 231 | ...session, |
| 232 | ...(key && { __sessionKey: key }), |
| 233 | // `products` is deterministic from the catalog — dropped from persistence |
| 234 | // so callers re-derive on the next request. Only `proposals` (session- |
| 235 | // specific drafts from refine workflows) ride along. |
| 236 | lastGetProductsContext: session.lastGetProductsContext?.proposals?.length |
| 237 | ? { proposals: session.lastGetProductsContext.proposals } |
| 238 | : undefined, |
| 239 | }; |
| 240 | return structuredSerialize(persisted) as Record<string, unknown>; |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Hydrate a stored doc back into a SessionState. |
no outgoing calls
no test coverage detected