@confect/core 9.0.1 → 9.1.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@confect/core",
3
3
  "description": "Shared specs and schemas used by all Confect packages",
4
- "version": "9.0.1",
4
+ "version": "9.1.0",
5
5
  "author": "RJ Dellecese",
6
6
  "bugs": {
7
7
  "url": "https://github.com/rjdellecese/confect/issues"
package/src/Ref.ts CHANGED
@@ -257,6 +257,30 @@ export const encodeArgsSync = <Ref_ extends Any>(
257
257
  Match.exhaustive,
258
258
  );
259
259
 
260
+ export const decodeArgsSync = <Ref_ extends Any>(
261
+ ref: Ref_,
262
+ encodedArgs: unknown,
263
+ ): Args<Ref_> =>
264
+ Match.value(ref.functionSpec.functionProvenance).pipe(
265
+ Match.tag("Confect", (confectFunctionProvenance) =>
266
+ Schema.decodeSync(confectFunctionProvenance.args)(encodedArgs),
267
+ ),
268
+ Match.tag("Convex", () => encodedArgs),
269
+ Match.exhaustive,
270
+ ) as Args<Ref_>;
271
+
272
+ export const encodeReturnsSync = <Ref_ extends Any>(
273
+ ref: Ref_,
274
+ returns: Returns<Ref_>,
275
+ ): unknown =>
276
+ Match.value(ref.functionSpec.functionProvenance).pipe(
277
+ Match.tag("Confect", (confectFunctionProvenance) =>
278
+ Schema.encodeSync(confectFunctionProvenance.returns)(returns),
279
+ ),
280
+ Match.tag("Convex", () => returns),
281
+ Match.exhaustive,
282
+ );
283
+
260
284
  export const decodeReturnsSync = <Ref_ extends Any>(
261
285
  ref: Ref_,
262
286
  encodedReturns: unknown,