MCPcopy Create free account
hub / github.com/Effect-TS/effect / encodePage

Function encodePage

packages/effect/src/ui/internal/stateCodec.ts:135–155  ·  view source on GitHub ↗
(
  component: Component.Any,
  model: unknown,
  results: unknown,
  collected: ReadonlyArray<unknown> | undefined
)

Source from the content-addressed store, hash-verified

133
134/** @internal */
135export const encodePage = (
136 component: Component.Any,
137 model: unknown,
138 results: unknown,
139 collected: ReadonlyArray<unknown> | undefined
140): Effect.Effect<
141 { readonly state: unknown; readonly reported: unknown },
142 SchemaIssue.Issue
143> => {
144 const state = stateCodecOf(component).encode(model, results as never)
145 // No reports is where an owner starts on the client anyway.
146 if (
147 collected === undefined || collected.length === 0 ||
148 component.definition.collects === undefined
149 ) return Effect.mapEager(state, (state) => ({ state, reported: undefined }))
150 const reported = encodeJson(reportsSchemaOf(component.definition), collected)
151 return Effect.flatMapEager(
152 state,
153 (state) => Effect.mapEager(reported, (reported) => ({ state, reported }))
154 )
155}
156
157/** @internal */
158export const decodePage = (

Callers 2

instanceFunction · 0.90
saveFunction · 0.90

Calls 4

reportsSchemaOfFunction · 0.90
stateCodecOfFunction · 0.85
encodeMethod · 0.80
encodeJsonFunction · 0.70

Tested by

no test coverage detected