@confect/core 9.0.0-next.1 → 9.0.0-next.10
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/CHANGELOG.md +266 -4
- package/dist/FunctionProvenance.d.ts +101 -95
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js +25 -6
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +178 -218
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +2 -2
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.d.ts +7 -12
- package/dist/GenericId.d.ts.map +1 -1
- package/dist/GenericId.js +2 -1
- package/dist/GenericId.js.map +1 -1
- package/dist/GroupPath.d.ts +10 -16
- package/dist/GroupPath.d.ts.map +1 -1
- package/dist/GroupSpec.d.ts +38 -37
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js +9 -3
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Identifier.d.ts +14 -0
- package/dist/Identifier.d.ts.map +1 -0
- package/dist/{internal/utils.js → Identifier.js} +26 -3
- package/dist/Identifier.js.map +1 -0
- package/dist/Lazy.d.ts +22 -0
- package/dist/Lazy.d.ts.map +1 -0
- package/dist/Lazy.js +44 -0
- package/dist/Lazy.js.map +1 -0
- package/dist/PaginationResult.d.ts +11 -18
- package/dist/PaginationResult.d.ts.map +1 -1
- package/dist/PaginationResult.js +1 -1
- package/dist/PaginationResult.js.map +1 -1
- package/dist/Ref.d.ts +55 -51
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +17 -6
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.d.ts +21 -21
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js +5 -10
- package/dist/Refs.js.map +1 -1
- package/dist/Registry.d.ts +7 -11
- package/dist/Registry.d.ts.map +1 -1
- package/dist/Registry.js +2 -1
- package/dist/Registry.js.map +1 -1
- package/dist/RuntimeAndFunctionType.d.ts +36 -41
- package/dist/RuntimeAndFunctionType.d.ts.map +1 -1
- package/dist/Spec.d.ts +23 -32
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js +9 -48
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +10 -16
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js +1 -1
- package/dist/SystemFields.js.map +1 -1
- package/dist/Types.d.ts +27 -27
- package/dist/Types.d.ts.map +1 -1
- package/dist/UserIdentity.d.ts +56 -63
- package/dist/UserIdentity.d.ts.map +1 -1
- package/dist/UserIdentity.js +1 -1
- package/dist/UserIdentity.js.map +1 -1
- package/dist/index.d.ts +17 -15
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -1
- package/dist/tsconfig.src.tsbuildinfo +1 -0
- package/package.json +37 -46
- package/src/FunctionProvenance.ts +32 -10
- package/src/FunctionSpec.ts +5 -5
- package/src/GenericId.ts +3 -1
- package/src/GroupSpec.ts +16 -11
- package/src/{internal/utils.ts → Identifier.ts} +34 -0
- package/src/Lazy.ts +40 -0
- package/src/PaginationResult.ts +1 -1
- package/src/Ref.ts +23 -8
- package/src/Refs.ts +13 -44
- package/src/Registry.ts +2 -1
- package/src/Spec.ts +18 -81
- package/src/SystemFields.ts +1 -1
- package/src/UserIdentity.ts +1 -1
- package/src/index.ts +2 -0
- package/dist/internal/utils.d.ts +0 -5
- package/dist/internal/utils.d.ts.map +0 -1
- package/dist/internal/utils.js.map +0 -1
package/dist/Ref.d.ts
CHANGED
|
@@ -1,55 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import type { FunctionReference as ConvexFunctionReference, FunctionVisibility } from "convex/server";
|
|
2
|
+
import type { Value } from "convex/values";
|
|
3
|
+
import { ConvexError } from "convex/values";
|
|
4
|
+
import type { ParseResult } from "effect";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import type * as FunctionSpec from "./FunctionSpec";
|
|
8
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
9
|
+
export interface Ref<_RuntimeAndFunctionType extends RuntimeAndFunctionType.RuntimeAndFunctionType, _FunctionVisibility extends FunctionVisibility, _Args, _Returns, _Error = never> {
|
|
10
|
+
readonly _RuntimeAndFunctionType?: _RuntimeAndFunctionType;
|
|
11
|
+
readonly _FunctionVisibility?: _FunctionVisibility;
|
|
12
|
+
readonly _Args?: _Args;
|
|
13
|
+
readonly _Returns?: _Returns;
|
|
14
|
+
readonly _Error?: _Error;
|
|
10
15
|
}
|
|
11
|
-
interface
|
|
12
|
-
readonly _RuntimeAndFunctionType?: _RuntimeAndFunctionType;
|
|
13
|
-
readonly _FunctionVisibility?: _FunctionVisibility;
|
|
14
|
-
readonly _Args?: _Args;
|
|
15
|
-
readonly _Returns?: _Returns;
|
|
16
|
-
readonly _Error?: _Error;
|
|
16
|
+
export interface Any extends Ref<any, any, any, any, any> {
|
|
17
17
|
}
|
|
18
|
-
interface
|
|
19
|
-
|
|
20
|
-
interface AnyPublic extends Ref<any, "public", any, any, any> {
|
|
21
|
-
|
|
22
|
-
interface
|
|
23
|
-
|
|
24
|
-
interface
|
|
25
|
-
|
|
26
|
-
interface
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
type
|
|
35
|
-
type
|
|
36
|
-
type
|
|
37
|
-
|
|
18
|
+
export interface AnyInternal extends Ref<any, "internal", any, any, any> {
|
|
19
|
+
}
|
|
20
|
+
export interface AnyPublic extends Ref<any, "public", any, any, any> {
|
|
21
|
+
}
|
|
22
|
+
export interface AnyQuery extends Ref<RuntimeAndFunctionType.AnyQuery, FunctionVisibility, any, any, any> {
|
|
23
|
+
}
|
|
24
|
+
export interface AnyMutation extends Ref<RuntimeAndFunctionType.AnyMutation, FunctionVisibility, any, any, any> {
|
|
25
|
+
}
|
|
26
|
+
export interface AnyAction extends Ref<RuntimeAndFunctionType.AnyAction, FunctionVisibility, any, any, any> {
|
|
27
|
+
}
|
|
28
|
+
export interface AnyPublicQuery extends Ref<RuntimeAndFunctionType.AnyQuery, "public", any, any, any> {
|
|
29
|
+
}
|
|
30
|
+
export interface AnyPublicMutation extends Ref<RuntimeAndFunctionType.AnyMutation, "public", any, any, any> {
|
|
31
|
+
}
|
|
32
|
+
export interface AnyPublicAction extends Ref<RuntimeAndFunctionType.AnyAction, "public", any, any, any> {
|
|
33
|
+
}
|
|
34
|
+
export type GetRuntimeAndFunctionType<Ref_> = Ref_ extends Ref<infer RuntimeAndFunctionType_, infer _FunctionVisibility, infer _Args, infer _Returns, infer _Error> ? RuntimeAndFunctionType_ : never;
|
|
35
|
+
export type GetRuntime<Ref_> = Ref_ extends Ref<infer RuntimeAndFunctionType_, infer _FunctionVisibility, infer _Args, infer _Returns, infer _Error> ? RuntimeAndFunctionType.GetRuntime<RuntimeAndFunctionType_> : never;
|
|
36
|
+
export type GetFunctionType<Ref_> = Ref_ extends Ref<infer RuntimeAndFunctionType_, infer _FunctionVisibility, infer _Args, infer _Returns, infer _Error> ? RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_> : never;
|
|
37
|
+
export type GetFunctionVisibility<Ref_> = Ref_ extends Ref<infer _RuntimeAndFunctionType, infer FunctionVisibility_, infer _Args, infer _Returns, infer _Error> ? FunctionVisibility_ : never;
|
|
38
|
+
export type Args<Ref_> = Ref_ extends Ref<infer _RuntimeAndFunctionType, infer _FunctionVisibility, infer Args_, infer _Returns, infer _Error> ? Args_ : never;
|
|
39
|
+
export type OptionalArgs<Ref_ extends Any> = keyof Args<Ref_> extends never ? [args?: Args<Ref_>] : [args: Args<Ref_>];
|
|
40
|
+
export type Returns<Ref_> = Ref_ extends Ref<infer _RuntimeAndFunctionType, infer _FunctionVisibility, infer _Args, infer Returns_, infer _Error> ? Returns_ : never;
|
|
41
|
+
export type Error<Ref_> = Ref_ extends Ref<infer _RuntimeAndFunctionType, infer _FunctionVisibility, infer _Args, infer _Returns, infer Error_> ? Error_ : never;
|
|
42
|
+
export type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<GetFunctionType<Ref_>, GetFunctionVisibility<Ref_>>;
|
|
43
|
+
export type FromFunctionSpec<FunctionSpec_ extends FunctionSpec.AnyWithProps> = Ref<FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>, FunctionSpec.GetFunctionVisibility<FunctionSpec_>, FunctionSpec.Args<FunctionSpec_>, FunctionSpec.Returns<FunctionSpec_>, FunctionSpec.Error<FunctionSpec_>>;
|
|
44
|
+
export declare const make: <FunctionSpec_ extends FunctionSpec.AnyWithProps>(
|
|
38
45
|
/**
|
|
39
46
|
* The namespace portion of a Convex function name, i.e. the part before the
|
|
40
47
|
* colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be
|
|
41
48
|
* `myGroupDir/myGroupMod`.
|
|
42
49
|
*/
|
|
43
|
-
|
|
44
50
|
functionNamespace: string, functionSpec: FunctionSpec_) => FromFunctionSpec<FunctionSpec_>;
|
|
45
|
-
declare const getConvexFunctionName: (ref: Any) => string;
|
|
46
|
-
declare const getFunctionReference: <Ref_ extends Any>(ref: Ref_) => FunctionReference<Ref_>;
|
|
47
|
-
declare const hasErrorSchema: (ref: Any) => boolean;
|
|
48
|
-
declare const encodeArgs: <Ref_ extends Any>(ref: Ref_, args: Args<Ref_>) => Effect.Effect<unknown, ParseResult.ParseError>;
|
|
49
|
-
declare const decodeReturns: <Ref_ extends Any>(ref: Ref_, returns: unknown) => Effect.Effect<Returns<Ref_>, ParseResult.ParseError>;
|
|
50
|
-
declare const encodeArgsSync: <Ref_ extends Any>(ref: Ref_, args: Args<Ref_>) => unknown;
|
|
51
|
-
declare const decodeReturnsSync: <Ref_ extends Any>(ref: Ref_, encodedReturns: unknown) => Returns<Ref_>;
|
|
52
|
-
declare const isConvexError: (error: unknown) => error is ConvexError<Value>;
|
|
51
|
+
export declare const getConvexFunctionName: (ref: Any) => string;
|
|
52
|
+
export declare const getFunctionReference: <Ref_ extends Any>(ref: Ref_) => FunctionReference<Ref_>;
|
|
53
|
+
export declare const hasErrorSchema: (ref: Any) => boolean;
|
|
54
|
+
export declare const encodeArgs: <Ref_ extends Any>(ref: Ref_, args: Args<Ref_>) => Effect.Effect<unknown, ParseResult.ParseError>;
|
|
55
|
+
export declare const decodeReturns: <Ref_ extends Any>(ref: Ref_, returns: unknown) => Effect.Effect<Returns<Ref_>, ParseResult.ParseError>;
|
|
56
|
+
export declare const encodeArgsSync: <Ref_ extends Any>(ref: Ref_, args: Args<Ref_>) => unknown;
|
|
57
|
+
export declare const decodeReturnsSync: <Ref_ extends Any>(ref: Ref_, encodedReturns: unknown) => Returns<Ref_>;
|
|
58
|
+
export declare const isConvexError: (error: unknown) => error is ConvexError<Value>;
|
|
53
59
|
/**
|
|
54
60
|
* Build a callback-style handler that decodes the ref's typed error from a
|
|
55
61
|
* caught `ConvexError`, or else forwards the value to `mapUnknownError`. The
|
|
@@ -59,7 +65,7 @@ declare const isConvexError: (error: unknown) => error is ConvexError<Value>;
|
|
|
59
65
|
* emitter callbacks for streamed subscriptions) to the same error semantics
|
|
60
66
|
* that `runWithCodec` provides.
|
|
61
67
|
*/
|
|
62
|
-
declare const decodeErrorOrElse: <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) => (error: unknown) => Error<Ref_> | E;
|
|
68
|
+
export declare const decodeErrorOrElse: <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) => (error: unknown) => Error<Ref_> | E;
|
|
63
69
|
/**
|
|
64
70
|
* Decode `encodedError` against the ref's error schema. Returns `None` if the
|
|
65
71
|
* ref doesn't declare a typed error (Confect ref without an `error` schema, or
|
|
@@ -67,13 +73,13 @@ declare const decodeErrorOrElse: <Ref_ extends Any, E>(ref: Ref_, mapUnknownErro
|
|
|
67
73
|
* into, and the caller is responsible for deciding what to do (typically:
|
|
68
74
|
* surface the original value as a defect).
|
|
69
75
|
*/
|
|
70
|
-
declare const decodeError: <Ref_ extends Any>(ref: Ref_, encodedError: unknown) => Effect.Effect<Option.Option<Error<Ref_>>, ParseResult.ParseError>;
|
|
76
|
+
export declare const decodeError: <Ref_ extends Any>(ref: Ref_, encodedError: unknown) => Effect.Effect<Option.Option<Error<Ref_>>, ParseResult.ParseError>;
|
|
71
77
|
/**
|
|
72
78
|
* Synchronous counterpart to `decodeError`. Throws on schema decode failure;
|
|
73
79
|
* returns `None` when the ref doesn't declare a typed error.
|
|
74
80
|
*/
|
|
75
|
-
declare const decodeErrorSync: <Ref_ extends Any>(ref: Ref_, encodedError: unknown) => Option.Option<Error<Ref_>>;
|
|
76
|
-
declare const maybeDecodeErrorSync: <Ref_ extends Any>(ref: Ref_, error: unknown) => unknown;
|
|
81
|
+
export declare const decodeErrorSync: <Ref_ extends Any>(ref: Ref_, encodedError: unknown) => Option.Option<Error<Ref_>>;
|
|
82
|
+
export declare const maybeDecodeErrorSync: <Ref_ extends Any>(ref: Ref_, error: unknown) => unknown;
|
|
77
83
|
/**
|
|
78
84
|
* Encode args via the ref's args schema, invoke `call`, decode returns via the
|
|
79
85
|
* ref's returns schema, and translate any thrown `ConvexError` into the ref's
|
|
@@ -82,7 +88,5 @@ declare const maybeDecodeErrorSync: <Ref_ extends Any>(ref: Ref_, error: unknown
|
|
|
82
88
|
* `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when
|
|
83
89
|
* no handler is provided.
|
|
84
90
|
*/
|
|
85
|
-
declare const runWithCodec: <Ref_ extends Any, E = never>(ref: Ref_, args: Args<Ref_>, call: (functionReference: FunctionReference<Ref_>, encodedArgs: unknown) => PromiseLike<unknown>, mapUnknownError?: (error: unknown) => E) => Effect.Effect<Returns<Ref_>, E | Error<Ref_> | ParseResult.ParseError>;
|
|
86
|
-
//#endregion
|
|
87
|
-
export { Any, AnyAction, AnyInternal, AnyMutation, AnyPublic, AnyPublicAction, AnyPublicMutation, AnyPublicQuery, AnyQuery, Args, Error, FromFunctionSpec, FunctionReference, GetFunctionType, GetFunctionVisibility, GetRuntime, GetRuntimeAndFunctionType, OptionalArgs, Ref, Ref_d_exports, Returns, decodeError, decodeErrorOrElse, decodeErrorSync, decodeReturns, decodeReturnsSync, encodeArgs, encodeArgsSync, getConvexFunctionName, getFunctionReference, hasErrorSchema, isConvexError, make, maybeDecodeErrorSync, runWithCodec };
|
|
91
|
+
export declare const runWithCodec: <Ref_ extends Any, E = never>(ref: Ref_, args: Args<Ref_>, call: (functionReference: FunctionReference<Ref_>, encodedArgs: unknown) => PromiseLike<unknown>, mapUnknownError?: (error: unknown) => E) => Effect.Effect<Returns<Ref_>, E | Error<Ref_> | ParseResult.ParseError>;
|
|
88
92
|
//# sourceMappingURL=Ref.d.ts.map
|
package/dist/Ref.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.d.ts","
|
|
1
|
+
{"version":3,"file":"Ref.d.ts","sourceRoot":"","sources":["../src/Ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,IAAI,uBAAuB,EAC5C,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAExE,MAAM,WAAW,GAAG,CAClB,uBAAuB,SAAS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,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,CAAC,UAAU,CAYhE,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,IAAI,SAAS,GAAG,EAC9C,KAAK,IAAI,EACT,cAAc,OAAO,KACpB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAazB,CAAC;AAEJ,eAAO,MAAM,oBAAoB,GAAI,IAAI,SAAS,GAAG,EACnD,KAAK,IAAI,EACT,OAAO,OAAO,KACb,OAWQ,CAAC;AAEZ;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,SAAS,GAAG,EAAE,CAAC,GAAG,KAAK,EACtD,KAAK,IAAI,EACT,MAAM,IAAI,CAAC,IAAI,CAAC,EAChB,MAAM,CACJ,iBAAiB,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAC1C,WAAW,EAAE,OAAO,KACjB,WAAW,CAAC,OAAO,CAAC,EACzB,kBAAkB,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,KACtC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,UAAU,CAqCpE,CAAC"}
|
package/dist/Ref.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import
|
|
2
|
+
import * as Schema from "effect/Schema";
|
|
3
3
|
import { makeFunctionReference } from "convex/server";
|
|
4
4
|
import { ConvexError } from "convex/values";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Match from "effect/Match";
|
|
7
|
+
import * as Option from "effect/Option";
|
|
5
8
|
|
|
6
9
|
//#region src/Ref.ts
|
|
7
10
|
var Ref_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -25,8 +28,16 @@ const make = (functionNamespace, functionSpec) => ({
|
|
|
25
28
|
functionNamespace
|
|
26
29
|
});
|
|
27
30
|
const getConvexFunctionName = (ref) => `${ref.functionNamespace}:${ref.functionSpec.name}`;
|
|
28
|
-
const
|
|
29
|
-
const
|
|
31
|
+
const functionReferenceCache = /* @__PURE__ */ new Map();
|
|
32
|
+
const getFunctionReference = (ref) => {
|
|
33
|
+
const functionName = getConvexFunctionName(ref);
|
|
34
|
+
const cached = functionReferenceCache.get(functionName);
|
|
35
|
+
if (cached !== void 0) return cached;
|
|
36
|
+
const functionReference = makeFunctionReference(functionName);
|
|
37
|
+
functionReferenceCache.set(functionName, functionReference);
|
|
38
|
+
return functionReference;
|
|
39
|
+
};
|
|
40
|
+
const hasErrorSchema = (ref) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => "error" in confectFunctionProvenance), Match.tag("Convex", () => false), Match.exhaustive);
|
|
30
41
|
const encodeArgs = (ref, args) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => Schema.encode(confectFunctionProvenance.args)(args)), Match.tag("Convex", () => Effect.succeed(args)), Match.exhaustive);
|
|
31
42
|
const decodeReturns = (ref, returns) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => Schema.decode(confectFunctionProvenance.returns)(returns)), Match.tag("Convex", () => Effect.succeed(returns)), Match.exhaustive);
|
|
32
43
|
const encodeArgsSync = (ref, args) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => Schema.encodeSync(confectFunctionProvenance.args)(args)), Match.tag("Convex", () => args), Match.exhaustive);
|
|
@@ -56,13 +67,13 @@ const decodeErrorOrElse = (ref, mapUnknownError) => (error) => {
|
|
|
56
67
|
* into, and the caller is responsible for deciding what to do (typically:
|
|
57
68
|
* surface the original value as a defect).
|
|
58
69
|
*/
|
|
59
|
-
const decodeError = (ref, encodedError) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) =>
|
|
70
|
+
const decodeError = (ref, encodedError) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => "error" in confectFunctionProvenance ? Effect.map(Schema.decode(confectFunctionProvenance.error)(encodedError), Option.some) : Effect.succeed(Option.none())), Match.tag("Convex", () => Effect.succeed(Option.none())), Match.exhaustive);
|
|
60
71
|
/**
|
|
61
72
|
* Synchronous counterpart to `decodeError`. Throws on schema decode failure;
|
|
62
73
|
* returns `None` when the ref doesn't declare a typed error.
|
|
63
74
|
*/
|
|
64
|
-
const decodeErrorSync = (ref, encodedError) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) =>
|
|
65
|
-
const maybeDecodeErrorSync = (ref, error) => isConvexError(error) ? Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) =>
|
|
75
|
+
const decodeErrorSync = (ref, encodedError) => Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => "error" in confectFunctionProvenance ? Option.some(Schema.decodeSync(confectFunctionProvenance.error)(encodedError)) : Option.none()), Match.tag("Convex", () => Option.none()), Match.exhaustive);
|
|
76
|
+
const maybeDecodeErrorSync = (ref, error) => isConvexError(error) ? Match.value(ref.functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionProvenance) => "error" in confectFunctionProvenance ? Schema.decodeSync(confectFunctionProvenance.error)(error.data) : error), Match.tag("Convex", () => error), Match.exhaustive) : error;
|
|
66
77
|
/**
|
|
67
78
|
* Encode args via the ref's args schema, invoke `call`, decode returns via the
|
|
68
79
|
* ref's returns schema, and translate any thrown `ConvexError` into the ref's
|
package/dist/Ref.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Ref.js","names":[],"sources":["../src/Ref.ts"],"sourcesContent":["import type {\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n} from \"convex/server\";\nimport { makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport type { ParseResult } from \"effect\";\nimport { Effect, Match, Option, Schema } from \"effect\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport interface Ref<\n _RuntimeAndFunctionType extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n _FunctionVisibility extends FunctionVisibility,\n _Args,\n _Returns,\n _Error = never,\n> {\n readonly _RuntimeAndFunctionType?: _RuntimeAndFunctionType;\n readonly _FunctionVisibility?: _FunctionVisibility;\n readonly _Args?: _Args;\n readonly _Returns?: _Returns;\n readonly _Error?: _Error;\n /** @internal */\n readonly functionSpec: FunctionSpec.AnyWithProps;\n /** @internal */\n readonly functionNamespace: string;\n}\n\nexport interface Any extends Ref<any, any, any, any, any> {}\n\nexport interface AnyInternal extends Ref<any, \"internal\", any, any, any> {}\n\nexport interface AnyPublic extends Ref<any, \"public\", any, any, any> {}\n\nexport interface AnyQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport type GetRuntimeAndFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType.GetRuntime<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionVisibility<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer FunctionVisibility_,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer Args_,\n infer _Returns,\n infer _Error\n >\n ? Args_\n : never;\n\nexport type OptionalArgs<Ref_ extends Any> = keyof Args<Ref_> extends never\n ? [args?: Args<Ref_>]\n : [args: Args<Ref_>];\n\nexport type Returns<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer _Args,\n infer Returns_,\n infer _Error\n >\n ? Returns_\n : never;\n\nexport type Error<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer Error_\n >\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\nexport type FromFunctionSpec<FunctionSpec_ extends FunctionSpec.AnyWithProps> =\n Ref<\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n FunctionSpec.Error<FunctionSpec_>\n >;\n\nexport const make = <FunctionSpec_ extends FunctionSpec.AnyWithProps>(\n /**\n * The namespace portion of a Convex function name, i.e. the part before the\n * colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be\n * `myGroupDir/myGroupMod`.\n */\n functionNamespace: string,\n functionSpec: FunctionSpec_,\n): FromFunctionSpec<FunctionSpec_> => ({ functionSpec, functionNamespace });\n\nexport const getConvexFunctionName = (ref: Any): string =>\n `${ref.functionNamespace}:${ref.functionSpec.name}`;\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> =>\n makeFunctionReference(getConvexFunctionName(ref)) as FunctionReference<Ref_>;\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Confect\",\n (confectFunctionProvenance) =>\n confectFunctionProvenance.error !== undefined,\n ),\n Match.tag(\"Convex\", () => false),\n Match.exhaustive,\n );\n\nexport const encodeArgs = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): Effect.Effect<unknown, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.encode(confectFunctionProvenance.args)(args),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(args)),\n Match.exhaustive,\n );\n\nexport const decodeReturns = <Ref_ extends Any>(\n ref: Ref_,\n returns: unknown,\n): Effect.Effect<Returns<Ref_>, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.decode(confectFunctionProvenance.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.encodeSync(confectFunctionProvenance.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.decodeSync(confectFunctionProvenance.returns)(encodedReturns),\n ),\n Match.tag(\"Convex\", () => encodedReturns),\n Match.exhaustive,\n ) as Returns<Ref_>;\n\nconst ConvexErrorIdentifier = Symbol.for(\"ConvexError\");\n\nexport const isConvexError = (error: unknown): error is ConvexError<Value> =>\n error instanceof ConvexError ||\n (typeof error === \"object\" &&\n error !== null &&\n ConvexErrorIdentifier in error);\n\n/**\n * Build a callback-style handler that decodes the ref's typed error from a\n * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The\n * fallback is also invoked when the input *is* a `ConvexError` but the ref\n * doesn't declare a typed-error schema—by definition such a value falls\n * outside the ref's error contract. Useful when adapting non-Effect APIs (e.g.\n * emitter callbacks for streamed subscriptions) to the same error semantics\n * that `runWithCodec` provides.\n */\nexport const decodeErrorOrElse =\n <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) =>\n (error: unknown): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorSync(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\n/**\n * Decode `encodedError` against the ref's error schema. Returns `None` if the\n * ref doesn't declare a typed error (Confect ref without an `error` schema, or\n * a Convex-provenance ref)—by definition there's nothing to decode the value\n * into, and the caller is responsible for deciding what to do (typically:\n * surface the original value as a defect).\n */\nexport const decodeError = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Effect.Effect<Option.Option<Error<Ref_>>, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n confectFunctionProvenance.error !== undefined\n ? Effect.map(\n Schema.decode(confectFunctionProvenance.error)(encodedError),\n Option.some,\n )\n : Effect.succeed(Option.none<Error<Ref_>>()),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(Option.none<Error<Ref_>>())),\n Match.exhaustive,\n );\n\n/**\n * Synchronous counterpart to `decodeError`. Throws on schema decode failure;\n * returns `None` when the ref doesn't declare a typed error.\n */\nexport const decodeErrorSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n confectFunctionProvenance.error !== undefined\n ? Option.some(\n Schema.decodeSync(confectFunctionProvenance.error)(\n encodedError,\n ) as Error<Ref_>,\n )\n : Option.none<Error<Ref_>>(),\n ),\n Match.tag(\"Convex\", () => Option.none<Error<Ref_>>()),\n Match.exhaustive,\n );\n\nexport const maybeDecodeErrorSync = <Ref_ extends Any>(\n ref: Ref_,\n error: unknown,\n): unknown =>\n isConvexError(error)\n ? Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n confectFunctionProvenance.error !== undefined\n ? Schema.decodeSync(confectFunctionProvenance.error)(error.data)\n : error,\n ),\n Match.tag(\"Convex\", () => error),\n Match.exhaustive,\n )\n : error;\n\n/**\n * Encode args via the ref's args schema, invoke `call`, decode returns via the\n * ref's returns schema, and translate any thrown `ConvexError` into the ref's\n * typed error. Anything else the Promise rejects with—network failures,\n * server-side runtime errors, validation failures, etc.—is passed to\n * `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when\n * no handler is provided.\n */\nexport const runWithCodec = <Ref_ extends Any, E = never>(\n ref: Ref_,\n args: Args<Ref_>,\n call: (\n functionReference: FunctionReference<Ref_>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>,\n mapUnknownError?: (error: unknown) => E,\n): Effect.Effect<Returns<Ref_>, E | Error<Ref_> | ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionReference = getFunctionReference(ref);\n const functionProvenance = ref.functionSpec.functionProvenance;\n const invoke = (\n encodedArgs: unknown,\n ): Effect.Effect<unknown, Error<Ref_> | E> =>\n Effect.tryPromise({\n try: () => Promise.resolve(call(functionReference, encodedArgs)),\n catch: (error): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorSync(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n if (mapUnknownError !== undefined) {\n return mapUnknownError(error);\n }\n throw error;\n },\n });\n return yield* Match.value(functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(\n confectFunctionProvenance.args,\n )(args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* Schema.decode(confectFunctionProvenance.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () => invoke(args)),\n Match.exhaustive,\n );\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmLA,MAAa,QAMX,mBACA,kBACqC;CAAE;CAAc;CAAmB;AAE1E,MAAa,yBAAyB,QACpC,GAAG,IAAI,kBAAkB,GAAG,IAAI,aAAa;AAE/C,MAAa,wBACX,QAEA,sBAAsB,sBAAsB,IAAI,CAAC;AAEnD,MAAa,kBAAkB,QAC7B,MAAM,MAAM,IAAI,aAAa,mBAAmB,CAAC,KAC/C,MAAM,IACJ,YACC,8BACC,0BAA0B,UAAU,OACvC,EACD,MAAM,IAAI,gBAAgB,MAAM,EAChC,MAAM,WACP;AAEH,MAAa,cACX,KACA,SAEA,MAAM,MAAM,IAAI,aAAa,mBAAmB,CAAC,KAC/C,MAAM,IAAI,YAAY,8BACpB,OAAO,OAAO,0BAA0B,KAAK,CAAC,KAAK,CACpD,EACD,MAAM,IAAI,gBAAgB,OA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,0BAA0B,QAAQ,CAC5D,eACD;GACD,CACH,EACD,MAAM,IAAI,gBAAgB,OAAO,KAAK,CAAC,EACvC,MAAM,WACP;EACD"}
|
|
1
|
+
{"version":3,"file":"Ref.js","names":[],"sources":["../src/Ref.ts"],"sourcesContent":["import type {\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n} from \"convex/server\";\nimport { makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport type { ParseResult } from \"effect\";\nimport * as Effect from \"effect/Effect\";\nimport * as Match from \"effect/Match\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport interface Ref<\n _RuntimeAndFunctionType extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n _FunctionVisibility extends FunctionVisibility,\n _Args,\n _Returns,\n _Error = never,\n> {\n readonly _RuntimeAndFunctionType?: _RuntimeAndFunctionType;\n readonly _FunctionVisibility?: _FunctionVisibility;\n readonly _Args?: _Args;\n readonly _Returns?: _Returns;\n readonly _Error?: _Error;\n /** @internal */\n readonly functionSpec: FunctionSpec.AnyWithProps;\n /** @internal */\n readonly functionNamespace: string;\n}\n\nexport interface Any extends Ref<any, any, any, any, any> {}\n\nexport interface AnyInternal extends Ref<any, \"internal\", any, any, any> {}\n\nexport interface AnyPublic extends Ref<any, \"public\", any, any, any> {}\n\nexport interface AnyQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicQuery extends Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicMutation extends Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport interface AnyPublicAction extends Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n> {}\n\nexport type GetRuntimeAndFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType.GetRuntime<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionType<Ref_> =\n Ref_ extends Ref<\n infer RuntimeAndFunctionType_,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? RuntimeAndFunctionType.GetFunctionType<RuntimeAndFunctionType_>\n : never;\n\nexport type GetFunctionVisibility<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer FunctionVisibility_,\n infer _Args,\n infer _Returns,\n infer _Error\n >\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer Args_,\n infer _Returns,\n infer _Error\n >\n ? Args_\n : never;\n\nexport type OptionalArgs<Ref_ extends Any> = keyof Args<Ref_> extends never\n ? [args?: Args<Ref_>]\n : [args: Args<Ref_>];\n\nexport type Returns<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer _Args,\n infer Returns_,\n infer _Error\n >\n ? Returns_\n : never;\n\nexport type Error<Ref_> =\n Ref_ extends Ref<\n infer _RuntimeAndFunctionType,\n infer _FunctionVisibility,\n infer _Args,\n infer _Returns,\n infer Error_\n >\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\nexport type FromFunctionSpec<FunctionSpec_ extends FunctionSpec.AnyWithProps> =\n Ref<\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n FunctionSpec.Error<FunctionSpec_>\n >;\n\nexport const make = <FunctionSpec_ extends FunctionSpec.AnyWithProps>(\n /**\n * The namespace portion of a Convex function name, i.e. the part before the\n * colon. For example, for `myGroupDir/myGroupMod:myFunc` this would be\n * `myGroupDir/myGroupMod`.\n */\n functionNamespace: string,\n functionSpec: FunctionSpec_,\n): FromFunctionSpec<FunctionSpec_> => ({ functionSpec, functionNamespace });\n\nexport const getConvexFunctionName = (ref: Any): string =>\n `${ref.functionNamespace}:${ref.functionSpec.name}`;\n\nconst functionReferenceCache = new Map<string, FunctionReference<Any>>();\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> => {\n const functionName = getConvexFunctionName(ref);\n\n const cached = functionReferenceCache.get(functionName);\n if (cached !== undefined) {\n return cached as FunctionReference<Ref_>;\n }\n\n const functionReference = makeFunctionReference(functionName);\n functionReferenceCache.set(functionName, functionReference);\n\n return functionReference as FunctionReference<Ref_>;\n};\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Confect\",\n (confectFunctionProvenance) => \"error\" in confectFunctionProvenance,\n ),\n Match.tag(\"Convex\", () => false),\n Match.exhaustive,\n );\n\nexport const encodeArgs = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): Effect.Effect<unknown, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.encode(confectFunctionProvenance.args)(args),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(args)),\n Match.exhaustive,\n );\n\nexport const decodeReturns = <Ref_ extends Any>(\n ref: Ref_,\n returns: unknown,\n): Effect.Effect<Returns<Ref_>, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.decode(confectFunctionProvenance.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.encodeSync(confectFunctionProvenance.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Schema.decodeSync(confectFunctionProvenance.returns)(encodedReturns),\n ),\n Match.tag(\"Convex\", () => encodedReturns),\n Match.exhaustive,\n ) as Returns<Ref_>;\n\nconst ConvexErrorIdentifier = Symbol.for(\"ConvexError\");\n\nexport const isConvexError = (error: unknown): error is ConvexError<Value> =>\n error instanceof ConvexError ||\n (typeof error === \"object\" &&\n error !== null &&\n ConvexErrorIdentifier in error);\n\n/**\n * Build a callback-style handler that decodes the ref's typed error from a\n * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The\n * fallback is also invoked when the input *is* a `ConvexError` but the ref\n * doesn't declare a typed-error schema—by definition such a value falls\n * outside the ref's error contract. Useful when adapting non-Effect APIs (e.g.\n * emitter callbacks for streamed subscriptions) to the same error semantics\n * that `runWithCodec` provides.\n */\nexport const decodeErrorOrElse =\n <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) =>\n (error: unknown): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorSync(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\n/**\n * Decode `encodedError` against the ref's error schema. Returns `None` if the\n * ref doesn't declare a typed error (Confect ref without an `error` schema, or\n * a Convex-provenance ref)—by definition there's nothing to decode the value\n * into, and the caller is responsible for deciding what to do (typically:\n * surface the original value as a defect).\n */\nexport const decodeError = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Effect.Effect<Option.Option<Error<Ref_>>, ParseResult.ParseError> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n \"error\" in confectFunctionProvenance\n ? Effect.map(\n Schema.decode(confectFunctionProvenance.error)(encodedError),\n Option.some,\n )\n : Effect.succeed(Option.none<Error<Ref_>>()),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(Option.none<Error<Ref_>>())),\n Match.exhaustive,\n );\n\n/**\n * Synchronous counterpart to `decodeError`. Throws on schema decode failure;\n * returns `None` when the ref doesn't declare a typed error.\n */\nexport const decodeErrorSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n \"error\" in confectFunctionProvenance\n ? Option.some(\n Schema.decodeSync(confectFunctionProvenance.error)(\n encodedError,\n ) as Error<Ref_>,\n )\n : Option.none<Error<Ref_>>(),\n ),\n Match.tag(\"Convex\", () => Option.none<Error<Ref_>>()),\n Match.exhaustive,\n );\n\nexport const maybeDecodeErrorSync = <Ref_ extends Any>(\n ref: Ref_,\n error: unknown,\n): unknown =>\n isConvexError(error)\n ? Match.value(ref.functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n \"error\" in confectFunctionProvenance\n ? Schema.decodeSync(confectFunctionProvenance.error)(error.data)\n : error,\n ),\n Match.tag(\"Convex\", () => error),\n Match.exhaustive,\n )\n : error;\n\n/**\n * Encode args via the ref's args schema, invoke `call`, decode returns via the\n * ref's returns schema, and translate any thrown `ConvexError` into the ref's\n * typed error. Anything else the Promise rejects with—network failures,\n * server-side runtime errors, validation failures, etc.—is passed to\n * `mapUnknownError` to be turned into a typed `E`, or surfaced as a defect when\n * no handler is provided.\n */\nexport const runWithCodec = <Ref_ extends Any, E = never>(\n ref: Ref_,\n args: Args<Ref_>,\n call: (\n functionReference: FunctionReference<Ref_>,\n encodedArgs: unknown,\n ) => PromiseLike<unknown>,\n mapUnknownError?: (error: unknown) => E,\n): Effect.Effect<Returns<Ref_>, E | Error<Ref_> | ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionReference = getFunctionReference(ref);\n const functionProvenance = ref.functionSpec.functionProvenance;\n const invoke = (\n encodedArgs: unknown,\n ): Effect.Effect<unknown, Error<Ref_> | E> =>\n Effect.tryPromise({\n try: () => Promise.resolve(call(functionReference, encodedArgs)),\n catch: (error): Error<Ref_> | E => {\n if (isConvexError(error)) {\n const decoded = decodeErrorSync(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n if (mapUnknownError !== undefined) {\n return mapUnknownError(error);\n }\n throw error;\n },\n });\n return yield* Match.value(functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionProvenance) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(\n confectFunctionProvenance.args,\n )(args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* Schema.decode(confectFunctionProvenance.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () => invoke(args)),\n Match.exhaustive,\n );\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsLA,MAAa,QAMX,mBACA,kBACqC;CAAE;CAAc;CAAmB;AAE1E,MAAa,yBAAyB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IAAI,aAAa;CACtB,MAAM,oBAAoB,qBAAqB,IAAI;CACnD,MAAM,qBAAqB,IAAI,aAAa;CAC5C,MAAM,UACJ,gBAEA,OAAO,WAAW;EAChB,WAAW,QAAQ,QAAQ,KAAK,mBAAmB,YAAY,CAAC;EAChE,QAAQ,UAA2B;AACjC,OAAI,cAAc,MAAM,EAAE;IACxB,MAAM,UAAU,gBAAgB,KAAK,MAAM,KAAK;AAChD,QAAI,OAAO,OAAO,QAAQ,CACxB,QAAO,QAAQ;;AAGnB,OAAI,oBAAoB,OACtB,QAAO,gBAAgB,MAAM;AAE/B,SAAM;;EAET,CAAC;AACJ,QAAO,OAAO,MAAM,MAAM,mBAAmB,CAAC,KAC5C,MAAM,IAAI,YAAY,8BACpB,OAAO,IAAI,aAAa;EAItB,MAAM,iBAAiB,OAAO,OAHV,OAAO,OAAO,OAChC,0BAA0B,KAC3B,CAAC,KAAK,CAC0C;AACjD,SAAO,OAAO,OAAO,OAAO,0BAA0B,QAAQ,CAC5D,eACD;GACD,CACH,EACD,MAAM,IAAI,gBAAgB,OAAO,KAAK,CAAC,EACvC,MAAM,WACP;EACD"}
|
package/dist/Refs.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
type Refs<ConvexSpec extends AnyWithPropsWithRuntime<"Convex">, NodeSpec extends AnyWithPropsWithRuntime<"Node"> = never, Predicate extends Any = Any> = Types.Simplify<OmitEmpty<Helper<Groups$1<ConvexSpec> | (NodeSpec extends never ? never : GroupSpec<"Node", "node", never, NodeSpec["groups"][keyof NodeSpec["groups"]]>), Predicate>>>;
|
|
12
|
-
type GroupRefs<Group extends AnyWithProps$1, Predicate extends Any> = Types.Simplify<OmitEmpty<Helper<Groups<Group>, Predicate>> & FilteredFunctions<Functions<Group>, Predicate>>;
|
|
13
|
-
type OmitEmpty<T> = { [K in keyof T as keyof T[K] extends never ? never : K]: T[K] };
|
|
14
|
-
type FunctionSpecMatchesPredicate<FunctionSpec_ extends AnyWithProps, Predicate extends Any> = Ref$1<GetRuntimeAndFunctionType<FunctionSpec_>, GetFunctionVisibility<FunctionSpec_>, any, any> extends Predicate ? true : false;
|
|
15
|
-
type FilteredFunctions<FunctionSpecs extends AnyWithProps, Predicate extends Any> = { [Name in Name$1<FunctionSpecs> as WithName<FunctionSpecs, Name> extends infer FunctionSpec_ extends AnyWithProps ? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true ? Name : never : never]: WithName<FunctionSpecs, Name> extends infer F extends AnyWithProps ? FromFunctionSpec<F> : never };
|
|
16
|
-
type Helper<Groups extends AnyWithProps$1, Predicate extends Any> = { [GroupName in Name$2<Groups>]: WithName$1<Groups, GroupName> extends infer Group extends AnyWithProps$1 ? GroupRefs<Group, Predicate> : never };
|
|
17
|
-
declare const make: <ConvexSpec extends AnyWithPropsWithRuntime<"Convex">, NodeSpec extends AnyWithPropsWithRuntime<"Node"> = never>(convexSpec: ConvexSpec, nodeSpec?: NodeSpec) => {
|
|
18
|
-
public: Refs<ConvexSpec, NodeSpec, AnyPublic>;
|
|
19
|
-
internal: Refs<ConvexSpec, NodeSpec, AnyInternal>;
|
|
1
|
+
import type { Types } from "effect";
|
|
2
|
+
import type * as FunctionSpec from "./FunctionSpec";
|
|
3
|
+
import type * as GroupSpec from "./GroupSpec";
|
|
4
|
+
import * as Ref from "./Ref";
|
|
5
|
+
import type * as Spec from "./Spec";
|
|
6
|
+
export type Refs<Spec_ extends Spec.AnyWithProps, Predicate extends Ref.Any = Ref.Any> = Types.Simplify<OmitEmpty<Helper<Spec.Groups<Spec_>, Predicate>>>;
|
|
7
|
+
type GroupRefs<Group extends GroupSpec.AnyWithProps, Predicate extends Ref.Any> = Types.Simplify<OmitEmpty<Helper<GroupSpec.Groups<Group>, Predicate>> & FilteredFunctions<GroupSpec.Functions<Group>, Predicate>>;
|
|
8
|
+
type OmitEmpty<T> = {
|
|
9
|
+
[K in keyof T as keyof T[K] extends never ? never : K]: T[K];
|
|
20
10
|
};
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
type FunctionSpecMatchesPredicate<FunctionSpec_ extends FunctionSpec.AnyWithProps, Predicate extends Ref.Any> = Ref.Ref<FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>, FunctionSpec.GetFunctionVisibility<FunctionSpec_>, any, any> extends Predicate ? true : false;
|
|
12
|
+
type FilteredFunctions<FunctionSpecs extends FunctionSpec.AnyWithProps, Predicate extends Ref.Any> = {
|
|
13
|
+
[Name in FunctionSpec.Name<FunctionSpecs> as FunctionSpec.WithName<FunctionSpecs, Name> extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps ? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true ? Name : never : never]: FunctionSpec.WithName<FunctionSpecs, Name> extends infer F extends FunctionSpec.AnyWithProps ? Ref.FromFunctionSpec<F> : never;
|
|
14
|
+
};
|
|
15
|
+
type Helper<Groups extends GroupSpec.AnyWithProps, Predicate extends Ref.Any> = {
|
|
16
|
+
[GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<Groups, GroupName> extends infer Group extends GroupSpec.AnyWithProps ? GroupRefs<Group, Predicate> : never;
|
|
17
|
+
};
|
|
18
|
+
export declare const make: <Spec_ extends Spec.AnyWithProps>(spec: Spec_) => {
|
|
19
|
+
public: Refs<Spec_, Ref.AnyPublic>;
|
|
20
|
+
internal: Refs<Spec_, Ref.AnyInternal>;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
23
23
|
//# sourceMappingURL=Refs.d.ts.map
|
package/dist/Refs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Refs.d.ts","
|
|
1
|
+
{"version":3,"file":"Refs.d.ts","sourceRoot":"","sources":["../src/Refs.ts"],"names":[],"mappings":"AAA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J,KAAK,CAAC;AAEZ,KAAK,iBAAiB,CACpB,aAAa,SAAS,YAAY,CAAC,YAAY,EAC/C,SAAS,SAAS,GAAG,CAAC,GAAG,IACvB;KACD,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,YAAY,CAAC,QAAQ,CAChE,aAAa,EACb,IAAI,CACL,SAAS,MAAM,aAAa,SAAS,YAAY,CAAC,YAAY,GAC3D,4BAA4B,CAAC,aAAa,EAAE,SAAS,CAAC,SAAS,IAAI,GACjE,IAAI,GACJ,KAAK,GACP,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,MAAM,CAAC,SACpE,YAAY,CAAC,YAAY,GACvB,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,GACvB,KAAK;CACV,CAAC;AAEF,KAAK,MAAM,CACT,MAAM,SAAS,SAAS,CAAC,YAAY,EACrC,SAAS,SAAS,GAAG,CAAC,GAAG,IACvB;KACD,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,QAAQ,CACvD,MAAM,EACN,SAAS,CACV,SAAS,MAAM,KAAK,SAAS,SAAS,CAAC,YAAY,GAChD,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,GAC3B,KAAK;CACV,CAAC;AAQF,eAAO,MAAM,IAAI,GAAI,KAAK,SAAS,IAAI,CAAC,YAAY,EAClD,MAAM,KAAK,KACV;IACD,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IACnC,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CAOxC,CAAC"}
|
package/dist/Refs.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { makeNodeAt } from "./GroupSpec.js";
|
|
3
2
|
import { getConvexFunctionName, make as make$1 } from "./Ref.js";
|
|
4
|
-
import
|
|
3
|
+
import * as Record from "effect/Record";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import { pipe } from "effect/Function";
|
|
5
6
|
|
|
6
7
|
//#region src/Refs.ts
|
|
7
8
|
var Refs_exports = /* @__PURE__ */ __exportAll({ make: () => make });
|
|
8
|
-
const make = (
|
|
9
|
-
const refs = makeHelper(
|
|
10
|
-
onNone: () => convexSpec.groups,
|
|
11
|
-
onSome: (nodeGroup) => ({
|
|
12
|
-
...convexSpec.groups,
|
|
13
|
-
node: nodeGroup
|
|
14
|
-
})
|
|
15
|
-
})));
|
|
9
|
+
const make = (spec) => {
|
|
10
|
+
const refs = makeHelper(spec.groups);
|
|
16
11
|
return {
|
|
17
12
|
public: refs,
|
|
18
13
|
internal: refs
|
package/dist/Refs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Refs.js","names":["
|
|
1
|
+
{"version":3,"file":"Refs.js","names":["Ref.make","Ref.getConvexFunctionName"],"sources":["../src/Refs.ts"],"sourcesContent":["import type { Types } from \"effect\";\nimport { pipe } from \"effect/Function\";\nimport * as Option from \"effect/Option\";\nimport * as Record from \"effect/Record\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as GroupSpec from \"./GroupSpec\";\nimport * as Ref from \"./Ref\";\nimport type * as Spec from \"./Spec\";\n\nexport type Refs<\n Spec_ extends Spec.AnyWithProps,\n Predicate extends Ref.Any = Ref.Any,\n> = Types.Simplify<OmitEmpty<Helper<Spec.Groups<Spec_>, Predicate>>>;\n\ntype GroupRefs<\n Group extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = Types.Simplify<\n OmitEmpty<Helper<GroupSpec.Groups<Group>, Predicate>> &\n FilteredFunctions<GroupSpec.Functions<Group>, Predicate>\n>;\n\ntype OmitEmpty<T> = {\n [K in keyof T as keyof T[K] extends never ? never : K]: T[K];\n};\n\ntype FunctionSpecMatchesPredicate<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> =\n Ref.Ref<\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n any,\n any\n > extends Predicate\n ? true\n : false;\n\ntype FilteredFunctions<\n FunctionSpecs extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = {\n [Name in FunctionSpec.Name<FunctionSpecs> as FunctionSpec.WithName<\n FunctionSpecs,\n Name\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true\n ? Name\n : never\n : never]: FunctionSpec.WithName<FunctionSpecs, Name> extends infer F extends\n FunctionSpec.AnyWithProps\n ? Ref.FromFunctionSpec<F>\n : never;\n};\n\ntype Helper<\n Groups extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupRefs<Group, Predicate>\n : never;\n};\n\ntype Any =\n | {\n readonly [key: string]: Any;\n }\n | Ref.Any;\n\nexport const make = <Spec_ extends Spec.AnyWithProps>(\n spec: Spec_,\n): {\n public: Refs<Spec_, Ref.AnyPublic>;\n internal: Refs<Spec_, Ref.AnyInternal>;\n} => {\n const refs = makeHelper(spec.groups);\n return {\n public: refs as Refs<Spec_, Ref.AnyPublic>,\n internal: refs as Refs<Spec_, Ref.AnyInternal>,\n };\n};\n\nconst makeHelper = (\n groups: Record.ReadonlyRecord<string, GroupSpec.Any>,\n functionNamespace: Option.Option<string> = Option.none(),\n): Any =>\n pipe(\n groups as Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n Record.map((group, name) => {\n const currentFunctionNamespace = Option.match(functionNamespace, {\n onNone: () => name,\n onSome: (parentNamespace) => `${parentNamespace}/${name}`,\n });\n\n return Record.union(\n makeHelper(group.groups, Option.some(currentFunctionNamespace)),\n Record.map(group.functions, (function_) =>\n Ref.make(currentFunctionNamespace, function_),\n ),\n (_subGroup, _function) => {\n throw new Error(\n `Group and function at same level have same name ('${Ref.getConvexFunctionName(_function)}')`,\n );\n },\n );\n }),\n );\n"],"mappings":";;;;;;;;AA0EA,MAAa,QACX,SAIG;CACH,MAAM,OAAO,WAAW,KAAK,OAAO;AACpC,QAAO;EACL,QAAQ;EACR,UAAU;EACX;;AAGH,MAAM,cACJ,QACA,oBAA2C,OAAO,MAAM,KAExD,KACE,QACA,OAAO,KAAK,OAAO,SAAS;CAC1B,MAAM,2BAA2B,OAAO,MAAM,mBAAmB;EAC/D,cAAc;EACd,SAAS,oBAAoB,GAAG,gBAAgB,GAAG;EACpD,CAAC;AAEF,QAAO,OAAO,MACZ,WAAW,MAAM,QAAQ,OAAO,KAAK,yBAAyB,CAAC,EAC/D,OAAO,IAAI,MAAM,YAAY,cAC3BA,OAAS,0BAA0B,UAAU,CAC9C,GACA,WAAW,cAAc;AACxB,QAAM,IAAI,MACR,qDAAqDC,sBAA0B,UAAU,CAAC,IAC3F;GAEJ;EACD,CACH"}
|
package/dist/Registry.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
//#region src/Registry.d.ts
|
|
4
|
-
declare namespace Registry_d_exports {
|
|
5
|
-
export { Registry, RegistryItems };
|
|
6
|
-
}
|
|
1
|
+
import * as Context from "effect/Context";
|
|
2
|
+
import * as Ref from "effect/Ref";
|
|
7
3
|
/**
|
|
8
4
|
* Recursive tree that mirrors a `Spec`'s group structure. Leaves are the
|
|
9
5
|
* per-function items written by each `FunctionImpl`'s layer initializer. The
|
|
@@ -12,8 +8,8 @@ declare namespace Registry_d_exports {
|
|
|
12
8
|
* consumers (the server runtime and the CLI's `implValidation`) narrow as
|
|
13
9
|
* needed.
|
|
14
10
|
*/
|
|
15
|
-
interface RegistryItems {
|
|
16
|
-
|
|
11
|
+
export interface RegistryItems {
|
|
12
|
+
readonly [key: string]: unknown | RegistryItems;
|
|
17
13
|
}
|
|
18
14
|
declare const Registry_base: Context.ReferenceClass<Registry, "@confect/core/Registry", Ref.Ref<RegistryItems>>;
|
|
19
15
|
/**
|
|
@@ -25,7 +21,7 @@ declare const Registry_base: Context.ReferenceClass<Registry, "@confect/core/Reg
|
|
|
25
21
|
* Effect's global default-value cache to align two separately-defined tags
|
|
26
22
|
* by string key.
|
|
27
23
|
*/
|
|
28
|
-
declare class Registry extends Registry_base {
|
|
29
|
-
|
|
30
|
-
export {
|
|
24
|
+
export declare class Registry extends Registry_base {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
31
27
|
//# sourceMappingURL=Registry.d.ts.map
|
package/dist/Registry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Registry.d.ts","
|
|
1
|
+
{"version":3,"file":"Registry.d.ts","sourceRoot":"","sources":["../src/Registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,YAAY,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC;CACjD;;AAED;;;;;;;;GAQG;AACH,qBAAa,QAAS,SAAQ,aAK7B;CAAG"}
|
package/dist/Registry.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Ref from "effect/Ref";
|
|
3
4
|
|
|
4
5
|
//#region src/Registry.ts
|
|
5
6
|
var Registry_exports = /* @__PURE__ */ __exportAll({ Registry: () => Registry });
|
package/dist/Registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Registry.js","names":[],"sources":["../src/Registry.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"Registry.js","names":[],"sources":["../src/Registry.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport * as Ref from \"effect/Ref\";\n\n/**\n * Recursive tree that mirrors a `Spec`'s group structure. Leaves are the\n * per-function items written by each `FunctionImpl`'s layer initializer. The\n * leaf type is intentionally `unknown` here so `@confect/core` does not need\n * to know about `@confect/server`'s `RegistryItem` shape; producers and\n * consumers (the server runtime and the CLI's `implValidation`) narrow as\n * needed.\n */\nexport interface RegistryItems {\n readonly [key: string]: unknown | RegistryItems;\n}\n\n/**\n * Effect `Context.Reference` keyed by `@confect/core/Registry`. Lives in\n * `@confect/core` so `@confect/server` (which writes to it from\n * `FunctionImpl` initializers and reads it from `RegisteredFunctions`) and\n * `@confect/cli` (which inspects it during impl validation) can share the\n * exact same `Ref` instance by importing the same tag — without relying on\n * Effect's global default-value cache to align two separately-defined tags\n * by string key.\n */\nexport class Registry extends Context.Reference<Registry>()(\n \"@confect/core/Registry\",\n {\n defaultValue: () => Ref.unsafeMake<RegistryItems>({}),\n },\n) {}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAa,WAAb,cAA8B,QAAQ,WAAqB,CACzD,0BACA,EACE,oBAAoB,IAAI,WAA0B,EAAE,CAAC,EACtD,CACF,CAAC"}
|
|
@@ -1,54 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
type RuntimeAndFunctionType = {
|
|
5
|
-
readonly runtime: "Convex";
|
|
6
|
-
readonly functionType: "query";
|
|
1
|
+
export type RuntimeAndFunctionType = {
|
|
2
|
+
readonly runtime: "Convex";
|
|
3
|
+
readonly functionType: "query";
|
|
7
4
|
} | {
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
readonly runtime: "Convex";
|
|
6
|
+
readonly functionType: "mutation";
|
|
10
7
|
} | {
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
readonly runtime: "Convex";
|
|
9
|
+
readonly functionType: "action";
|
|
13
10
|
} | {
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
readonly runtime: "Node";
|
|
12
|
+
readonly functionType: "action";
|
|
16
13
|
};
|
|
17
|
-
type Runtime = RuntimeAndFunctionType["runtime"];
|
|
18
|
-
type AnyQuery = Extract<RuntimeAndFunctionType, {
|
|
19
|
-
|
|
14
|
+
export type Runtime = RuntimeAndFunctionType["runtime"];
|
|
15
|
+
export type AnyQuery = Extract<RuntimeAndFunctionType, {
|
|
16
|
+
readonly functionType: "query";
|
|
20
17
|
}>;
|
|
21
|
-
type AnyMutation = Extract<RuntimeAndFunctionType, {
|
|
22
|
-
|
|
18
|
+
export type AnyMutation = Extract<RuntimeAndFunctionType, {
|
|
19
|
+
readonly functionType: "mutation";
|
|
23
20
|
}>;
|
|
24
|
-
type AnyAction = Extract<RuntimeAndFunctionType, {
|
|
25
|
-
|
|
21
|
+
export type AnyAction = Extract<RuntimeAndFunctionType, {
|
|
22
|
+
readonly functionType: "action";
|
|
26
23
|
}>;
|
|
27
|
-
type WithRuntime<Runtime_ extends Runtime> = Extract<RuntimeAndFunctionType, {
|
|
28
|
-
|
|
24
|
+
export type WithRuntime<Runtime_ extends Runtime> = Extract<RuntimeAndFunctionType, {
|
|
25
|
+
readonly runtime: Runtime_;
|
|
29
26
|
}>;
|
|
30
|
-
type GetRuntime<RuntimeAndFunctionType_ extends RuntimeAndFunctionType> = RuntimeAndFunctionType_["runtime"];
|
|
31
|
-
type GetFunctionType<RuntimeAndFunctionType_ extends RuntimeAndFunctionType> = RuntimeAndFunctionType_["functionType"];
|
|
32
|
-
declare const ConvexQuery: {
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
export type GetRuntime<RuntimeAndFunctionType_ extends RuntimeAndFunctionType> = RuntimeAndFunctionType_["runtime"];
|
|
28
|
+
export type GetFunctionType<RuntimeAndFunctionType_ extends RuntimeAndFunctionType> = RuntimeAndFunctionType_["functionType"];
|
|
29
|
+
export declare const ConvexQuery: {
|
|
30
|
+
readonly runtime: "Convex";
|
|
31
|
+
readonly functionType: "query";
|
|
35
32
|
};
|
|
36
|
-
type ConvexQuery = typeof ConvexQuery;
|
|
37
|
-
declare const ConvexMutation: {
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
export type ConvexQuery = typeof ConvexQuery;
|
|
34
|
+
export declare const ConvexMutation: {
|
|
35
|
+
readonly runtime: "Convex";
|
|
36
|
+
readonly functionType: "mutation";
|
|
40
37
|
};
|
|
41
|
-
type ConvexMutation = typeof ConvexMutation;
|
|
42
|
-
declare const ConvexAction: {
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
export type ConvexMutation = typeof ConvexMutation;
|
|
39
|
+
export declare const ConvexAction: {
|
|
40
|
+
readonly runtime: "Convex";
|
|
41
|
+
readonly functionType: "action";
|
|
45
42
|
};
|
|
46
|
-
type ConvexAction = typeof ConvexAction;
|
|
47
|
-
declare const NodeAction: {
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
export type ConvexAction = typeof ConvexAction;
|
|
44
|
+
export declare const NodeAction: {
|
|
45
|
+
readonly runtime: "Node";
|
|
46
|
+
readonly functionType: "action";
|
|
50
47
|
};
|
|
51
|
-
type NodeAction = typeof NodeAction;
|
|
52
|
-
//#endregion
|
|
53
|
-
export { AnyAction, AnyMutation, AnyQuery, ConvexAction, ConvexMutation, ConvexQuery, GetFunctionType, GetRuntime, NodeAction, Runtime, RuntimeAndFunctionType, RuntimeAndFunctionType_d_exports, WithRuntime };
|
|
48
|
+
export type NodeAction = typeof NodeAction;
|
|
54
49
|
//# sourceMappingURL=RuntimeAndFunctionType.d.ts.map
|