@confect/core 10.0.0-next.22 → 10.0.0-next.23

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/FunctionProvenance.d.ts +34 -25
  3. package/dist/FunctionProvenance.d.ts.map +1 -1
  4. package/dist/FunctionProvenance.js +13 -11
  5. package/dist/FunctionProvenance.js.map +1 -1
  6. package/dist/FunctionSpec.d.ts +12 -8
  7. package/dist/FunctionSpec.d.ts.map +1 -1
  8. package/dist/FunctionSpec.js.map +1 -1
  9. package/dist/GroupPath.d.ts +5 -6
  10. package/dist/GroupPath.d.ts.map +1 -1
  11. package/dist/GroupPath.js.map +1 -1
  12. package/dist/GroupSpec.d.ts +5 -2
  13. package/dist/GroupSpec.d.ts.map +1 -1
  14. package/dist/GroupSpec.js +2 -2
  15. package/dist/GroupSpec.js.map +1 -1
  16. package/dist/Identifier.d.ts +5 -4
  17. package/dist/Identifier.d.ts.map +1 -1
  18. package/dist/Identifier.js +5 -4
  19. package/dist/Identifier.js.map +1 -1
  20. package/dist/Lazy.d.ts +11 -12
  21. package/dist/Lazy.d.ts.map +1 -1
  22. package/dist/Lazy.js +11 -12
  23. package/dist/Lazy.js.map +1 -1
  24. package/dist/MiddlewareSpec.d.ts +27 -25
  25. package/dist/MiddlewareSpec.d.ts.map +1 -1
  26. package/dist/MiddlewareSpec.js +8 -4
  27. package/dist/MiddlewareSpec.js.map +1 -1
  28. package/dist/PaginationError.d.ts +9 -3
  29. package/dist/PaginationError.d.ts.map +1 -1
  30. package/dist/PaginationError.js +9 -3
  31. package/dist/PaginationError.js.map +1 -1
  32. package/dist/PaginationOptions.d.ts +2 -2
  33. package/dist/PaginationOptions.js +2 -2
  34. package/dist/PaginationOptions.js.map +1 -1
  35. package/dist/Ref.d.ts +38 -32
  36. package/dist/Ref.d.ts.map +1 -1
  37. package/dist/Ref.js +25 -25
  38. package/dist/Ref.js.map +1 -1
  39. package/dist/Refs.d.ts +1 -1
  40. package/dist/Refs.d.ts.map +1 -1
  41. package/dist/Refs.js +2 -1
  42. package/dist/Refs.js.map +1 -1
  43. package/dist/Spec.d.ts +14 -11
  44. package/dist/Spec.d.ts.map +1 -1
  45. package/dist/Spec.js +13 -8
  46. package/dist/Spec.js.map +1 -1
  47. package/dist/SystemFields.d.ts +14 -12
  48. package/dist/SystemFields.d.ts.map +1 -1
  49. package/dist/SystemFields.js +8 -6
  50. package/dist/SystemFields.js.map +1 -1
  51. package/dist/Table.d.ts +1 -0
  52. package/dist/Table.d.ts.map +1 -1
  53. package/dist/Table.js.map +1 -1
  54. package/dist/index.js +1 -1
  55. package/package.json +3 -2
  56. package/src/FunctionProvenance.ts +34 -25
  57. package/src/FunctionSpec.ts +12 -8
  58. package/src/GroupPath.ts +5 -6
  59. package/src/GroupSpec.ts +9 -5
  60. package/src/Identifier.ts +5 -4
  61. package/src/Lazy.ts +11 -12
  62. package/src/MiddlewareSpec.ts +27 -25
  63. package/src/PaginationError.ts +9 -3
  64. package/src/PaginationOptions.ts +2 -2
  65. package/src/Ref.ts +38 -32
  66. package/src/Refs.ts +2 -2
  67. package/src/Spec.ts +49 -38
  68. package/src/SystemFields.ts +14 -12
  69. package/src/Table.ts +1 -0
package/dist/Ref.d.ts CHANGED
@@ -19,16 +19,16 @@ export interface Base<RuntimeAndFunctionType_ extends RuntimeAndFunctionType.Run
19
19
  }
20
20
  /**
21
21
  * A reference to a single Convex function, as callers see it: the wire name
22
- * plus the data needed to encode args, decode returns, and decode typed
23
- * errors. A ref is one of two shapes, keyed by the spec's provenance.
22
+ * plus the data needed to encode args, decode returns, and decode typed errors.
23
+ * A ref is one of two shapes, keyed by the spec's provenance.
24
24
  */
25
25
  export type Ref<RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType, FunctionVisibility_ extends FunctionVisibility, Args_ extends DefaultFunctionArgs, Returns_, Error_ = never> = ConfectRefWithTypes<RuntimeAndFunctionType_, FunctionVisibility_, FunctionProvenance.ArgsFields, Args_, Returns_, Error_> | ConvexRef<RuntimeAndFunctionType_, FunctionVisibility_, Args_, Returns_, Error_>;
26
26
  export type ConfectRef<RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType, FunctionVisibility_ extends FunctionVisibility, ArgsFields_ extends FunctionProvenance.ArgsFields, ReturnsSchema_ extends Schema.Codec<any, any>, ErrorSchema_ extends Schema.Codec<any, any> = never, MiddlewareError_ = never> = ConfectRefWithTypes<RuntimeAndFunctionType_, FunctionVisibility_, ArgsFields_, Schema.Struct.Type<ArgsFields_>, ReturnsSchema_["Type"], ErrorSchema_["Type"] | MiddlewareError_>;
27
27
  /**
28
28
  * Internal form used while mapping a spec to a ref. Supplying the already
29
29
  * derived value types avoids repeatedly expanding `Schema.Struct` for every
30
- * leaf in a generated ref tree; the public `ConfectRef` alias still derives
31
- * the same values from its fields and schemas.
30
+ * leaf in a generated ref tree; the public `ConfectRef` alias still derives the
31
+ * same values from its fields and schemas.
32
32
  */
33
33
  interface ConfectRefWithTypes<RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType, FunctionVisibility_ extends FunctionVisibility, ArgsFields_ extends FunctionProvenance.ArgsFields, Args_ extends DefaultFunctionArgs, Returns_, Error_> extends Base<RuntimeAndFunctionType_, FunctionVisibility_, Args_, Returns_, Error_> {
34
34
  readonly _tag: "Confect";
@@ -43,7 +43,9 @@ export interface ConvexRef<RuntimeAndFunctionType_ extends RuntimeAndFunctionTyp
43
43
  readonly _tag: "Convex";
44
44
  }
45
45
  export type Any = Ref<any, any, any, any, any>;
46
- /** Erased Confect-provenance ref used by provenance-specific APIs. */
46
+ /**
47
+ * Erased Confect-provenance ref used by provenance-specific APIs.
48
+ */
47
49
  export type AnyConfect = Extract<Any, {
48
50
  readonly _tag: "Confect";
49
51
  }>;
@@ -75,14 +77,18 @@ export type GetFunctionVisibility<Ref_> = Ref_ extends {
75
77
  export type Args<Ref_> = Ref_ extends {
76
78
  readonly "~Args": infer Args_;
77
79
  } ? Args_ : never;
78
- /** The field map captured by a Confect-provenance ref. */
80
+ /**
81
+ * The field map captured by a Confect-provenance ref.
82
+ */
79
83
  export type ArgsFields<Ref_> = Ref_ extends {
80
84
  readonly _tag: "Confect";
81
85
  readonly args: {
82
86
  readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;
83
87
  };
84
88
  } ? ArgsFields_ : never;
85
- /** The assembled args schema carried by a Confect-provenance ref. */
89
+ /**
90
+ * The assembled args schema carried by a Confect-provenance ref.
91
+ */
86
92
  export type ArgsSchema<Ref_> = Ref_ extends {
87
93
  readonly _tag: "Confect";
88
94
  readonly args: infer ArgsSchema_ extends FunctionProvenance.AnyArgsSchema;
@@ -117,44 +123,44 @@ export declare const isConvexError: (error: unknown) => error is ConvexError<Val
117
123
  /**
118
124
  * Build a callback-style handler that decodes the ref's typed error from a
119
125
  * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The
120
- * fallback is also invoked when the input *is* a `ConvexError` but the ref
121
- * doesn't declare a typed-error schema—by definition such a value falls
122
- * outside the ref's error contract. Useful when adapting non-Effect APIs (e.g.
123
- * emitter callbacks for streamed subscriptions) to the same error semantics
124
- * that `runWithCodec` provides.
126
+ * fallback is also invoked when the input _is_ a `ConvexError` but the ref
127
+ * doesn't declare a typed-error schema—by definition such a value falls outside
128
+ * the ref's error contract. Useful when adapting non-Effect APIs (e.g. emitter
129
+ * callbacks for streamed subscriptions) to the same error semantics that
130
+ * `runWithCodec` provides.
125
131
  */
126
132
  export declare const decodeErrorOrElse: <Ref_ extends Any, E>(ref: Ref_, mapUnknownError: (error: unknown) => E) => (error: unknown) => Error<Ref_> | E;
127
133
  /**
128
- * Decode `encodedError` against the ref's error schema—the function's
129
- * declared `error` schema unioned with its covering middlewares' error
130
- * schemas. Returns `None` if the ref declares no typed error at all (Confect
131
- * ref without an `error` schema and without failing middleware, or a
132
- * Convex-provenance ref)—by definition there's nothing to decode the value
133
- * into, and the caller is responsible for deciding what to do (typically:
134
- * surface the original value as a defect).
134
+ * Decode `encodedError` against the ref's error schema—the function's declared
135
+ * `error` schema unioned with its covering middlewares' error schemas. Returns
136
+ * `None` if the ref declares no typed error at all (Confect ref without an
137
+ * `error` schema and without failing middleware, or a Convex-provenance ref)—by
138
+ * definition there's nothing to decode the value into, and the caller is
139
+ * responsible for deciding what to do (typically: surface the original value as
140
+ * a defect).
135
141
  */
136
142
  export declare const decodeError: <Ref_ extends Any>(ref: Ref_, encodedError: unknown) => Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError>;
137
143
  /**
138
144
  * Synchronous counterpart to `decodeError`. Returns `None` when the value is
139
- * not this ref's typed error—either because the ref declares no `error`
140
- * schema, or because `encodedError` doesn't match the one it declares.
145
+ * not this ref's typed error—either because the ref declares no `error` schema,
146
+ * or because `encodedError` doesn't match the one it declares.
141
147
  *
142
148
  * The second case is reachable in normal operation: Convex raises its own
143
- * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and
144
- * those never match a user-declared error schema. Callers pair this with a
145
- * fallback that surfaces the original error, so failing to decode must not
146
- * throw—a `ParseError` here would replace the real error with an opaque one
147
- * and lose the only useful diagnostic. Hence the `Option` suffix rather than
148
- * `Sync`, matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers
149
- * in this module all throw on a parse failure, and this one deliberately
150
- * doesn't.
149
+ * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and those
150
+ * never match a user-declared error schema. Callers pair this with a fallback
151
+ * that surfaces the original error, so failing to decode must not throw—a
152
+ * `ParseError` here would replace the real error with an opaque one and lose
153
+ * the only useful diagnostic. Hence the `Option` suffix rather than `Sync`,
154
+ * matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers in this
155
+ * module all throw on a parse failure, and this one deliberately doesn't.
151
156
  */
152
157
  export declare const decodeErrorOption: <Ref_ extends Any>(ref: Ref_, encodedError: unknown) => Option.Option<Error<Ref_>>;
153
158
  /**
154
- * Encode the args of a paginated query ref via its user-args schema—`paginationOpts` is excluded, since the pagination protocol fields are
159
+ * Encode the args of a paginated query ref via its user-args
160
+ * schema—`paginationOpts` is excluded, since the pagination protocol fields are
155
161
  * managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by
156
- * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery`
157
- * (or `internalPaginatedQuery`).
162
+ * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or
163
+ * `internalPaginatedQuery`).
158
164
  */
159
165
  export declare const encodePaginatedQueryArgsSync: <Ref_ extends AnyPublicPaginatedQuery>(ref: Ref_, args: Omit<Args<Ref_>, "paginationOpts">) => unknown;
160
166
  /**
package/dist/Ref.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Ref.d.ts","sourceRoot":"","sources":["../src/Ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,oBAAoB,MAAM,wBAAwB,CAAC;AACpE,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,IAAI,uBAAuB,EAC5C,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAEpD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,KAAK,sBAAsB,MAAM,0BAA0B,CAAC;AAExE,MAAM,WAAW,IAAI,CACnB,uBAAuB,SAAS,sBAAsB,CAAC,sBAAsB,EAC7E,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,GAAG,EAAE,CAAC,OAAO,IAAI,mBAAmB,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,aAC/D,OAAO,KAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAQ/B,CAAC;AAqBJ;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,IAAI,SAAS,GAAG,OACrC,IAAI,gBACK,OAAO,KACpB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,CAO3D,CAAC;AAEL;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,IAAI,SAAS,GAAG,OAC3C,IAAI,gBACK,OAAO,KACpB,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAOzB,CAAC;AAwBJ;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACvC,IAAI,SAAS,uBAAuB,OAE/B,IAAI,QACH,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,CAAC,KACvC,OAOA,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,IAAI,SAAS,uBAAuB,OACtE,IAAI,eACI,OAAO,KACnB,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAOK,CAAC;AAE7B;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GACvB,IAAI,SAAS,GAAG,EAChB,CAAC,iEAKoB,iBAAiB,CAAC,IAAI,CAAC,eAC7B,OAAO,KACjB,WAAW,CAAC,OAAO,CAAC,6BACC,OAAO,KAAK,CAAC,2FAyBvC,CAAC"}
package/dist/Ref.js CHANGED
@@ -70,11 +70,11 @@ const isConvexError = (error) => error instanceof ConvexError || typeof error ==
70
70
  /**
71
71
  * Build a callback-style handler that decodes the ref's typed error from a
72
72
  * caught `ConvexError`, or else forwards the value to `mapUnknownError`. The
73
- * fallback is also invoked when the input *is* a `ConvexError` but the ref
74
- * doesn't declare a typed-error schema—by definition such a value falls
75
- * outside the ref's error contract. Useful when adapting non-Effect APIs (e.g.
76
- * emitter callbacks for streamed subscriptions) to the same error semantics
77
- * that `runWithCodec` provides.
73
+ * fallback is also invoked when the input _is_ a `ConvexError` but the ref
74
+ * doesn't declare a typed-error schema—by definition such a value falls outside
75
+ * the ref's error contract. Useful when adapting non-Effect APIs (e.g. emitter
76
+ * callbacks for streamed subscriptions) to the same error semantics that
77
+ * `runWithCodec` provides.
78
78
  */
79
79
  const decodeErrorOrElse = (ref, mapUnknownError) => (error) => {
80
80
  if (isConvexError(error)) {
@@ -88,13 +88,13 @@ const errorSchemaOf = (ref) => Match.value(ref).pipe(Match.tag("Confect", (confe
88
88
  return schemas.length === 0 ? Option.none() : Option.some(schemas.length === 1 ? schemas[0] : Schema.Union(schemas));
89
89
  }), Match.tag("Convex", () => Option.none()), Match.exhaustive);
90
90
  /**
91
- * Decode `encodedError` against the ref's error schema—the function's
92
- * declared `error` schema unioned with its covering middlewares' error
93
- * schemas. Returns `None` if the ref declares no typed error at all (Confect
94
- * ref without an `error` schema and without failing middleware, or a
95
- * Convex-provenance ref)—by definition there's nothing to decode the value
96
- * into, and the caller is responsible for deciding what to do (typically:
97
- * surface the original value as a defect).
91
+ * Decode `encodedError` against the ref's error schema—the function's declared
92
+ * `error` schema unioned with its covering middlewares' error schemas. Returns
93
+ * `None` if the ref declares no typed error at all (Confect ref without an
94
+ * `error` schema and without failing middleware, or a Convex-provenance ref)—by
95
+ * definition there's nothing to decode the value into, and the caller is
96
+ * responsible for deciding what to do (typically: surface the original value as
97
+ * a defect).
98
98
  */
99
99
  const decodeError = (ref, encodedError) => Option.match(errorSchemaOf(ref), {
100
100
  onNone: () => Effect.succeed(Option.none()),
@@ -102,18 +102,17 @@ const decodeError = (ref, encodedError) => Option.match(errorSchemaOf(ref), {
102
102
  });
103
103
  /**
104
104
  * Synchronous counterpart to `decodeError`. Returns `None` when the value is
105
- * not this ref's typed error—either because the ref declares no `error`
106
- * schema, or because `encodedError` doesn't match the one it declares.
105
+ * not this ref's typed error—either because the ref declares no `error` schema,
106
+ * or because `encodedError` doesn't match the one it declares.
107
107
  *
108
108
  * The second case is reachable in normal operation: Convex raises its own
109
- * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and
110
- * those never match a user-declared error schema. Callers pair this with a
111
- * fallback that surfaces the original error, so failing to decode must not
112
- * throw—a `ParseError` here would replace the real error with an opaque one
113
- * and lose the only useful diagnostic. Hence the `Option` suffix rather than
114
- * `Sync`, matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers
115
- * in this module all throw on a parse failure, and this one deliberately
116
- * doesn't.
109
+ * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and those
110
+ * never match a user-declared error schema. Callers pair this with a fallback
111
+ * that surfaces the original error, so failing to decode must not throw—a
112
+ * `ParseError` here would replace the real error with an opaque one and lose
113
+ * the only useful diagnostic. Hence the `Option` suffix rather than `Sync`,
114
+ * matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers in this
115
+ * module all throw on a parse failure, and this one deliberately doesn't.
117
116
  */
118
117
  const decodeErrorOption = (ref, encodedError) => Option.flatMap(errorSchemaOf(ref), (schema) => Schema.decodeUnknownOption(schema)(encodedError));
119
118
  const missingPaginatedProvenanceError = (ref) => new globalThis.Error(`Paginated query ref "${getConvexFunctionName(ref)}" was not built with \`FunctionSpec.publicPaginatedQuery\` (or \`FunctionSpec.internalPaginatedQuery\`). Paginated encoding and decoding require the user-args and item schemas those constructors store. Define the function as, e.g.:
@@ -127,10 +126,11 @@ const paginatedKind = (ref) => Match.value(ref.kind).pipe(Match.tag("Paginated",
127
126
  throw missingPaginatedProvenanceError(ref);
128
127
  }), Match.exhaustive);
129
128
  /**
130
- * Encode the args of a paginated query ref via its user-args schema—`paginationOpts` is excluded, since the pagination protocol fields are
129
+ * Encode the args of a paginated query ref via its user-args
130
+ * schema—`paginationOpts` is excluded, since the pagination protocol fields are
131
131
  * managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by
132
- * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery`
133
- * (or `internalPaginatedQuery`).
132
+ * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or
133
+ * `internalPaginatedQuery`).
134
134
  */
135
135
  const encodePaginatedQueryArgsSync = (ref, args) => Match.value(ref).pipe(Match.tag("Confect", (confectRef) => Schema.encodeUnknownSync(paginatedKind(confectRef).userArgs)(args)), Match.tag("Convex", () => args), Match.exhaustive);
136
136
  /**
package/dist/Ref.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Ref.js","names":["MiddlewareSpec.errorSchemas"],"sources":["../src/Ref.ts"],"sourcesContent":["import type * as MiddlewareAttachment from \"./MiddlewareAttachment\";\nimport type {\n DefaultFunctionArgs,\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\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 FunctionProvenance from \"./FunctionProvenance\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport * as Lazy from \"./Lazy\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport interface Base<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\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 readonly convexFunctionName: string;\n}\n\n/**\n * A reference to a single Convex function, as callers see it: the wire name\n * plus the data needed to encode args, decode returns, and decode typed\n * errors. A ref is one of two shapes, keyed by the spec's provenance.\n */\nexport type Ref<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> =\n | ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n FunctionProvenance.ArgsFields,\n Args_,\n Returns_,\n Error_\n >\n | ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport type ConfectRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = never,\n MiddlewareError_ = never,\n> = ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Schema.Struct.Type<ArgsFields_>,\n ReturnsSchema_[\"Type\"],\n ErrorSchema_[\"Type\"] | MiddlewareError_\n>;\n\n/**\n * Internal form used while mapping a spec to a ref. Supplying the already\n * derived value types avoids repeatedly expanding `Schema.Struct` for every\n * leaf in a generated ref tree; the public `ConfectRef` alias still derives\n * the same values from its fields and schemas.\n */\ninterface ConfectRefWithTypes<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Confect\";\n readonly args: FunctionProvenance.ArgsSchema<ArgsFields_>;\n readonly returns: Schema.Codec<any, any>;\n readonly kind: FunctionProvenance.ConfectKind;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;\n readonly error?: Schema.Codec<any, any>;\n}\n\nexport interface ConvexRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Convex\";\n}\n\nexport type Any = Ref<any, any, any, any, any>;\n\n/** Erased Confect-provenance ref used by provenance-specific APIs. */\nexport type AnyConfect = Extract<Any, { readonly _tag: \"Confect\" }>;\n\nexport type AnyInternal = Ref<any, \"internal\", any, any, any>;\n\nexport type AnyPublic = Ref<any, \"public\", any, any, any>;\n\nexport type AnyQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPaginatedQuery = AnyQuery &\n Base<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n {\n [key: string]: any;\n paginationOpts: PaginationOptions;\n },\n PaginationResult<any>,\n any\n >;\n\nexport type AnyMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPublicQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicQuery = Extract<AnyPublicQuery, AnyConfect>;\n\nexport type AnyPublicPaginatedQuery = AnyPublicQuery & AnyPaginatedQuery;\n\nexport type AnyConfectPublicPaginatedQuery = AnyConfectPublicQuery &\n AnyPublicPaginatedQuery;\n\nexport type AnyPublicMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicMutation = Extract<AnyPublicMutation, AnyConfect>;\n\nexport type AnyPublicAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicAction = Extract<AnyPublicAction, AnyConfect>;\n\nexport type GetRuntimeAndFunctionType<Ref_> = Ref_ extends {\n readonly \"~RuntimeAndFunctionType\": infer RuntimeAndFunctionType_ extends\n RuntimeAndFunctionType.RuntimeAndFunctionType;\n}\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> = RuntimeAndFunctionType.GetRuntime<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionType<Ref_> = RuntimeAndFunctionType.GetFunctionType<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionVisibility<Ref_> = Ref_ extends {\n readonly \"~FunctionVisibility\": infer FunctionVisibility_;\n}\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> = Ref_ extends { readonly \"~Args\": infer Args_ }\n ? Args_\n : never;\n\n/** The field map captured by a Confect-provenance ref. */\nexport type ArgsFields<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? ArgsFields_\n : never;\n\n/** The assembled args schema carried by a Confect-provenance ref. */\nexport type ArgsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: infer ArgsSchema_ extends FunctionProvenance.AnyArgsSchema;\n}\n ? ArgsSchema_\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_> = Ref_ extends { readonly \"~Returns\": infer Returns_ }\n ? Returns_\n : never;\n\nexport type Error<Ref_> = Ref_ extends { readonly \"~Error\": infer Error_ }\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\nexport type FromFunctionSpec<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareError = never,\n> = FromFunctionSpecHelper<\n FunctionSpec_,\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.ArgsFields<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n FunctionSpec.Error<FunctionSpec_> | MiddlewareError\n>;\n\ntype FromFunctionSpecHelper<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_ extends DefaultFunctionArgs ? Args_ : never,\n Returns_,\n never\n >\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Args_,\n Returns_,\n Error_\n >\n : Ref<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\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 convexFunctionNamespace: string,\n functionSpec: FunctionSpec_,\n groupMiddlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment> = [],\n): FromFunctionSpec<FunctionSpec_> => {\n const convexFunctionName = `${convexFunctionNamespace}:${functionSpec.name}`;\n\n return Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Convex\",\n (): Any =>\n ({\n _tag: \"Convex\",\n convexFunctionName,\n }) as Any,\n ),\n Match.tag(\"Confect\", (provenance): Any => {\n const ref = {\n _tag: \"Confect\" as const,\n convexFunctionName,\n kind: provenance.kind,\n middlewareAttachments: [\n ...groupMiddlewareAttachments,\n ...functionSpec.middlewareAttachments,\n ],\n get middlewareSpecs() {\n return this.middlewareAttachments.map(({ spec }) => spec);\n },\n };\n\n Lazy.defineProperty(ref, \"args\", () => provenance.args);\n Lazy.defineProperty(ref, \"returns\", () => provenance.returns);\n if (\"error\" in provenance) {\n Lazy.defineProperty(ref, \"error\", () => provenance.error);\n }\n\n return ref as unknown as Any;\n }),\n Match.exhaustive,\n ) as FromFunctionSpec<FunctionSpec_>;\n};\n\nexport const getConvexFunctionName = (ref: Any): string =>\n ref.convexFunctionName;\n\nconst functionReferenceCache = new Map<string, FunctionReference<Any>>();\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> => {\n const convexFunctionName = getConvexFunctionName(ref);\n\n const cached = functionReferenceCache.get(convexFunctionName);\n if (cached !== undefined) {\n return cached as FunctionReference<Ref_>;\n }\n\n const functionReference = makeFunctionReference(convexFunctionName);\n functionReferenceCache.set(convexFunctionName, functionReference);\n\n return functionReference as FunctionReference<Ref_>;\n};\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref).pipe(\n Match.tag(\n \"Confect\",\n (confectRef) =>\n \"error\" in confectRef ||\n confectRef.middlewareSpecs.some(\n (middlewareSpec) => \"error\" in middlewareSpec,\n ),\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, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeEffect(confectRef.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_>, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownEffect(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns as Returns<Ref_>)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedArgs: unknown,\n): Args<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.args)(encodedArgs),\n ),\n Match.tag(\"Convex\", () => encodedArgs),\n Match.exhaustive,\n ) as Args<Ref_>;\n\nexport const encodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n returns: Returns<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => returns),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.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 = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\nconst errorSchemaOf = (ref: Any): Option.Option<Schema.Codec<any, any>> =>\n Match.value(ref).pipe(\n Match.tag(\"Confect\", (confectRef) => {\n const schemas = [\n ...(\"error\" in confectRef && confectRef.error !== undefined\n ? [confectRef.error]\n : []),\n ...MiddlewareSpec.errorSchemas(confectRef.middlewareSpecs),\n ];\n return schemas.length === 0\n ? Option.none<Schema.Codec<any, any>>()\n : Option.some(\n schemas.length === 1 ? schemas[0]! : Schema.Union(schemas),\n );\n }),\n Match.tag(\"Convex\", () => Option.none<Schema.Codec<any, any>>()),\n Match.exhaustive,\n );\n\n/**\n * Decode `encodedError` against the ref's error schema—the function's\n * declared `error` schema unioned with its covering middlewares' error\n * schemas. Returns `None` if the ref declares no typed error at all (Confect\n * ref without an `error` schema and without failing middleware, or a\n * 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_>>, Schema.SchemaError> =>\n Option.match(errorSchemaOf(ref), {\n onNone: () => Effect.succeed(Option.none<Error<Ref_>>()),\n onSome: (schema) =>\n Effect.asSome(\n Schema.decodeUnknownEffect(schema)(encodedError),\n ) as Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError>,\n });\n\n/**\n * Synchronous counterpart to `decodeError`. Returns `None` when the value is\n * not this ref's typed error—either because the ref declares no `error`\n * schema, or because `encodedError` doesn't match the one it declares.\n *\n * The second case is reachable in normal operation: Convex raises its own\n * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and\n * those never match a user-declared error schema. Callers pair this with a\n * fallback that surfaces the original error, so failing to decode must not\n * throw—a `ParseError` here would replace the real error with an opaque one\n * and lose the only useful diagnostic. Hence the `Option` suffix rather than\n * `Sync`, matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers\n * in this module all throw on a parse failure, and this one deliberately\n * doesn't.\n */\nexport const decodeErrorOption = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Option.flatMap(\n errorSchemaOf(ref),\n (schema) =>\n Schema.decodeUnknownOption(schema)(encodedError) as Option.Option<\n Error<Ref_>\n >,\n );\n\nconst missingPaginatedProvenanceError = (ref: Any) =>\n new globalThis.Error(\n `Paginated query ref \"${getConvexFunctionName(ref)}\" was not built with ` +\n \"`FunctionSpec.publicPaginatedQuery` (or `FunctionSpec.internalPaginatedQuery`). \" +\n \"Paginated encoding and decoding require the user-args and item schemas \" +\n \"those constructors store. Define the function as, e.g.:\\n\\n\" +\n \" FunctionSpec.publicPaginatedQuery({\\n\" +\n ' name: \"...\",\\n' +\n \" args: () => ({ ... }), // optional; without paginationOpts\\n\" +\n \" item: () => ItemSchema,\\n\" +\n \" })\",\n );\n\nconst paginatedKind = (ref: AnyConfect): FunctionProvenance.Paginated =>\n Match.value(ref.kind).pipe(\n Match.tag(\"Paginated\", (kind) => kind),\n Match.tag(\"Standard\", () => {\n throw missingPaginatedProvenanceError(ref);\n }),\n Match.exhaustive,\n );\n\n/**\n * Encode the args of a paginated query ref via its user-args schema—`paginationOpts` is excluded, since the pagination protocol fields are\n * managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by\n * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery`\n * (or `internalPaginatedQuery`).\n */\nexport const encodePaginatedQueryArgsSync = <\n Ref_ extends AnyPublicPaginatedQuery,\n>(\n ref: Ref_,\n args: Omit<Args<Ref_>, \"paginationOpts\">,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeUnknownSync(paginatedKind(confectRef).userArgs)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\n/**\n * Decode a page of a paginated query's results via the ref's item schema.\n * Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or\n * `internalPaginatedQuery`).\n */\nexport const decodePaginationPageSync = <Ref_ extends AnyPublicPaginatedQuery>(\n ref: Ref_,\n encodedPage: unknown,\n): Returns<Ref_>[\"page\"] =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(paginatedKind(confectRef).page)(encodedPage),\n ),\n Match.tag(\"Convex\", () => encodedPage),\n Match.exhaustive,\n ) as Returns<Ref_>[\"page\"];\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 = Effect.fnUntraced(function* <\n Ref_ extends Any,\n E = never,\n>(\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.fn.Return<Returns<Ref_>, E | Error<Ref_> | Schema.SchemaError> {\n const functionReference = getFunctionReference(ref);\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 = decodeErrorOption(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\n const encodedArgs = yield* encodeArgs(ref, args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* decodeReturns(ref, encodedReturns);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8TA,MAAa,QAMX,yBACA,cACA,6BAAuF,CAAC,MACpD;CACpC,MAAM,qBAAqB,GAAG,wBAAwB,GAAG,aAAa;CAEtE,OAAO,MAAM,MAAM,aAAa,kBAAkB,CAAC,CAAC,KAClD,MAAM,IACJ,iBAEG;EACC,MAAM;EACN;CACF,EACJ,GACA,MAAM,IAAI,YAAY,eAAoB;EACxC,MAAM,MAAM;GACV,MAAM;GACN;GACA,MAAM,WAAW;GACjB,uBAAuB,CACrB,GAAG,4BACH,GAAG,aAAa,qBAClB;GACA,IAAI,kBAAkB;IACpB,OAAO,KAAK,sBAAsB,KAAK,EAAE,WAAW,IAAI;GAC1D;EACF;EAEA,eAAoB,KAAK,cAAc,WAAW,IAAI;EACtD,eAAoB,KAAK,iBAAiB,WAAW,OAAO;EAC5D,IAAI,WAAW,YACb,eAAoB,KAAK,eAAe,WAAW,KAAK;EAG1D,OAAO;CACT,CAAC,GACD,MAAM,UACR;AACF;AAEA,MAAa,yBAAyB,QACpC,IAAI;AAEN,MAAM,yCAAyB,IAAI,IAAoC;AAEvE,MAAa,wBACX,QAC4B;CAC5B,MAAM,qBAAqB,sBAAsB,GAAG;CAEpD,MAAM,SAAS,uBAA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AAC;CAGH,MAAM,iBAAiB,OAAO,OAAO,OADV,WAAW,KAAK,IAAI,CACC;CAChD,OAAO,OAAO,cAAc,KAAK,cAAc;AACjD,CAAC"}
1
+ {"version":3,"file":"Ref.js","names":["MiddlewareSpec.errorSchemas"],"sources":["../src/Ref.ts"],"sourcesContent":["import type * as MiddlewareAttachment from \"./MiddlewareAttachment\";\nimport type {\n DefaultFunctionArgs,\n FunctionReference as ConvexFunctionReference,\n FunctionVisibility,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { makeFunctionReference } from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\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 FunctionProvenance from \"./FunctionProvenance\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport * as Lazy from \"./Lazy\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\n\nexport interface Base<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\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 readonly convexFunctionName: string;\n}\n\n/**\n * A reference to a single Convex function, as callers see it: the wire name\n * plus the data needed to encode args, decode returns, and decode typed errors.\n * A ref is one of two shapes, keyed by the spec's provenance.\n */\nexport type Ref<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> =\n | ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n FunctionProvenance.ArgsFields,\n Args_,\n Returns_,\n Error_\n >\n | ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n >;\n\nexport type ConfectRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n ReturnsSchema_ extends Schema.Codec<any, any>,\n ErrorSchema_ extends Schema.Codec<any, any> = never,\n MiddlewareError_ = never,\n> = ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Schema.Struct.Type<ArgsFields_>,\n ReturnsSchema_[\"Type\"],\n ErrorSchema_[\"Type\"] | MiddlewareError_\n>;\n\n/**\n * Internal form used while mapping a spec to a ref. Supplying the already\n * derived value types avoids repeatedly expanding `Schema.Struct` for every\n * leaf in a generated ref tree; the public `ConfectRef` alias still derives the\n * same values from its fields and schemas.\n */\ninterface ConfectRefWithTypes<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Confect\";\n readonly args: FunctionProvenance.ArgsSchema<ArgsFields_>;\n readonly returns: Schema.Codec<any, any>;\n readonly kind: FunctionProvenance.ConfectKind;\n readonly middlewareSpecs: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;\n readonly error?: Schema.Codec<any, any>;\n}\n\nexport interface ConvexRef<\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_ = never,\n> extends Base<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\n> {\n readonly _tag: \"Convex\";\n}\n\nexport type Any = Ref<any, any, any, any, any>;\n\n/**\n * Erased Confect-provenance ref used by provenance-specific APIs.\n */\nexport type AnyConfect = Extract<Any, { readonly _tag: \"Confect\" }>;\n\nexport type AnyInternal = Ref<any, \"internal\", any, any, any>;\n\nexport type AnyPublic = Ref<any, \"public\", any, any, any>;\n\nexport type AnyQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPaginatedQuery = AnyQuery &\n Base<\n RuntimeAndFunctionType.AnyQuery,\n FunctionVisibility,\n {\n [key: string]: any;\n paginationOpts: PaginationOptions;\n },\n PaginationResult<any>,\n any\n >;\n\nexport type AnyMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n FunctionVisibility,\n any,\n any,\n any\n>;\n\nexport type AnyPublicQuery = Ref<\n RuntimeAndFunctionType.AnyQuery,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicQuery = Extract<AnyPublicQuery, AnyConfect>;\n\nexport type AnyPublicPaginatedQuery = AnyPublicQuery & AnyPaginatedQuery;\n\nexport type AnyConfectPublicPaginatedQuery = AnyConfectPublicQuery &\n AnyPublicPaginatedQuery;\n\nexport type AnyPublicMutation = Ref<\n RuntimeAndFunctionType.AnyMutation,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicMutation = Extract<AnyPublicMutation, AnyConfect>;\n\nexport type AnyPublicAction = Ref<\n RuntimeAndFunctionType.AnyAction,\n \"public\",\n any,\n any,\n any\n>;\n\nexport type AnyConfectPublicAction = Extract<AnyPublicAction, AnyConfect>;\n\nexport type GetRuntimeAndFunctionType<Ref_> = Ref_ extends {\n readonly \"~RuntimeAndFunctionType\": infer RuntimeAndFunctionType_ extends\n RuntimeAndFunctionType.RuntimeAndFunctionType;\n}\n ? RuntimeAndFunctionType_\n : never;\n\nexport type GetRuntime<Ref_> = RuntimeAndFunctionType.GetRuntime<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionType<Ref_> = RuntimeAndFunctionType.GetFunctionType<\n GetRuntimeAndFunctionType<Ref_>\n>;\n\nexport type GetFunctionVisibility<Ref_> = Ref_ extends {\n readonly \"~FunctionVisibility\": infer FunctionVisibility_;\n}\n ? FunctionVisibility_\n : never;\n\nexport type Args<Ref_> = Ref_ extends { readonly \"~Args\": infer Args_ }\n ? Args_\n : never;\n\n/**\n * The field map captured by a Confect-provenance ref.\n */\nexport type ArgsFields<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? ArgsFields_\n : never;\n\n/**\n * The assembled args schema carried by a Confect-provenance ref.\n */\nexport type ArgsSchema<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: infer ArgsSchema_ extends FunctionProvenance.AnyArgsSchema;\n}\n ? ArgsSchema_\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_> = Ref_ extends { readonly \"~Returns\": infer Returns_ }\n ? Returns_\n : never;\n\nexport type Error<Ref_> = Ref_ extends { readonly \"~Error\": infer Error_ }\n ? Error_\n : never;\n\nexport type FunctionReference<Ref_ extends Any> = ConvexFunctionReference<\n GetFunctionType<Ref_>,\n GetFunctionVisibility<Ref_>\n>;\n\nexport type FromFunctionSpec<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n MiddlewareError = never,\n> = FromFunctionSpecHelper<\n FunctionSpec_,\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n FunctionSpec.ArgsFields<FunctionSpec_>,\n FunctionSpec.Args<FunctionSpec_>,\n FunctionSpec.Returns<FunctionSpec_>,\n FunctionSpec.Error<FunctionSpec_> | MiddlewareError\n>;\n\ntype FromFunctionSpecHelper<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,\n FunctionVisibility_ extends FunctionVisibility,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Args_ extends DefaultFunctionArgs,\n Returns_,\n Error_,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRef<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_ extends DefaultFunctionArgs ? Args_ : never,\n Returns_,\n never\n >\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRefWithTypes<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n ArgsFields_,\n Args_,\n Returns_,\n Error_\n >\n : Ref<\n RuntimeAndFunctionType_,\n FunctionVisibility_,\n Args_,\n Returns_,\n Error_\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 convexFunctionNamespace: string,\n functionSpec: FunctionSpec_,\n groupMiddlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment> = [],\n): FromFunctionSpec<FunctionSpec_> => {\n const convexFunctionName = `${convexFunctionNamespace}:${functionSpec.name}`;\n\n return Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\n \"Convex\",\n (): Any =>\n ({\n _tag: \"Convex\",\n convexFunctionName,\n }) as Any,\n ),\n Match.tag(\"Confect\", (provenance): Any => {\n const ref = {\n _tag: \"Confect\" as const,\n convexFunctionName,\n kind: provenance.kind,\n middlewareAttachments: [\n ...groupMiddlewareAttachments,\n ...functionSpec.middlewareAttachments,\n ],\n get middlewareSpecs() {\n return this.middlewareAttachments.map(({ spec }) => spec);\n },\n };\n\n Lazy.defineProperty(ref, \"args\", () => provenance.args);\n Lazy.defineProperty(ref, \"returns\", () => provenance.returns);\n if (\"error\" in provenance) {\n Lazy.defineProperty(ref, \"error\", () => provenance.error);\n }\n\n return ref as unknown as Any;\n }),\n Match.exhaustive,\n ) as FromFunctionSpec<FunctionSpec_>;\n};\n\nexport const getConvexFunctionName = (ref: Any): string =>\n ref.convexFunctionName;\n\nconst functionReferenceCache = new Map<string, FunctionReference<Any>>();\n\nexport const getFunctionReference = <Ref_ extends Any>(\n ref: Ref_,\n): FunctionReference<Ref_> => {\n const convexFunctionName = getConvexFunctionName(ref);\n\n const cached = functionReferenceCache.get(convexFunctionName);\n if (cached !== undefined) {\n return cached as FunctionReference<Ref_>;\n }\n\n const functionReference = makeFunctionReference(convexFunctionName);\n functionReferenceCache.set(convexFunctionName, functionReference);\n\n return functionReference as FunctionReference<Ref_>;\n};\n\nexport const hasErrorSchema = (ref: Any): boolean =>\n Match.value(ref).pipe(\n Match.tag(\n \"Confect\",\n (confectRef) =>\n \"error\" in confectRef ||\n confectRef.middlewareSpecs.some(\n (middlewareSpec) => \"error\" in middlewareSpec,\n ),\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, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeEffect(confectRef.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_>, Schema.SchemaError> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownEffect(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => Effect.succeed(returns as Returns<Ref_>)),\n Match.exhaustive,\n );\n\nexport const encodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n args: Args<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.args)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\nexport const decodeArgsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedArgs: unknown,\n): Args<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.args)(encodedArgs),\n ),\n Match.tag(\"Convex\", () => encodedArgs),\n Match.exhaustive,\n ) as Args<Ref_>;\n\nexport const encodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n returns: Returns<Ref_>,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeSync(confectRef.returns)(returns),\n ),\n Match.tag(\"Convex\", () => returns),\n Match.exhaustive,\n );\n\nexport const decodeReturnsSync = <Ref_ extends Any>(\n ref: Ref_,\n encodedReturns: unknown,\n): Returns<Ref_> =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(confectRef.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 outside\n * the ref's error contract. Useful when adapting non-Effect APIs (e.g. emitter\n * callbacks for streamed subscriptions) to the same error semantics that\n * `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 = decodeErrorOption(ref, error.data);\n if (Option.isSome(decoded)) {\n return decoded.value;\n }\n }\n return mapUnknownError(error);\n };\n\nconst errorSchemaOf = (ref: Any): Option.Option<Schema.Codec<any, any>> =>\n Match.value(ref).pipe(\n Match.tag(\"Confect\", (confectRef) => {\n const schemas = [\n ...(\"error\" in confectRef && confectRef.error !== undefined\n ? [confectRef.error]\n : []),\n ...MiddlewareSpec.errorSchemas(confectRef.middlewareSpecs),\n ];\n return schemas.length === 0\n ? Option.none<Schema.Codec<any, any>>()\n : Option.some(\n schemas.length === 1 ? schemas[0]! : Schema.Union(schemas),\n );\n }),\n Match.tag(\"Convex\", () => Option.none<Schema.Codec<any, any>>()),\n Match.exhaustive,\n );\n\n/**\n * Decode `encodedError` against the ref's error schema—the function's declared\n * `error` schema unioned with its covering middlewares' error schemas. Returns\n * `None` if the ref declares no typed error at all (Confect ref without an\n * `error` schema and without failing middleware, or a Convex-provenance ref)—by\n * definition there's nothing to decode the value into, and the caller is\n * responsible for deciding what to do (typically: surface the original value as\n * a defect).\n */\nexport const decodeError = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError> =>\n Option.match(errorSchemaOf(ref), {\n onNone: () => Effect.succeed(Option.none<Error<Ref_>>()),\n onSome: (schema) =>\n Effect.asSome(\n Schema.decodeUnknownEffect(schema)(encodedError),\n ) as Effect.Effect<Option.Option<Error<Ref_>>, Schema.SchemaError>,\n });\n\n/**\n * Synchronous counterpart to `decodeError`. Returns `None` when the value is\n * not this ref's typed error—either because the ref declares no `error` schema,\n * or because `encodedError` doesn't match the one it declares.\n *\n * The second case is reachable in normal operation: Convex raises its own\n * `ConvexError`s (an `InvalidCursor` pagination error, for instance), and those\n * never match a user-declared error schema. Callers pair this with a fallback\n * that surfaces the original error, so failing to decode must not throw—a\n * `ParseError` here would replace the real error with an opaque one and lose\n * the only useful diagnostic. Hence the `Option` suffix rather than `Sync`,\n * matching `Schema.decodeUnknownOption`: the sibling `*Sync` helpers in this\n * module all throw on a parse failure, and this one deliberately doesn't.\n */\nexport const decodeErrorOption = <Ref_ extends Any>(\n ref: Ref_,\n encodedError: unknown,\n): Option.Option<Error<Ref_>> =>\n Option.flatMap(\n errorSchemaOf(ref),\n (schema) =>\n Schema.decodeUnknownOption(schema)(encodedError) as Option.Option<\n Error<Ref_>\n >,\n );\n\nconst missingPaginatedProvenanceError = (ref: Any) =>\n new globalThis.Error(\n `Paginated query ref \"${getConvexFunctionName(ref)}\" was not built with ` +\n \"`FunctionSpec.publicPaginatedQuery` (or `FunctionSpec.internalPaginatedQuery`). \" +\n \"Paginated encoding and decoding require the user-args and item schemas \" +\n \"those constructors store. Define the function as, e.g.:\\n\\n\" +\n \" FunctionSpec.publicPaginatedQuery({\\n\" +\n ' name: \"...\",\\n' +\n \" args: () => ({ ... }), // optional; without paginationOpts\\n\" +\n \" item: () => ItemSchema,\\n\" +\n \" })\",\n );\n\nconst paginatedKind = (ref: AnyConfect): FunctionProvenance.Paginated =>\n Match.value(ref.kind).pipe(\n Match.tag(\"Paginated\", (kind) => kind),\n Match.tag(\"Standard\", () => {\n throw missingPaginatedProvenanceError(ref);\n }),\n Match.exhaustive,\n );\n\n/**\n * Encode the args of a paginated query ref via its user-args\n * schema—`paginationOpts` is excluded, since the pagination protocol fields are\n * managed by the client (e.g. `usePaginatedQuery` from `convex/react`), not by\n * the caller. Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or\n * `internalPaginatedQuery`).\n */\nexport const encodePaginatedQueryArgsSync = <\n Ref_ extends AnyPublicPaginatedQuery,\n>(\n ref: Ref_,\n args: Omit<Args<Ref_>, \"paginationOpts\">,\n): unknown =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.encodeUnknownSync(paginatedKind(confectRef).userArgs)(args),\n ),\n Match.tag(\"Convex\", () => args),\n Match.exhaustive,\n );\n\n/**\n * Decode a page of a paginated query's results via the ref's item schema.\n * Requires a ref built with `FunctionSpec.publicPaginatedQuery` (or\n * `internalPaginatedQuery`).\n */\nexport const decodePaginationPageSync = <Ref_ extends AnyPublicPaginatedQuery>(\n ref: Ref_,\n encodedPage: unknown,\n): Returns<Ref_>[\"page\"] =>\n Match.value<Any>(ref).pipe(\n Match.tag(\"Confect\", (confectRef) =>\n Schema.decodeUnknownSync(paginatedKind(confectRef).page)(encodedPage),\n ),\n Match.tag(\"Convex\", () => encodedPage),\n Match.exhaustive,\n ) as Returns<Ref_>[\"page\"];\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 = Effect.fnUntraced(function* <\n Ref_ extends Any,\n E = never,\n>(\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.fn.Return<Returns<Ref_>, E | Error<Ref_> | Schema.SchemaError> {\n const functionReference = getFunctionReference(ref);\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 = decodeErrorOption(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\n const encodedArgs = yield* encodeArgs(ref, args);\n const encodedReturns = yield* invoke(encodedArgs);\n return yield* decodeReturns(ref, encodedReturns);\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoUA,MAAa,QAMX,yBACA,cACA,6BAAuF,CAAC,MACpD;CACpC,MAAM,qBAAqB,GAAG,wBAAwB,GAAG,aAAa;CAEtE,OAAO,MAAM,MAAM,aAAa,kBAAkB,CAAC,CAAC,KAClD,MAAM,IACJ,iBAEG;EACC,MAAM;EACN;CACF,EACJ,GACA,MAAM,IAAI,YAAY,eAAoB;EACxC,MAAM,MAAM;GACV,MAAM;GACN;GACA,MAAM,WAAW;GACjB,uBAAuB,CACrB,GAAG,4BACH,GAAG,aAAa,qBAClB;GACA,IAAI,kBAAkB;IACpB,OAAO,KAAK,sBAAsB,KAAK,EAAE,WAAW,IAAI;GAC1D;EACF;EAEA,eAAoB,KAAK,cAAc,WAAW,IAAI;EACtD,eAAoB,KAAK,iBAAiB,WAAW,OAAO;EAC5D,IAAI,WAAW,YACb,eAAoB,KAAK,eAAe,WAAW,KAAK;EAG1D,OAAO;CACT,CAAC,GACD,MAAM,UACR;AACF;AAEA,MAAa,yBAAyB,QACpC,IAAI;AAEN,MAAM,yCAAyB,IAAI,IAAoC;AAEvE,MAAa,wBACX,QAC4B;CAC5B,MAAM,qBAAqB,sBAAsB,GAAG;CAEpD,MAAM,SAAS,uBAAuB,IAAI,kBAAkB;CAC5D,IAAI,WAAW,KAAA,GACb,OAAO;CAGT,MAAM,oBAAoB,sBAAsB,kBAAkB;CAClE,uBAAuB,IAAI,oBAAoB,iBAAiB;CAEhE,OAAO;AACT;AAEA,MAAa,kBAAkB,QAC7B,MAAM,MAAM,GAAG,CAAC,CAAC,KACf,MAAM,IACJ,YAC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AAM,MAAM,IAAI,IAAI,CAAC,CAAC,KACpB,MAAM,IAAI,cAAc,SAAS,IAAI,GACrC,MAAM,IAAI,kBAAkB;CAC1B,MAAM,gCAAgC,GAAG;AAC3C,CAAC,GACD,MAAM,UACR;;;;;;;;AASF,MAAa,gCAGX,KACA,SAEA,MAAM,MAAW,GAAG,CAAC,CAAC,KACpB,MAAM,IAAI,YAAY,eACpB,OAAO,kBAAkB,cAAc,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CACnE,GACA,MAAM,IAAI,gBAAgB,IAAI,GAC9B,MAAM,UACR;;;;;;AAOF,MAAa,4BACX,KACA,gBAEA,MAAM,MAAW,GAAG,CAAC,CAAC,KACpB,MAAM,IAAI,YAAY,eACpB,OAAO,kBAAkB,cAAc,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,CACtE,GACA,MAAM,IAAI,gBAAgB,WAAW,GACrC,MAAM,UACR;;;;;;;;;AAUF,MAAa,eAAe,OAAO,WAAW,WAI5C,KACA,MACA,MAIA,iBACuE;CACvE,MAAM,oBAAoB,qBAAqB,GAAG;CAClD,MAAM,UACJ,gBAEA,OAAO,WAAW;EAChB,WAAW,QAAQ,QAAQ,KAAK,mBAAmB,WAAW,CAAC;EAC/D,QAAQ,UAA2B;GACjC,IAAI,cAAc,KAAK,GAAG;IACxB,MAAM,UAAU,kBAAkB,KAAK,MAAM,IAAI;IACjD,IAAI,OAAO,OAAO,OAAO,GACvB,OAAO,QAAQ;GAEnB;GACA,IAAI,oBAAoB,KAAA,GACtB,OAAO,gBAAgB,KAAK;GAE9B,MAAM;EACR;CACF,CAAC;CAGH,MAAM,iBAAiB,OAAO,OAAO,OADV,WAAW,KAAK,IAAI,CACC;CAChD,OAAO,OAAO,cAAc,KAAK,cAAc;AACjD,CAAC"}
package/dist/Refs.d.ts CHANGED
@@ -3,7 +3,7 @@ import type * as FunctionSpec from "./FunctionSpec";
3
3
  import type * as GroupSpec from "./GroupSpec";
4
4
  import type * as MiddlewareSpec from "./MiddlewareSpec";
5
5
  import * as Ref from "./Ref";
6
- import type * as Spec from "./Spec";
6
+ import * as Spec from "./Spec";
7
7
  export type Refs<Spec_ extends Spec.AnyWithProps, Predicate extends Ref.Any = Ref.Any> = Types.Simplify<OmitEmpty<Helper<Spec.Groups<Spec_>, Predicate>>>;
8
8
  export interface FromSpec<Spec_ extends Spec.AnyWithProps> {
9
9
  public: Refs<Spec_, Ref.AnyPublic>;
@@ -1 +1 @@
1
- {"version":3,"file":"Refs.d.ts","sourceRoot":"","sources":["../src/Refs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAIpC,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,KAAK,SAAS,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,KAAK,IAAI,MAAM,QAAQ,CAAC;AAEpC,MAAM,MAAM,IAAI,CACd,KAAK,SAAS,IAAI,CAAC,YAAY,EAC/B,SAAS,SAAS,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IACjC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;AAErE,MAAM,WAAW,QAAQ,CAAC,KAAK,SAAS,IAAI,CAAC,YAAY;IACvD,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IACnC,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACxC;AAED,KAAK,SAAS,CACZ,KAAK,SAAS,SAAS,CAAC,YAAY,EACpC,SAAS,SAAS,GAAG,CAAC,GAAG,IACvB,KAAK,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CAAC,IAAI,YAAY,CAAC,QAAQ,CAC/D,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,GACR,YAAY,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,MAAM,CAAC,SAC3D,YAAY,CAAC,YAAY,GACvB,GAAG,CAAC,gBAAgB,CAClB,CAAC,EACD,CAAC,SAAS;QACR,QAAQ,CAAC,kBAAkB,EAAE;YAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;SAAE,CAAC;KAC3D,GAEO,eAAe,GACf,cAAc,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GACzD,KAAK,CACV,GACD,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,QAC5C,KAAK,KACV,QAAQ,CAAC,KAAK,CAMhB,CAAC"}
package/dist/Refs.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { getConvexFunctionName, make as make$1 } from "./Ref.js";
3
+ import { groups } from "./Spec.js";
3
4
  import * as Option from "effect/Option";
4
5
  import * as Record from "effect/Record";
5
6
  import { pipe } from "effect/Function";
6
7
  //#region src/Refs.ts
7
8
  var Refs_exports = /* @__PURE__ */ __exportAll({ make: () => make });
8
9
  const make = (spec) => {
9
- const refs = makeHelper(spec.groups);
10
+ const refs = makeHelper(groups(spec));
10
11
  return {
11
12
  public: refs,
12
13
  internal: refs
package/dist/Refs.js.map CHANGED
@@ -1 +1 @@
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 type * as MiddlewareSpec from \"./MiddlewareSpec\";\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\nexport interface FromSpec<Spec_ extends Spec.AnyWithProps> {\n public: Refs<Spec_, Ref.AnyPublic>;\n internal: Refs<Spec_, Ref.AnyInternal>;\n}\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<\n GroupSpec.Functions<Group>,\n Predicate,\n MiddlewareSpec.Error<GroupSpec.MiddlewareSpecs<Group>>\n >\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 any\n > extends Predicate\n ? true\n : false;\n\ntype FilteredFunctions<\n FunctionSpecs extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n MiddlewareError,\n> = {\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\n ]: FunctionSpec.WithName<FunctionSpecs, Name> extends infer F extends\n FunctionSpec.AnyWithProps\n ? Ref.FromFunctionSpec<\n F,\n F extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ?\n | MiddlewareError\n | MiddlewareSpec.Error<FunctionSpec.MiddlewareSpecs<F>>\n : never\n >\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): FromSpec<Spec_> => {\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 convexFunctionNamespace: Option.Option<string> = Option.none(),\n): Any =>\n pipe(\n groups as Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n Record.map((group, name) => {\n const currentConvexFunctionNamespace = Option.match(\n convexFunctionNamespace,\n {\n onNone: () => name,\n onSome: (parentNamespace) => `${parentNamespace}/${name}`,\n },\n );\n\n return Record.union(\n makeHelper(group.groups, Option.some(currentConvexFunctionNamespace)),\n Record.map(group.functions, (function_) =>\n Ref.make(\n currentConvexFunctionNamespace,\n function_,\n group.middlewareAttachments,\n ),\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":";;;;;;;AAiGA,MAAa,QACX,SACoB;CACpB,MAAM,OAAO,WAAW,KAAK,MAAM;CACnC,OAAO;EACL,QAAQ;EACR,UAAU;CACZ;AACF;AAEA,MAAM,cACJ,QACA,0BAAiD,OAAO,KAAK,MAE7D,KACE,QACA,OAAO,KAAK,OAAO,SAAS;CAC1B,MAAM,iCAAiC,OAAO,MAC5C,yBACA;EACE,cAAc;EACd,SAAS,oBAAoB,GAAG,gBAAgB,GAAG;CACrD,CACF;CAEA,OAAO,OAAO,MACZ,WAAW,MAAM,QAAQ,OAAO,KAAK,8BAA8B,CAAC,GACpE,OAAO,IAAI,MAAM,YAAY,cAC3BA,OACE,gCACA,WACA,MAAM,qBACR,CACF,IACC,WAAW,cAAc;EACxB,MAAM,IAAI,MACR,qDAAqDC,sBAA0B,SAAS,EAAE,GAC5F;CACF,CACF;AACF,CAAC,CACH"}
1
+ {"version":3,"file":"Refs.js","names":["Spec.groups","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 type * as MiddlewareSpec from \"./MiddlewareSpec\";\nimport * as Ref from \"./Ref\";\nimport * 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\nexport interface FromSpec<Spec_ extends Spec.AnyWithProps> {\n public: Refs<Spec_, Ref.AnyPublic>;\n internal: Refs<Spec_, Ref.AnyInternal>;\n}\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<\n GroupSpec.Functions<Group>,\n Predicate,\n MiddlewareSpec.Error<GroupSpec.MiddlewareSpecs<Group>>\n >\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 any\n > extends Predicate\n ? true\n : false;\n\ntype FilteredFunctions<\n FunctionSpecs extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n MiddlewareError,\n> = {\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\n ]: FunctionSpec.WithName<FunctionSpecs, Name> extends infer F extends\n FunctionSpec.AnyWithProps\n ? Ref.FromFunctionSpec<\n F,\n F extends {\n readonly functionProvenance: { readonly _tag: \"Confect\" };\n }\n ?\n | MiddlewareError\n | MiddlewareSpec.Error<FunctionSpec.MiddlewareSpecs<F>>\n : never\n >\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): FromSpec<Spec_> => {\n const refs = makeHelper(Spec.groups(spec));\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 convexFunctionNamespace: Option.Option<string> = Option.none(),\n): Any =>\n pipe(\n groups as Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n Record.map((group, name) => {\n const currentConvexFunctionNamespace = Option.match(\n convexFunctionNamespace,\n {\n onNone: () => name,\n onSome: (parentNamespace) => `${parentNamespace}/${name}`,\n },\n );\n\n return Record.union(\n makeHelper(group.groups, Option.some(currentConvexFunctionNamespace)),\n Record.map(group.functions, (function_) =>\n Ref.make(\n currentConvexFunctionNamespace,\n function_,\n group.middlewareAttachments,\n ),\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":";;;;;;;;AAiGA,MAAa,QACX,SACoB;CACpB,MAAM,OAAO,WAAWA,OAAY,IAAI,CAAC;CACzC,OAAO;EACL,QAAQ;EACR,UAAU;CACZ;AACF;AAEA,MAAM,cACJ,QACA,0BAAiD,OAAO,KAAK,MAE7D,KACE,QACA,OAAO,KAAK,OAAO,SAAS;CAC1B,MAAM,iCAAiC,OAAO,MAC5C,yBACA;EACE,cAAc;EACd,SAAS,oBAAoB,GAAG,gBAAgB,GAAG;CACrD,CACF;CAEA,OAAO,OAAO,MACZ,WAAW,MAAM,QAAQ,OAAO,KAAK,8BAA8B,CAAC,GACpE,OAAO,IAAI,MAAM,YAAY,cAC3BC,OACE,gCACA,WACA,MAAM,qBACR,CACF,IACC,WAAW,cAAc;EACxB,MAAM,IAAI,MACR,qDAAqDC,sBAA0B,SAAS,EAAE,GAC5F;CACF,CACF;AACF,CAAC,CACH"}
package/dist/Spec.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as Record from "effect/Record";
2
+ import * as Struct from "effect/Struct";
1
3
  import * as GroupSpec from "./GroupSpec";
2
4
  export declare const TypeId = "~@confect/core/Spec";
3
5
  export type TypeId = typeof TypeId;
@@ -9,20 +11,21 @@ export declare const isSpec: (u: unknown) => u is AnyWithProps;
9
11
  * group lives on the group itself (`GroupSpec.runtime`) and on each function's
10
12
  * `RuntimeAndFunctionType`; the spec does not carry a runtime of its own.
11
13
  */
12
- export interface Spec<Groups_ extends GroupSpec.AnyWithProps = never> {
13
- readonly [TypeId]: TypeId;
14
- readonly groups: {
15
- [GroupName in GroupSpec.Name<Groups_>]: GroupSpec.WithName<Groups_, GroupName>;
16
- };
17
- readonly "~Groups": Groups_;
18
- add<Group extends GroupSpec.AnyWithProps>(group: Group): Spec<Groups_ | Group>;
19
- addAt<const Name extends string, Group extends GroupSpec.AnyWithProps>(name: Name, group: Group): Spec<Groups_ | GroupSpec.NamedAt<Group, Name>>;
14
+ export interface Spec<Groups_ extends Record.ReadonlyRecord<string, GroupSpec.AnyWithProps> = {}> {
15
+ readonly [TypeId]: Readonly<Groups_>;
16
+ add<Group extends GroupSpec.AnyWithProps>(group: Group): Spec<Struct.Assign<Groups_, Record.ReadonlyRecord<GroupSpec.Name<Group>, Group>>>;
17
+ addAt<const Name extends string, Group extends GroupSpec.AnyWithProps>(name: Name, group: Group): Spec<Struct.Assign<Groups_, Record.ReadonlyRecord<Name, GroupSpec.NamedAt<Group, Name>>>>;
20
18
  }
21
19
  export interface Any {
22
- readonly [TypeId]: TypeId;
20
+ readonly [TypeId]: unknown;
23
21
  }
24
- export interface AnyWithProps extends Spec<GroupSpec.AnyWithProps> {
22
+ export interface AnyWithProps extends Any {
23
+ readonly [TypeId]: Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>;
25
24
  }
26
- export type Groups<Spec_ extends AnyWithProps> = Spec_["~Groups"];
25
+ export type Groups<Spec_ extends AnyWithProps> = Spec_[TypeId][keyof Spec_[TypeId]];
26
+ /**
27
+ * The group record stored by a spec, with its precise member types.
28
+ */
29
+ export declare const groups: <Spec_ extends AnyWithProps>(self: Spec_) => Spec_[TypeId];
27
30
  export declare const make: () => Spec;
28
31
  //# sourceMappingURL=Spec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Spec.d.ts","sourceRoot":"","sources":["../src/Spec.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,eAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC,eAAO,MAAM,MAAM,MAAO,OAAO,KAAG,CAAC,IAAI,YACP,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,IAAI,CAAC,OAAO,SAAS,SAAS,CAAC,YAAY,GAAG,KAAK;IAClE,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE;SACd,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,QAAQ,CACxD,OAAO,EACP,SAAS,CACV;KACF,CAAC;IACF,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B,GAAG,CAAC,KAAK,SAAS,SAAS,CAAC,YAAY,EACtC,KAAK,EAAE,KAAK,GACX,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;IAEzB,KAAK,CAAC,KAAK,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,SAAS,SAAS,CAAC,YAAY,EACnE,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,GACX,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,GAAG;IAClB,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC;CAAG;AAErE,MAAM,MAAM,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AC,MAAM,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,YAAa,SAAQ,GAAG;IACvC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC;CAC1E;AAED,MAAM,MAAM,MAAM,CAAC,KAAK,SAAS,YAAY,IAC3C,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,SAAS,YAAY,QACzC,KAAK,KACV,KAAK,CAAC,MAAM,CAAiB,CAAC;AA6BjC,eAAO,MAAM,IAAI,QAAO,IAAsB,CAAC"}
package/dist/Spec.js CHANGED
@@ -2,26 +2,31 @@ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { withName } from "./GroupSpec.js";
3
3
  import * as Predicate from "effect/Predicate";
4
4
  import * as Record from "effect/Record";
5
+ import * as Struct from "effect/Struct";
5
6
  //#region src/Spec.ts
6
7
  var Spec_exports = /* @__PURE__ */ __exportAll({
7
8
  TypeId: () => TypeId,
9
+ groups: () => groups,
8
10
  isSpec: () => isSpec,
9
11
  make: () => make
10
12
  });
11
13
  const TypeId = "~@confect/core/Spec";
12
14
  const isSpec = (u) => Predicate.hasProperty(u, TypeId);
13
- const Proto = {
14
- [TypeId]: TypeId,
15
+ /**
16
+ * The group record stored by a spec, with its precise member types.
17
+ */
18
+ const groups = (self) => self[TypeId];
19
+ const makeRecord = (record) => ({
20
+ [TypeId]: record,
15
21
  add(group) {
16
- return makeProto({ groups: Record.set(this.groups, group.name, group) });
22
+ return makeRecord(Struct.assign(record, Record.singleton(group.name, group)));
17
23
  },
18
24
  addAt(name, group) {
19
- return makeProto({ groups: Record.set(this.groups, name, withName(name, group)) });
25
+ return makeRecord(Struct.assign(record, Record.singleton(name, withName(name, group))));
20
26
  }
21
- };
22
- const makeProto = ({ groups }) => Object.assign(Object.create(Proto), { groups });
23
- const make = () => makeProto({ groups: {} });
27
+ });
28
+ const make = () => makeRecord({});
24
29
  //#endregion
25
- export { Spec_exports, TypeId, isSpec, make };
30
+ export { Spec_exports, TypeId, groups, isSpec, make };
26
31
 
27
32
  //# sourceMappingURL=Spec.js.map
package/dist/Spec.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Spec.js","names":["GroupSpec.withName"],"sources":["../src/Spec.ts"],"sourcesContent":["import * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as GroupSpec from \"./GroupSpec\";\n\nexport const TypeId = \"~@confect/core/Spec\";\nexport type TypeId = typeof TypeId;\n\nexport const isSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\n/**\n * A Confect spec: a flat container of function groups. Groups may be of any\n * runtime—a group built with `GroupSpec.makeNode()` (a Node action group) sits\n * alongside `GroupSpec.make()` groups in the same namespace. The runtime of a\n * group lives on the group itself (`GroupSpec.runtime`) and on each function's\n * `RuntimeAndFunctionType`; the spec does not carry a runtime of its own.\n */\nexport interface Spec<Groups_ extends GroupSpec.AnyWithProps = never> {\n readonly [TypeId]: TypeId;\n readonly groups: {\n [GroupName in GroupSpec.Name<Groups_>]: GroupSpec.WithName<\n Groups_,\n GroupName\n >;\n };\n readonly \"~Groups\": Groups_;\n\n add<Group extends GroupSpec.AnyWithProps>(\n group: Group,\n ): Spec<Groups_ | Group>;\n\n addAt<const Name extends string, Group extends GroupSpec.AnyWithProps>(\n name: Name,\n group: Group,\n ): Spec<Groups_ | GroupSpec.NamedAt<Group, Name>>;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends Spec<GroupSpec.AnyWithProps> {}\n\nexport type Groups<Spec_ extends AnyWithProps> = Spec_[\"~Groups\"];\n\nconst Proto = {\n [TypeId]: TypeId,\n\n add<Group extends GroupSpec.AnyWithProps>(this: AnyWithProps, group: Group) {\n return makeProto({\n groups: Record.set(this.groups, group.name, group),\n });\n },\n\n addAt<Group extends GroupSpec.AnyWithProps>(\n this: AnyWithProps,\n name: string,\n group: Group,\n ) {\n return makeProto({\n groups: Record.set(this.groups, name, GroupSpec.withName(name, group)),\n });\n },\n};\n\nconst makeProto = <Groups_ extends GroupSpec.AnyWithProps>({\n groups,\n}: {\n groups: Record.ReadonlyRecord<string, Groups_>;\n}): Spec<Groups_> =>\n Object.assign(Object.create(Proto), {\n groups,\n }) as Spec<Groups_>;\n\nexport const make = (): Spec => makeProto({ groups: {} });\n"],"mappings":";;;;;;;;;;AAIA,MAAa,SAAS;AAGtB,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,MAAM;AAqCjC,MAAM,QAAQ;EACX,SAAS;CAEV,IAA8D,OAAc;EAC1E,OAAO,UAAU,EACf,QAAQ,OAAO,IAAI,KAAK,QAAQ,MAAM,MAAM,KAAK,EACnD,CAAC;CACH;CAEA,MAEE,MACA,OACA;EACA,OAAO,UAAU,EACf,QAAQ,OAAO,IAAI,KAAK,QAAQ,MAAMA,SAAmB,MAAM,KAAK,CAAC,EACvE,CAAC;CACH;AACF;AAEA,MAAM,aAAqD,EACzD,aAIA,OAAO,OAAO,OAAO,OAAO,KAAK,GAAG,EAClC,OACF,CAAC;AAEH,MAAa,aAAmB,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC"}
1
+ {"version":3,"file":"Spec.js","names":["GroupSpec.withName"],"sources":["../src/Spec.ts"],"sourcesContent":["import * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as Struct from \"effect/Struct\";\nimport * as GroupSpec from \"./GroupSpec\";\n\nexport const TypeId = \"~@confect/core/Spec\";\nexport type TypeId = typeof TypeId;\n\nexport const isSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\n/**\n * A Confect spec: a flat container of function groups. Groups may be of any\n * runtime—a group built with `GroupSpec.makeNode()` (a Node action group) sits\n * alongside `GroupSpec.make()` groups in the same namespace. The runtime of a\n * group lives on the group itself (`GroupSpec.runtime`) and on each function's\n * `RuntimeAndFunctionType`; the spec does not carry a runtime of its own.\n */\nexport interface Spec<\n Groups_ extends Record.ReadonlyRecord<string, GroupSpec.AnyWithProps> = {},\n> {\n readonly [TypeId]: Readonly<Groups_>;\n\n add<Group extends GroupSpec.AnyWithProps>(\n group: Group,\n ): Spec<\n Struct.Assign<Groups_, Record.ReadonlyRecord<GroupSpec.Name<Group>, Group>>\n >;\n\n addAt<const Name extends string, Group extends GroupSpec.AnyWithProps>(\n name: Name,\n group: Group,\n ): Spec<\n Struct.Assign<\n Groups_,\n Record.ReadonlyRecord<Name, GroupSpec.NamedAt<Group, Name>>\n >\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: unknown;\n}\n\nexport interface AnyWithProps extends Any {\n readonly [TypeId]: Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>;\n}\n\nexport type Groups<Spec_ extends AnyWithProps> =\n Spec_[TypeId][keyof Spec_[TypeId]];\n\n/**\n * The group record stored by a spec, with its precise member types.\n */\nexport const groups = <Spec_ extends AnyWithProps>(\n self: Spec_,\n): Spec_[TypeId] => self[TypeId];\n\nconst makeRecord = <\n Groups_ extends Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n>(\n record: Groups_,\n): Spec<Groups_> => ({\n [TypeId]: record,\n add<Group extends GroupSpec.AnyWithProps>(group: Group) {\n return makeRecord(\n Struct.assign(\n record,\n Record.singleton<GroupSpec.Name<Group>, Group>(group.name, group),\n ),\n );\n },\n addAt<const Name extends string, Group extends GroupSpec.AnyWithProps>(\n name: Name,\n group: Group,\n ) {\n return makeRecord(\n Struct.assign(\n record,\n Record.singleton(name, GroupSpec.withName(name, group)),\n ),\n );\n },\n});\n\nexport const make = (): Spec => makeRecord({});\n"],"mappings":";;;;;;;;;;;;AAKA,MAAa,SAAS;AAGtB,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,MAAM;;;;AA6CjC,MAAa,UACX,SACkB,KAAK;AAEzB,MAAM,cAGJ,YACmB;EAClB,SAAS;CACV,IAA0C,OAAc;EACtD,OAAO,WACL,OAAO,OACL,QACA,OAAO,UAAwC,MAAM,MAAM,KAAK,CAClE,CACF;CACF;CACA,MACE,MACA,OACA;EACA,OAAO,WACL,OAAO,OACL,QACA,OAAO,UAAU,MAAMA,SAAmB,MAAM,KAAK,CAAC,CACxD,CACF;CACF;AACF;AAEA,MAAa,aAAmB,WAAW,CAAC,CAAC"}