@gaganref/confect-server 10.3.1-fork.11 → 10.3.1-fork.12
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.
|
@@ -19,7 +19,7 @@ declare const unsupported: unique symbol;
|
|
|
19
19
|
type Unsupported = typeof unsupported;
|
|
20
20
|
type Needs<Param> = [GenericActionCtx<GenericDataModel>] extends [Param] ? [GenericMutationCtx<GenericDataModel>] extends [Param] ? [GenericQueryCtx<GenericDataModel>] extends [Param] ? QueryRunner.QueryRunner : MutationRunner.MutationRunner : [GenericQueryCtx<GenericDataModel>] extends [Param] ? Unsupported : ActionRunner.ActionRunner : Unsupported;
|
|
21
21
|
type Method<Official> = {
|
|
22
|
-
[K in keyof Official & string]: Official[K] extends (ctx: infer Ctx, ...args:
|
|
22
|
+
[K in keyof Official & string]: Official[K] extends (ctx: infer Ctx, ...args: infer _Args) => Promise<unknown> ? Needs<Ctx> extends Unsupported ? never : K : never;
|
|
23
23
|
}[keyof Official & string];
|
|
24
24
|
type Call<F> = F extends (ctx: infer Ctx, ...args: infer Args) => Promise<infer A> ? (...args: Args) => Effect.Effect<A, never, Needs<Ctx>> : never;
|
|
25
25
|
type Lifted<Official> = <M extends Method<Official>>(method: M, ...args: Parameters<Call<Official[M]>>) => ReturnType<Call<Official[M]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OfficialComponent.d.ts","sourceRoot":"","sources":["../src/OfficialComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAEvD,OA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-
{"version":3,"file":"OfficialComponent.js","names":["ActionCtx.ActionCtx","MutationCtx.MutationCtx","QueryCtx.QueryCtx"],"sources":["../src/OfficialComponent.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport type {\n DefaultFunctionArgs,\n GenericActionCtx,\n GenericDataModel,\n GenericMutationCtx,\n GenericQueryCtx,\n} from \"convex/server\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport * as ActionCtx from \"./ActionCtx.js\";\nimport type * as ActionRunner from \"./ActionRunner.js\";\nimport * as MutationCtx from \"./MutationCtx.js\";\nimport type * as MutationRunner from \"./MutationRunner.js\";\nimport * as QueryCtx from \"./QueryCtx.js\";\nimport type * as QueryRunner from \"./QueryRunner.js\";\n\n/**\n * An official component's method rejected. `cause` is the rejection as thrown.\n */\nexport class ComponentCallFailed extends Schema.TaggedError<ComponentCallFailed>()(\n \"ComponentCallFailed\",\n { component: Schema.String, method: Schema.String, cause: Schema.Defect() },\n) {}\n\ndeclare const unsupported: unique symbol;\ntype Unsupported = typeof unsupported;\ntype Needs<Param> = [GenericActionCtx<GenericDataModel>] extends [Param]\n ? [GenericMutationCtx<GenericDataModel>] extends [Param]\n ? [GenericQueryCtx<GenericDataModel>] extends [Param]\n ? QueryRunner.QueryRunner\n : MutationRunner.MutationRunner\n : [GenericQueryCtx<GenericDataModel>] extends [Param]\n ? Unsupported\n : ActionRunner.ActionRunner\n : Unsupported;\n\ntype Method<Official> = {\n [K in keyof Official & string]: Official[K] extends (\n ctx: infer Ctx,\n ...args:
|
|
1
|
+
{"version":3,"file":"OfficialComponent.js","names":["ActionCtx.ActionCtx","MutationCtx.MutationCtx","QueryCtx.QueryCtx"],"sources":["../src/OfficialComponent.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport type {\n DefaultFunctionArgs,\n GenericActionCtx,\n GenericDataModel,\n GenericMutationCtx,\n GenericQueryCtx,\n} from \"convex/server\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport * as ActionCtx from \"./ActionCtx.js\";\nimport type * as ActionRunner from \"./ActionRunner.js\";\nimport * as MutationCtx from \"./MutationCtx.js\";\nimport type * as MutationRunner from \"./MutationRunner.js\";\nimport * as QueryCtx from \"./QueryCtx.js\";\nimport type * as QueryRunner from \"./QueryRunner.js\";\n\n/**\n * An official component's method rejected. `cause` is the rejection as thrown.\n */\nexport class ComponentCallFailed extends Schema.TaggedError<ComponentCallFailed>()(\n \"ComponentCallFailed\",\n { component: Schema.String, method: Schema.String, cause: Schema.Defect() },\n) {}\n\ndeclare const unsupported: unique symbol;\ntype Unsupported = typeof unsupported;\ntype Needs<Param> = [GenericActionCtx<GenericDataModel>] extends [Param]\n ? [GenericMutationCtx<GenericDataModel>] extends [Param]\n ? [GenericQueryCtx<GenericDataModel>] extends [Param]\n ? QueryRunner.QueryRunner\n : MutationRunner.MutationRunner\n : [GenericQueryCtx<GenericDataModel>] extends [Param]\n ? Unsupported\n : ActionRunner.ActionRunner\n : Unsupported;\n\ntype Method<Official> = {\n [K in keyof Official & string]: Official[K] extends (\n ctx: infer Ctx,\n ...args: infer _Args\n ) => Promise<unknown>\n ? Needs<Ctx> extends Unsupported\n ? never\n : K\n : never;\n}[keyof Official & string];\n\ntype Call<F> = F extends (\n ctx: infer Ctx,\n ...args: infer Args\n) => Promise<infer A>\n ? (...args: Args) => Effect.Effect<A, never, Needs<Ctx>>\n : never;\n\ntype Lifted<Official> = <M extends Method<Official>>(\n method: M,\n ...args: Parameters<Call<Official[M]>>\n) => ReturnType<Call<Official[M]>>;\n\n/**\n * Lift official promise methods, deriving each capability from its ctx\n * parameter. A rejection is caller misuse, a limit or a platform fault rather\n * than a domain fact, so it dies.\n */\nexport const make = <Official extends object>(\n component: string,\n official: Official,\n): Lifted<Official> => {\n const context = Effect.gen(function* () {\n const action = yield* Effect.serviceOption(\n ActionCtx.ActionCtx<GenericDataModel>(),\n );\n if (Option.isSome(action)) return action.value;\n const mutation = yield* Effect.serviceOption(\n MutationCtx.MutationCtx<GenericDataModel>(),\n );\n if (Option.isSome(mutation)) return mutation.value;\n const query = yield* Effect.serviceOption(\n QueryCtx.QueryCtx<GenericDataModel>(),\n );\n if (Option.isSome(query)) return query.value;\n return yield* Effect.die(\n new Error(`${component} called outside a Confect handler`),\n );\n });\n const call = Effect.fn(`${component}.call`)(function* (\n method: Method<Official>,\n ...args: unknown[]\n ) {\n const ctx = yield* context;\n // Method selects promise methods whose first argument accepts a native handler context.\n const invoke = official[method] as (\n native: typeof ctx,\n ...args: unknown[]\n ) => Promise<unknown>;\n return yield* Effect.tryPromise({\n try: () => invoke.call(official, ctx, ...args),\n catch: (cause) => ComponentCallFailed.make({ component, method, cause }),\n }).pipe(Effect.orDie);\n });\n // Confect installs the native ctx with the runner capability inferred by Needs.\n return call as unknown as Lifted<Official>;\n};\n\n/**\n * A function reference with its encoded arguments, ready for an official method\n * that takes both.\n */\nexport interface Fn<R extends Ref.Any> {\n readonly reference: Ref.FunctionReference<R>;\n readonly args: DefaultFunctionArgs;\n}\n\n/**\n * Encode a ref's arguments through its codecs to the wire record an official\n * method expects.\n */\nexport const encodeCall = <R extends Ref.Any>(\n ref: R,\n args: NoInfer<Ref.Args<R>>,\n): Effect.Effect<Fn<R>> =>\n Ref.encodeArgs(ref, args).pipe(\n Effect.flatMap(\n Schema.decodeUnknownEffect(Schema.Record(Schema.String, Schema.Unknown)),\n ),\n Effect.map((encoded) => ({\n reference: Ref.getFunctionReference(ref),\n args: encoded,\n })),\n Effect.orDie,\n );\n\n/**\n * Encode a callback's real field without fabricating the rest of its arguments.\n */\nexport const encodeField = <\n R extends Ref.AnyConfect,\n K extends keyof Ref.Args<R> & keyof Ref.ArgsFields<R>,\n>(\n ref: R,\n key: K,\n value: NoInfer<Ref.Args<R>[K]>,\n): Effect.Effect<unknown> => {\n const fields = ref.args.fields as Record<\n keyof Ref.ArgsFields<R>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AW,IAAI,qBAAqB,GAAG;CACvC,MAAM;AACR,EAAE,GACF,OAAO,KACT;;;;AAKF,MAAa,eAIX,KACA,KACA,UAC2B;CAC3B,MAAM,SAAS,IAAI,KAAK;CAIxB,OAAO,OAAO,oBAAoB,OAAO,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,OAAO,KAAK;AACzE"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaganref/confect-server",
|
|
3
|
-
"version": "10.3.1-fork.
|
|
3
|
+
"version": "10.3.1-fork.12",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@effect/ai-openai-compat": "4.0.4",
|
|
6
6
|
"@effect/ai-openrouter": "4.0.4"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.
|
|
9
|
+
"@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.12",
|
|
10
10
|
"@effect/platform-node": "^4.0.0",
|
|
11
11
|
"convex": "^1.45.0",
|
|
12
12
|
"effect": "^4.0.4"
|
package/src/OfficialComponent.ts
CHANGED
|
@@ -39,7 +39,7 @@ type Needs<Param> = [GenericActionCtx<GenericDataModel>] extends [Param]
|
|
|
39
39
|
type Method<Official> = {
|
|
40
40
|
[K in keyof Official & string]: Official[K] extends (
|
|
41
41
|
ctx: infer Ctx,
|
|
42
|
-
...args:
|
|
42
|
+
...args: infer _Args
|
|
43
43
|
) => Promise<unknown>
|
|
44
44
|
? Needs<Ctx> extends Unsupported
|
|
45
45
|
? never
|