@confect/server 1.0.0-next.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/Api.d.ts +5 -2
- package/dist/Api.d.ts.map +1 -1
- package/dist/Api.js.map +1 -1
- package/dist/Handler.d.ts +10 -7
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +63 -0
- package/dist/RegisteredConvexFunction.d.ts.map +1 -0
- package/dist/RegisteredConvexFunction.js +60 -0
- package/dist/RegisteredConvexFunction.js.map +1 -0
- package/dist/RegisteredFunction.d.ts +54 -0
- package/dist/RegisteredFunction.d.ts.map +1 -0
- package/dist/RegisteredFunction.js +28 -0
- package/dist/RegisteredFunction.js.map +1 -0
- package/dist/RegisteredFunctions.d.ts +7 -53
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js +4 -56
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +15 -0
- package/dist/RegisteredNodeFunction.d.ts.map +1 -0
- package/dist/RegisteredNodeFunction.js +25 -0
- package/dist/RegisteredNodeFunction.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/node.d.ts +2 -0
- package/dist/node.js +3 -0
- package/package.json +10 -6
- package/src/Api.ts +10 -0
- package/src/Handler.ts +31 -13
- package/src/RegisteredConvexFunction.ts +252 -0
- package/src/RegisteredFunction.ts +108 -0
- package/src/RegisteredFunctions.ts +13 -303
- package/src/RegisteredNodeFunction.ts +68 -0
- package/src/index.ts +2 -0
- package/src/node.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @confect/server
|
|
2
2
|
|
|
3
|
+
## 1.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 2ff70a7: Initial release.
|
|
8
|
+
|
|
9
|
+
## 1.0.0-next.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 46109fb: Support Node actions
|
|
14
|
+
- Updated dependencies [46109fb]
|
|
15
|
+
- @confect/core@1.0.0-next.4
|
|
16
|
+
|
|
3
17
|
## 1.0.0-next.3
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/Api.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AnyWithProps as AnyWithProps$1 } from "./DatabaseSchema.js";
|
|
2
2
|
import { GenericSchema, SchemaDefinition } from "convex/server";
|
|
3
|
+
import { RuntimeAndFunctionType } from "@confect/core";
|
|
3
4
|
import * as Spec from "@confect/core/Spec";
|
|
4
5
|
|
|
5
6
|
//#region src/Api.d.ts
|
|
6
7
|
declare namespace Api_d_exports {
|
|
7
|
-
export { Any, AnyWithProps, Api, Groups, Schema, TypeId, isApi, make };
|
|
8
|
+
export { Any, AnyWithProps, AnyWithPropsWithRuntime, Api, GetSpec, Groups, Schema, TypeId, isApi, make };
|
|
8
9
|
}
|
|
9
10
|
declare const TypeId = "@confect/server/Api";
|
|
10
11
|
type TypeId = typeof TypeId;
|
|
@@ -19,9 +20,11 @@ interface Any {
|
|
|
19
20
|
readonly [TypeId]: TypeId;
|
|
20
21
|
}
|
|
21
22
|
interface AnyWithProps extends Api<AnyWithProps$1, Spec.AnyWithProps> {}
|
|
23
|
+
interface AnyWithPropsWithRuntime<Runtime extends RuntimeAndFunctionType.Runtime> extends Api<AnyWithProps$1, Spec.AnyWithPropsWithRuntime<Runtime>> {}
|
|
22
24
|
type Schema<Api_ extends AnyWithProps> = Api_["databaseSchema"];
|
|
25
|
+
type GetSpec<Api_ extends AnyWithProps> = Api_["spec"];
|
|
23
26
|
type Groups<Api_ extends AnyWithProps> = Spec.Groups<Api_["spec"]>;
|
|
24
27
|
declare const make: <DatabaseSchema_ extends AnyWithProps$1, Spec_ extends Spec.AnyWithProps>(databaseSchema: DatabaseSchema_, spec: Spec_) => Api<DatabaseSchema_, Spec_>;
|
|
25
28
|
//#endregion
|
|
26
|
-
export { Any, AnyWithProps, Api, Api_d_exports, Groups, Schema, TypeId, isApi, make };
|
|
29
|
+
export { Any, AnyWithProps, AnyWithPropsWithRuntime, Api, Api_d_exports, GetSpec, Groups, Schema, TypeId, isApi, make };
|
|
27
30
|
//# sourceMappingURL=Api.d.ts.map
|
package/dist/Api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.d.ts","names":[],"sources":["../src/Api.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Api.d.ts","names":[],"sources":["../src/Api.ts"],"mappings":";;;;;;;;;cAOa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,KAAA,GAAS,CAAA,cAAa,CAAA,IAAK,GAAA;AAAA,UAEvB,GAAA,yBACS,cAAA,gBACV,IAAA,CAAK,YAAA;EAAA,UAET,MAAA,GAAS,MAAA;EAAA,SACV,IAAA,EAAM,KAAA;EAAA,SACN,cAAA,EAAgB,eAAA;EAAA,SAChB,sBAAA,EAAwB,gBAAA,CAAiB,aAAA;AAAA;AAAA,UAGnC,GAAA;EAAA,UACL,MAAA,GAAS,MAAA;AAAA;AAAA,UAGJ,YAAA,SAAqB,GAAA,CACpC,cAAA,EACA,IAAA,CAAK,YAAA;AAAA,UAGU,uBAAA,iBACC,sBAAA,CAAuB,OAAA,UAC/B,GAAA,CACR,cAAA,EACA,IAAA,CAAK,uBAAA,CAAwB,OAAA;AAAA,KAGnB,MAAA,cAAoB,YAAA,IAAgB,IAAA;AAAA,KAEpC,OAAA,cAAqB,YAAA,IAAgB,IAAA;AAAA,KAErC,MAAA,cAAoB,YAAA,IAAgB,IAAA,CAAK,MAAA,CAAO,IAAA;AAAA,cA0B/C,IAAA,2BACa,cAAA,gBACV,IAAA,CAAK,YAAA,EAEnB,cAAA,EAAgB,eAAA,EAChB,IAAA,EAAM,KAAA,KACL,GAAA,CAAI,eAAA,EAAiB,KAAA"}
|
package/dist/Api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.js","names":["defineConvexSchema"],"sources":["../src/Api.ts"],"sourcesContent":["import type * as Spec from \"@confect/core/Spec\";\nimport type { GenericSchema, SchemaDefinition } from \"convex/server\";\nimport { defineSchema as defineConvexSchema } from \"convex/server\";\nimport { pipe, Predicate, Record } from \"effect\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\n\nexport const TypeId = \"@confect/server/Api\";\nexport type TypeId = typeof TypeId;\n\nexport const isApi = (u: unknown): u is Any => Predicate.hasProperty(u, TypeId);\n\nexport interface Api<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n> {\n readonly [TypeId]: TypeId;\n readonly spec: Spec_;\n readonly databaseSchema: DatabaseSchema_;\n readonly convexSchemaDefinition: SchemaDefinition<GenericSchema, true>;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends Api<\n DatabaseSchema.AnyWithProps,\n Spec.AnyWithProps\n> {}\n\nexport type Schema<Api_ extends AnyWithProps> = Api_[\"databaseSchema\"];\n\nexport type Groups<Api_ extends AnyWithProps> = Spec.Groups<Api_[\"spec\"]>;\n\nconst Proto = {\n [TypeId]: TypeId,\n};\n\nconst makeProto = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n>({\n databaseSchema,\n spec,\n}: {\n databaseSchema: DatabaseSchema.AnyWithProps;\n spec: Spec_;\n}): Api<DatabaseSchema_, Spec_> =>\n Object.assign(Object.create(Proto), {\n databaseSchema,\n spec,\n convexSchemaDefinition: pipe(\n databaseSchema.tables,\n Record.map(({ tableDefinition }) => tableDefinition),\n defineConvexSchema,\n ),\n });\n\nexport const make = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n>(\n databaseSchema: DatabaseSchema_,\n spec: Spec_,\n): Api<DatabaseSchema_, Spec_> => makeProto({ databaseSchema, spec });\n"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Api.js","names":["defineConvexSchema"],"sources":["../src/Api.ts"],"sourcesContent":["import type { RuntimeAndFunctionType } from \"@confect/core\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport type { GenericSchema, SchemaDefinition } from \"convex/server\";\nimport { defineSchema as defineConvexSchema } from \"convex/server\";\nimport { pipe, Predicate, Record } from \"effect\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\n\nexport const TypeId = \"@confect/server/Api\";\nexport type TypeId = typeof TypeId;\n\nexport const isApi = (u: unknown): u is Any => Predicate.hasProperty(u, TypeId);\n\nexport interface Api<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n> {\n readonly [TypeId]: TypeId;\n readonly spec: Spec_;\n readonly databaseSchema: DatabaseSchema_;\n readonly convexSchemaDefinition: SchemaDefinition<GenericSchema, true>;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends Api<\n DatabaseSchema.AnyWithProps,\n Spec.AnyWithProps\n> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends Api<\n DatabaseSchema.AnyWithProps,\n Spec.AnyWithPropsWithRuntime<Runtime>\n> {}\n\nexport type Schema<Api_ extends AnyWithProps> = Api_[\"databaseSchema\"];\n\nexport type GetSpec<Api_ extends AnyWithProps> = Api_[\"spec\"];\n\nexport type Groups<Api_ extends AnyWithProps> = Spec.Groups<Api_[\"spec\"]>;\n\nconst Proto = {\n [TypeId]: TypeId,\n};\n\nconst makeProto = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n>({\n databaseSchema,\n spec,\n}: {\n databaseSchema: DatabaseSchema.AnyWithProps;\n spec: Spec_;\n}): Api<DatabaseSchema_, Spec_> =>\n Object.assign(Object.create(Proto), {\n databaseSchema,\n spec,\n convexSchemaDefinition: pipe(\n databaseSchema.tables,\n Record.map(({ tableDefinition }) => tableDefinition),\n defineConvexSchema,\n ),\n });\n\nexport const make = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n>(\n databaseSchema: DatabaseSchema_,\n spec: Spec_,\n): Api<DatabaseSchema_, Spec_> => makeProto({ databaseSchema, spec });\n"],"mappings":";;;;;;;;;;AAOA,MAAa,SAAS;AAGtB,MAAa,SAAS,MAAyB,UAAU,YAAY,GAAG,OAAO;AAkC/E,MAAM,QAAQ,GACX,SAAS,QACX;AAED,MAAM,aAGJ,EACA,gBACA,WAKA,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE;CAClC;CACA;CACA,wBAAwB,KACtB,eAAe,QACf,OAAO,KAAK,EAAE,sBAAsB,gBAAgB,EACpDA,aACD;CACF,CAAC;AAEJ,MAAa,QAIX,gBACA,SACgC,UAAU;CAAE;CAAgB;CAAM,CAAC"}
|
package/dist/Handler.d.ts
CHANGED
|
@@ -13,19 +13,22 @@ import { Scheduler } from "./Scheduler.js";
|
|
|
13
13
|
import { StorageActionWriter, StorageReader, StorageWriter } from "./Storage.js";
|
|
14
14
|
import { VectorSearch } from "./VectorSearch.js";
|
|
15
15
|
import { Effect } from "effect";
|
|
16
|
-
import {
|
|
16
|
+
import { NodeContext } from "@effect/platform-node";
|
|
17
|
+
import { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
17
18
|
|
|
18
19
|
//#region src/Handler.d.ts
|
|
19
20
|
declare namespace Handler_d_exports {
|
|
20
|
-
export {
|
|
21
|
+
export { AnyWithProps, ConvexAction, Handler, Mutation, NodeAction, Query, WithName };
|
|
21
22
|
}
|
|
22
|
-
type Handler<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "query"> ? Query<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "mutation"> ? Mutation<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.
|
|
23
|
-
type Query<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<
|
|
24
|
-
type Mutation<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<
|
|
25
|
-
type
|
|
23
|
+
type Handler<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "query"> ? Query<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "mutation"> ? Mutation<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<FunctionSpec_, RuntimeAndFunctionType.ConvexAction> ? ConvexAction<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<FunctionSpec_, RuntimeAndFunctionType.NodeAction> ? NodeAction<DatabaseSchema_, FunctionSpec_> : never;
|
|
24
|
+
type Query<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | Auth | StorageReader | QueryRunner | QueryCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
|
|
25
|
+
type Mutation<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | DatabaseWriter<DatabaseSchema_> | Auth | Scheduler | StorageReader | StorageWriter | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
|
|
26
|
+
type ActionServices<DatabaseSchema_ extends AnyWithProps$1> = Scheduler | Auth | StorageReader | StorageWriter | StorageActionWriter | QueryRunner | MutationRunner | ActionRunner | VectorSearch<FromSchema<DatabaseSchema_>> | ActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>;
|
|
27
|
+
type ConvexAction<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>> = Base<FunctionSpec_, ActionServices<DatabaseSchema_>>;
|
|
28
|
+
type NodeAction<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>> = Base<FunctionSpec_, ActionServices<DatabaseSchema_> | NodeContext.NodeContext>;
|
|
26
29
|
type Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (args: FunctionSpec.Args<FunctionSpec_>["Type"]) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>["Type"], never, R>;
|
|
27
30
|
type AnyWithProps = Handler<AnyWithProps$1, FunctionSpec.AnyWithProps>;
|
|
28
31
|
type WithName<DatabaseSchema_ extends AnyWithProps$1, FunctionSpec_ extends FunctionSpec.AnyWithProps, FunctionName extends string> = Handler<DatabaseSchema_, FunctionSpec.WithName<FunctionSpec_, FunctionName>>;
|
|
29
32
|
//#endregion
|
|
30
|
-
export {
|
|
33
|
+
export { AnyWithProps, ConvexAction, Handler, Handler_d_exports, Mutation, NodeAction, Query, WithName };
|
|
31
34
|
//# sourceMappingURL=Handler.d.ts.map
|
package/dist/Handler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.d.ts","names":[],"sources":["../src/Handler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Handler.d.ts","names":[],"sources":["../src/Handler.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;KAsBY,OAAA,yBACc,cAAA,wBACF,YAAA,CAAa,YAAA,IAEnC,aAAA,SAAsB,YAAA,CAAa,gBAAA,CAAiB,aAAA,aAChD,KAAA,CAAM,eAAA,EAAiB,aAAA,IACvB,aAAA,SAAsB,YAAA,CAAa,gBAAA,CAC/B,aAAA,gBAGF,QAAA,CAAS,eAAA,EAAiB,aAAA,IAC1B,aAAA,SAAsB,YAAA,CAAa,0BAAA,CAC/B,aAAA,EACA,sBAAA,CAAuB,YAAA,IAEzB,YAAA,CAAa,eAAA,EAAiB,aAAA,IAC9B,aAAA,SAAsB,YAAA,CAAa,0BAAA,CAC/B,aAAA,EACA,sBAAA,CAAuB,UAAA,IAEzB,UAAA,CAAW,eAAA,EAAiB,aAAA;AAAA,KAG5B,KAAA,yBACc,cAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,QAAA,KACjE,IAAA,CACF,aAAA,EACE,cAAA,CAA8B,eAAA,IAC9B,IAAA,GACA,aAAA,GACA,WAAA,GACA,QAAA,CAAkB,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAGlD,QAAA,yBACc,cAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,WAAA,KACjE,IAAA,CACF,aAAA,EACE,cAAA,CAA8B,eAAA,IAC9B,cAAA,CAA8B,eAAA,IAC9B,IAAA,GACA,SAAA,GACA,aAAA,GACA,aAAA,GACA,WAAA,GACA,cAAA,GACA,WAAA,CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAIzC,cAAA,yBAAuC,cAAA,IACxC,SAAA,GACA,IAAA,GACA,aAAA,GACA,aAAA,GACA,mBAAA,GACA,WAAA,GACA,cAAA,GACA,YAAA,GACA,YAAA,CAA0B,UAAA,CAAqB,eAAA,KAC/C,SAAA,CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAGlC,YAAA,yBACc,cAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,SAAA,KACjE,IAAA,CAAK,aAAA,EAAe,cAAA,CAAe,eAAA;AAAA,KAE3B,UAAA,yBACc,cAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,UAAA,KACjE,IAAA,CACF,aAAA,EACA,cAAA,CAAe,eAAA,IAAmB,WAAA,CAAY,WAAA;AAAA,KAG3C,IAAA,uBAA2B,YAAA,CAAa,YAAA,QAC3C,IAAA,EAAM,YAAA,CAAa,IAAA,CAAK,aAAA,cACrB,MAAA,CAAO,MAAA,CAAO,YAAA,CAAa,OAAA,CAAQ,aAAA,kBAA+B,CAAA;AAAA,KAE3D,YAAA,GAAe,OAAA,CACzB,cAAA,EACA,YAAA,CAAa,YAAA;AAAA,KAGH,QAAA,yBACc,cAAA,wBACF,YAAA,CAAa,YAAA,iCAEjC,OAAA,CACF,eAAA,EACA,YAAA,CAAa,QAAA,CAAS,aAAA,EAAe,YAAA"}
|
package/dist/Handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.js","names":[],"sources":["../src/Handler.ts"],"sourcesContent":["import type { FunctionSpec } from \"@confect/core\";\nimport type { Effect } from \"effect\";\nimport type * as ActionCtx from \"./ActionCtx\";\nimport type * as ActionRunner from \"./ActionRunner\";\nimport type * as Auth from \"./Auth\";\nimport type * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as MutationCtx from \"./MutationCtx\";\nimport type * as MutationRunner from \"./MutationRunner\";\nimport type * as QueryCtx from \"./QueryCtx\";\nimport type * as QueryRunner from \"./QueryRunner\";\nimport type * as Scheduler from \"./Scheduler\";\nimport type {\n StorageActionWriter,\n StorageReader,\n StorageWriter,\n} from \"./Storage\";\nimport type * as VectorSearch from \"./VectorSearch\";\n\nexport type Handler<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, \"query\">\n ? Query<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionType<\n FunctionSpec_,\n \"mutation\"\n >\n ? Mutation<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.
|
|
1
|
+
{"version":3,"file":"Handler.js","names":[],"sources":["../src/Handler.ts"],"sourcesContent":["import type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport type { NodeContext } from \"@effect/platform-node\";\nimport type { Effect } from \"effect\";\nimport type * as ActionCtx from \"./ActionCtx\";\nimport type * as ActionRunner from \"./ActionRunner\";\nimport type * as Auth from \"./Auth\";\nimport type * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as MutationCtx from \"./MutationCtx\";\nimport type * as MutationRunner from \"./MutationRunner\";\nimport type * as QueryCtx from \"./QueryCtx\";\nimport type * as QueryRunner from \"./QueryRunner\";\nimport type * as Scheduler from \"./Scheduler\";\nimport type {\n StorageActionWriter,\n StorageReader,\n StorageWriter,\n} from \"./Storage\";\nimport type * as VectorSearch from \"./VectorSearch\";\n\nexport type Handler<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, \"query\">\n ? Query<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionType<\n FunctionSpec_,\n \"mutation\"\n >\n ? Mutation<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<\n FunctionSpec_,\n RuntimeAndFunctionType.ConvexAction\n >\n ? ConvexAction<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<\n FunctionSpec_,\n RuntimeAndFunctionType.NodeAction\n >\n ? NodeAction<DatabaseSchema_, FunctionSpec_>\n : never;\n\nexport type Query<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>\n>;\n\nexport type Mutation<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | DatabaseWriter.DatabaseWriter<DatabaseSchema_>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n>;\n\ntype ActionServices<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | VectorSearch.VectorSearch<DataModel.FromSchema<DatabaseSchema_>>\n | ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >;\n\nexport type ConvexAction<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>,\n> = Base<FunctionSpec_, ActionServices<DatabaseSchema_>>;\n\nexport type NodeAction<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>,\n> = Base<\n FunctionSpec_,\n ActionServices<DatabaseSchema_> | NodeContext.NodeContext\n>;\n\ntype Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (\n args: FunctionSpec.Args<FunctionSpec_>[\"Type\"],\n) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>[\"Type\"], never, R>;\n\nexport type AnyWithProps = Handler<\n DatabaseSchema.AnyWithProps,\n FunctionSpec.AnyWithProps\n>;\n\nexport type WithName<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n FunctionName extends string,\n> = Handler<\n DatabaseSchema_,\n FunctionSpec.WithName<FunctionSpec_, FunctionName>\n>;\n"],"mappings":""}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Name, WithName } from "./Table.js";
|
|
2
|
+
import { AnyWithProps, IncludeSystemTables, Tables } from "./DatabaseSchema.js";
|
|
3
|
+
import { AnyWithPropsWithRuntime } from "./Api.js";
|
|
4
|
+
import { Auth as Auth$1 } from "./Auth.js";
|
|
5
|
+
import { DocumentDecodeError, DocumentEncodeError, WithoutSystemFields as WithoutSystemFields$1 } from "./Document.js";
|
|
6
|
+
import { TableInfo } from "./TableInfo.js";
|
|
7
|
+
import { DataModel, DocumentByName, FromSchema, TableInfoWithName, TableNames, ToConvex } from "./DataModel.js";
|
|
8
|
+
import { OrderedQuery as OrderedQuery$1 } from "./OrderedQuery.js";
|
|
9
|
+
import { GetByIdFailure, GetByIndexFailure } from "./QueryInitializer.js";
|
|
10
|
+
import { DatabaseReader } from "./DatabaseReader.js";
|
|
11
|
+
import { DatabaseWriter } from "./DatabaseWriter.js";
|
|
12
|
+
import { MutationCtx } from "./MutationCtx.js";
|
|
13
|
+
import { MutationRunner } from "./MutationRunner.js";
|
|
14
|
+
import { QueryRunner } from "./QueryRunner.js";
|
|
15
|
+
import { Scheduler as Scheduler$1 } from "./Scheduler.js";
|
|
16
|
+
import { StorageReader as StorageReader$1, StorageWriter as StorageWriter$1 } from "./Storage.js";
|
|
17
|
+
import { RegisteredFunction } from "./RegisteredFunction.js";
|
|
18
|
+
import { AnyWithProps as AnyWithProps$1 } from "./RegistryItem.js";
|
|
19
|
+
import { Effect, Layer } from "effect";
|
|
20
|
+
import * as _confect_core_Ref0 from "@confect/core/Ref";
|
|
21
|
+
import * as convex_server0 from "convex/server";
|
|
22
|
+
import { GenericMutationCtx } from "convex/server";
|
|
23
|
+
import * as convex_values0 from "convex/values";
|
|
24
|
+
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
25
|
+
import * as _confect_core_Types0 from "@confect/core/Types";
|
|
26
|
+
import * as effect_Duration0 from "effect/Duration";
|
|
27
|
+
import * as effect_DateTime0 from "effect/DateTime";
|
|
28
|
+
|
|
29
|
+
//#region src/RegisteredConvexFunction.d.ts
|
|
30
|
+
declare namespace RegisteredConvexFunction_d_exports {
|
|
31
|
+
export { MutationServices, make, mutationLayer };
|
|
32
|
+
}
|
|
33
|
+
declare const make: <Api_ extends AnyWithPropsWithRuntime<"Convex">>(api: Api_, {
|
|
34
|
+
function_,
|
|
35
|
+
handler
|
|
36
|
+
}: AnyWithProps$1) => RegisteredFunction;
|
|
37
|
+
declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<(<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>["Type"]) => Effect.Effect<_confect_core_Ref0.Returns<Query>["Type"], effect_ParseResult0.ParseError>) | GenericMutationCtx<ToConvex<FromSchema<Schema>>> | {
|
|
38
|
+
table: <const TableName extends Name<IncludeSystemTables<Tables<Schema>>>>(tableName: TableName) => {
|
|
39
|
+
readonly get: {
|
|
40
|
+
(id: convex_values0.GenericId<TableName>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
|
|
41
|
+
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<Schema>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"][IndexName]>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
42
|
+
};
|
|
43
|
+
readonly index: {
|
|
44
|
+
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"]>(indexName: IndexName, indexRange?: ((q: convex_server0.IndexRangeBuilder<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["convexDocument"], convex_server0.NamedIndex<TableInfoWithName<DataModel<IncludeSystemTables<Tables<Schema>>>, TableName>, IndexName>, 0>) => convex_server0.IndexRange) | undefined, order?: "asc" | "desc"): OrderedQuery$1<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>, TableName>;
|
|
45
|
+
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"]>(indexName: IndexName, order?: "asc" | "desc"): OrderedQuery$1<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>, TableName>;
|
|
46
|
+
};
|
|
47
|
+
readonly search: <IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["searchIndexes"]>(indexName: IndexName, searchFilter: (q: convex_server0.SearchFilterBuilder<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["convexDocument"], convex_server0.NamedSearchIndex<TableInfoWithName<DataModel<IncludeSystemTables<Tables<Schema>>>, TableName>, IndexName>>) => convex_server0.SearchFilter) => OrderedQuery$1<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>, TableName>;
|
|
48
|
+
};
|
|
49
|
+
} | {
|
|
50
|
+
table: <const TableName extends TableNames<FromSchema<Schema>>>(tableName: TableName) => {
|
|
51
|
+
insert: (document: WithoutSystemFields$1<DocumentByName<FromSchema<Schema>, TableName>>) => Effect.Effect<convex_values0.GenericId<TableName>, DocumentEncodeError, never>;
|
|
52
|
+
patch: (id: convex_values0.GenericId<TableName>, patchedValues: Partial<convex_server0.Expand<convex_server0.BetterOmit<DocumentByName<FromSchema<Schema>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentDecodeError | GetByIdFailure | DocumentEncodeError, never>;
|
|
53
|
+
replace: (id: convex_values0.GenericId<TableName>, value: convex_server0.Expand<convex_server0.BetterOmit<DocumentByName<FromSchema<Schema>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
54
|
+
delete: (id: convex_values0.GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
55
|
+
};
|
|
56
|
+
} | Auth$1 | {
|
|
57
|
+
runAfter: <FuncRef extends convex_server0.SchedulableFunctionReference>(delay: effect_Duration0.Duration, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
58
|
+
runAt: <FuncRef extends convex_server0.SchedulableFunctionReference>(dateTime: effect_DateTime0.DateTime, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
59
|
+
} | StorageReader$1 | StorageWriter$1 | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>["Type"]) => Effect.Effect<any, effect_ParseResult0.ParseError, never>), never, never>;
|
|
60
|
+
type MutationServices<Schema extends AnyWithProps> = DatabaseReader<Schema> | DatabaseWriter<Schema> | Auth$1 | Scheduler$1 | StorageReader$1 | StorageWriter$1 | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<Schema>>>;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { MutationServices, RegisteredConvexFunction_d_exports, make, mutationLayer };
|
|
63
|
+
//# sourceMappingURL=RegisteredConvexFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisteredConvexFunction.d.ts","names":[],"sources":["../src/RegisteredConvexFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4Ba,IAAA,gBAAqB,uBAAA,YAChC,GAAA,EAAK,IAAA;EACL,SAAA;EAAA;AAAA,GAAwB,cAAA,KACvB,kBAAA;AAAA,cAuHU,aAAA,kBAAgC,YAAA,EAC3C,MAAA,EAAQ,MAAA,EACR,GAAA,EAAK,kBAAA,CAAmB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAAS,KAAA,CAAA,KAAA,iBAAlD,kBAAA,CAAkD,QAAA,EAAA,KAAA,EAAA,KAAA,EAAA,IAAA,EAAA,kBAAA,CAAA,IAAA,CAAA,KAAA,cAAA,MAAA,CAAA,MAAA,CAAA,kBAAA,CAAA,OAAA,CAAA,KAAA,WAAA,mBAAA,CAAA,UAAA,KAAA,kBAAA,CAAA,QAAA,CAAA,UAAA,CAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;KAmB/D,gBAAA,gBAAgC,YAAA,IACxC,cAAA,CAA8B,MAAA,IAC9B,cAAA,CAA8B,MAAA,IAC9B,MAAA,GACA,WAAA,GACA,eAAA,GACA,eAAA,GACA,WAAA,GACA,cAAA,GACA,WAAA,CAAwB,QAAA,CAAmB,UAAA,CAAqB,MAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { layer } from "./Auth.js";
|
|
3
|
+
import { compileArgsSchema, compileReturnsSchema } from "./SchemaToValidator.js";
|
|
4
|
+
import { layer as layer$1 } from "./DatabaseReader.js";
|
|
5
|
+
import { layer as layer$2 } from "./DatabaseWriter.js";
|
|
6
|
+
import { layer as layer$3 } from "./MutationRunner.js";
|
|
7
|
+
import { layer as layer$4 } from "./QueryRunner.js";
|
|
8
|
+
import { layer as layer$5 } from "./Scheduler.js";
|
|
9
|
+
import { StorageReader as StorageReader$1, StorageWriter as StorageWriter$1 } from "./Storage.js";
|
|
10
|
+
import { MutationCtx } from "./MutationCtx.js";
|
|
11
|
+
import { QueryCtx } from "./QueryCtx.js";
|
|
12
|
+
import { actionFunctionBase, actionLayer } from "./RegisteredFunction.js";
|
|
13
|
+
import { Effect, Layer, Match, Schema, pipe } from "effect";
|
|
14
|
+
import { actionGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, mutationGeneric, queryGeneric } from "convex/server";
|
|
15
|
+
|
|
16
|
+
//#region src/RegisteredConvexFunction.ts
|
|
17
|
+
var RegisteredConvexFunction_exports = /* @__PURE__ */ __exportAll({
|
|
18
|
+
make: () => make,
|
|
19
|
+
mutationLayer: () => mutationLayer
|
|
20
|
+
});
|
|
21
|
+
const make = (api, { function_, handler }) => Match.value(function_.runtimeAndFunctionType.functionType).pipe(Match.when("query", () => {
|
|
22
|
+
return Match.value(function_.functionVisibility).pipe(Match.when("public", () => queryGeneric), Match.when("internal", () => internalQueryGeneric), Match.exhaustive)(queryFunction(api.databaseSchema, {
|
|
23
|
+
args: function_.args,
|
|
24
|
+
returns: function_.returns,
|
|
25
|
+
handler
|
|
26
|
+
}));
|
|
27
|
+
}), Match.when("mutation", () => {
|
|
28
|
+
return Match.value(function_.functionVisibility).pipe(Match.when("public", () => mutationGeneric), Match.when("internal", () => internalMutationGeneric), Match.exhaustive)(mutationFunction(api.databaseSchema, {
|
|
29
|
+
args: function_.args,
|
|
30
|
+
returns: function_.returns,
|
|
31
|
+
handler
|
|
32
|
+
}));
|
|
33
|
+
}), Match.when("action", () => {
|
|
34
|
+
return Match.value(function_.functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(convexActionFunction(api.databaseSchema, {
|
|
35
|
+
args: function_.args,
|
|
36
|
+
returns: function_.returns,
|
|
37
|
+
handler
|
|
38
|
+
}));
|
|
39
|
+
}), Match.exhaustive);
|
|
40
|
+
const queryFunction = (databaseSchema, { args, returns, handler }) => ({
|
|
41
|
+
args: compileArgsSchema(args),
|
|
42
|
+
returns: compileReturnsSchema(returns),
|
|
43
|
+
handler: (ctx, actualArgs) => pipe(actualArgs, Schema.decode(args), Effect.orDie, Effect.andThen((decodedArgs) => pipe(handler(decodedArgs), Effect.provide(Layer.mergeAll(layer$1(databaseSchema, ctx.db), layer(ctx.auth), StorageReader$1.layer(ctx.storage), layer$4(ctx.runQuery), Layer.succeed(QueryCtx(), ctx))))), Effect.andThen((convexReturns) => Schema.encodeUnknown(returns)(convexReturns)), Effect.runPromise)
|
|
44
|
+
});
|
|
45
|
+
const mutationLayer = (schema, ctx) => Layer.mergeAll(layer$1(schema, ctx.db), layer$2(schema, ctx.db), layer(ctx.auth), layer$5(ctx.scheduler), StorageReader$1.layer(ctx.storage), StorageWriter$1.layer(ctx.storage), layer$4(ctx.runQuery), layer$3(ctx.runMutation), Layer.succeed(MutationCtx(), ctx));
|
|
46
|
+
const mutationFunction = (schema, { args, returns, handler }) => ({
|
|
47
|
+
args: compileArgsSchema(args),
|
|
48
|
+
returns: compileReturnsSchema(returns),
|
|
49
|
+
handler: (ctx, actualArgs) => pipe(actualArgs, Schema.decode(args), Effect.orDie, Effect.andThen((decodedArgs) => handler(decodedArgs).pipe(Effect.provide(mutationLayer(schema, ctx)))), Effect.andThen((convexReturns) => Schema.encodeUnknown(returns)(convexReturns)), Effect.runPromise)
|
|
50
|
+
});
|
|
51
|
+
const convexActionFunction = (schema, { args, returns, handler }) => actionFunctionBase({
|
|
52
|
+
args,
|
|
53
|
+
returns,
|
|
54
|
+
handler,
|
|
55
|
+
createLayer: (ctx) => actionLayer(schema, ctx)
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { RegisteredConvexFunction_exports, make, mutationLayer };
|
|
60
|
+
//# sourceMappingURL=RegisteredConvexFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisteredConvexFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","StorageReader","QueryRunner.layer","QueryCtx.QueryCtx","DatabaseWriter.layer","Scheduler.layer","StorageWriter","MutationRunner.layer","MutationCtx.MutationCtx","RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredConvexFunction.ts"],"sourcesContent":["import {\n actionGeneric,\n type DefaultFunctionArgs,\n type GenericMutationCtx,\n type GenericQueryCtx,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n mutationGeneric,\n queryGeneric,\n} from \"convex/server\";\nimport { Effect, Layer, Match, pipe, Schema } from \"effect\";\nimport type * as Api from \"./Api\";\nimport * as Auth from \"./Auth\";\nimport * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport * as MutationCtx from \"./MutationCtx\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryCtx from \"./QueryCtx\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as RegistryItem from \"./RegistryItem\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport { StorageReader, StorageWriter } from \"./Storage\";\n\nexport const make = <Api_ extends Api.AnyWithPropsWithRuntime<\"Convex\">>(\n api: Api_,\n { function_, handler }: RegistryItem.AnyWithProps,\n): RegisteredFunction.RegisteredFunction =>\n Match.value(function_.runtimeAndFunctionType.functionType).pipe(\n Match.when(\"query\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => queryGeneric),\n Match.when(\"internal\", () => internalQueryGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n queryFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.when(\"mutation\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => mutationGeneric),\n Match.when(\"internal\", () => internalMutationGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n mutationFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.when(\"action\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => actionGeneric),\n Match.when(\"internal\", () => internalActionGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n convexActionFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.exhaustive,\n );\n\nconst queryFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n databaseSchema: DatabaseSchema_,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n >;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericQueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n pipe(\n handler(decodedArgs),\n Effect.provide(\n Layer.mergeAll(\n DatabaseReader.layer(databaseSchema, ctx.db),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n Layer.succeed(\n QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >(),\n ctx,\n ),\n ),\n ),\n ),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nexport const mutationLayer = <Schema extends DatabaseSchema.AnyWithProps>(\n schema: Schema,\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n) =>\n Layer.mergeAll(\n DatabaseReader.layer(schema, ctx.db),\n DatabaseWriter.layer(schema, ctx.db),\n Auth.layer(ctx.auth),\n Scheduler.layer(ctx.scheduler),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n Layer.succeed(\n MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n );\n\nexport type MutationServices<Schema extends DatabaseSchema.AnyWithProps> =\n | DatabaseReader.DatabaseReader<Schema>\n | DatabaseWriter.DatabaseWriter<Schema>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>;\n\nconst mutationFunction = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: Schema,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (a: Args) => Effect.Effect<Returns, E, MutationServices<Schema>>;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n handler(decodedArgs).pipe(Effect.provide(mutationLayer(schema, ctx))),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nconst convexActionFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: DatabaseSchema_,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n RegisteredFunction.ActionServices<DatabaseSchema_>\n >;\n },\n) =>\n RegisteredFunction.actionFunctionBase({\n args,\n returns,\n handler,\n createLayer: (ctx) => RegisteredFunction.actionLayer(schema, ctx),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,QACX,KACA,EAAE,WAAW,cAEb,MAAM,MAAM,UAAU,uBAAuB,aAAa,CAAC,KACzD,MAAM,KAAK,eAAe;AAOxB,QANwB,MAAM,MAAM,UAAU,mBAAmB,CAAC,KAChE,MAAM,KAAK,gBAAgB,aAAa,EACxC,MAAM,KAAK,kBAAkB,qBAAqB,EAClD,MAAM,WACP,CAGC,cAAc,IAAI,gBAAgB;EAChC,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB;EACD,CAAC,CACH;EACD,EACF,MAAM,KAAK,kBAAkB;AAO3B,QANwB,MAAM,MAAM,UAAU,mBAAmB,CAAC,KAChE,MAAM,KAAK,gBAAgB,gBAAgB,EAC3C,MAAM,KAAK,kBAAkB,wBAAwB,EACrD,MAAM,WACP,CAGC,iBAAiB,IAAI,gBAAgB;EACnC,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB;EACD,CAAC,CACH;EACD,EACF,MAAM,KAAK,gBAAgB;AAOzB,QANwB,MAAM,MAAM,UAAU,mBAAmB,CAAC,KAChE,MAAM,KAAK,gBAAgB,cAAc,EACzC,MAAM,KAAK,kBAAkB,sBAAsB,EACnD,MAAM,WACP,CAGC,qBAAqB,IAAI,gBAAgB;EACvC,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB;EACD,CAAC,CACH;EACD,EACF,MAAM,WACP;AAEH,MAAM,iBAQJ,gBACA,EACE,MACA,SACA,eAkBE;CACJ,MAAMA,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KAGA,eAEA,KACE,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,OACP,OAAO,SAAS,gBACd,KACE,QAAQ,YAAY,EACpB,OAAO,QACL,MAAM,SACJC,QAAqB,gBAAgB,IAAI,GAAG,EAC5CC,MAAW,IAAI,KAAK,EACpBC,gBAAc,MAAM,IAAI,QAAQ,EAChCC,QAAkB,IAAI,SAAS,EAC/B,MAAM,QACJC,UAEG,EACH,IACD,CACF,CACF,CACF,CACF,EACD,OAAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ;AAED,MAAa,iBACX,QACA,QAEA,MAAM,SACJJ,QAAqB,QAAQ,IAAI,GAAG,EACpCK,QAAqB,QAAQ,IAAI,GAAG,EACpCJ,MAAW,IAAI,KAAK,EACpBK,QAAgB,IAAI,UAAU,EAC9BJ,gBAAc,MAAM,IAAI,QAAQ,EAChCK,gBAAc,MAAM,IAAI,QAAQ,EAChCJ,QAAkB,IAAI,SAAS,EAC/BK,QAAqB,IAAI,YAAY,EACrC,MAAM,QACJC,aAEG,EACH,IACD,CACF;AAaH,MAAM,oBAQJ,QACA,EACE,MACA,SACA,eAME;CACJ,MAAMX,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KACA,eAEA,KACE,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,OACP,OAAO,SAAS,gBACd,QAAQ,YAAY,CAAC,KAAK,OAAO,QAAQ,cAAc,QAAQ,IAAI,CAAC,CAAC,CACtE,EACD,OAAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ;AAED,MAAM,wBAQJ,QACA,EACE,MACA,SACA,cAaFW,mBAAsC;CACpC;CACA;CACA;CACA,cAAc,QAAQC,YAA+B,QAAQ,IAAI;CAClE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { ActionCtx } from "./ActionCtx.js";
|
|
2
|
+
import { ActionRunner } from "./ActionRunner.js";
|
|
3
|
+
import { AnyWithProps } from "./DatabaseSchema.js";
|
|
4
|
+
import { Auth as Auth$1 } from "./Auth.js";
|
|
5
|
+
import { FromSchema, TableNames, ToConvex } from "./DataModel.js";
|
|
6
|
+
import { MutationRunner } from "./MutationRunner.js";
|
|
7
|
+
import { QueryRunner } from "./QueryRunner.js";
|
|
8
|
+
import { Scheduler as Scheduler$1 } from "./Scheduler.js";
|
|
9
|
+
import { StorageActionWriter as StorageActionWriter$1, StorageReader as StorageReader$1, StorageWriter as StorageWriter$1 } from "./Storage.js";
|
|
10
|
+
import { VectorSearch } from "./VectorSearch.js";
|
|
11
|
+
import { Effect, Layer, Schema } from "effect";
|
|
12
|
+
import * as _confect_core_Ref0 from "@confect/core/Ref";
|
|
13
|
+
import * as convex_server0 from "convex/server";
|
|
14
|
+
import { DefaultFunctionArgs, FunctionVisibility, GenericActionCtx, RegisteredAction, RegisteredMutation, RegisteredQuery } from "convex/server";
|
|
15
|
+
import * as convex_values0 from "convex/values";
|
|
16
|
+
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
17
|
+
import * as effect_Duration0 from "effect/Duration";
|
|
18
|
+
import * as effect_DateTime0 from "effect/DateTime";
|
|
19
|
+
|
|
20
|
+
//#region src/RegisteredFunction.d.ts
|
|
21
|
+
declare namespace RegisteredFunction_d_exports {
|
|
22
|
+
export { ActionServices, RegisteredFunction, actionFunctionBase, actionLayer };
|
|
23
|
+
}
|
|
24
|
+
type RegisteredFunction = RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;
|
|
25
|
+
declare const actionFunctionBase: <Schema extends AnyWithProps, Args, ConvexArgs extends DefaultFunctionArgs, Returns, ConvexReturns, E, R>({
|
|
26
|
+
args,
|
|
27
|
+
returns,
|
|
28
|
+
handler,
|
|
29
|
+
createLayer
|
|
30
|
+
}: {
|
|
31
|
+
args: Schema.Schema<Args, ConvexArgs>;
|
|
32
|
+
returns: Schema.Schema<Returns, ConvexReturns>;
|
|
33
|
+
handler: (a: Args) => Effect.Effect<Returns, E, R>;
|
|
34
|
+
createLayer: (ctx: GenericActionCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<R>;
|
|
35
|
+
}) => {
|
|
36
|
+
args: convex_values0.PropertyValidators;
|
|
37
|
+
returns: convex_values0.Validator<any, any, any>;
|
|
38
|
+
handler: (ctx: GenericActionCtx<ToConvex<FromSchema<Schema>>>, actualArgs: ConvexArgs) => Promise<ConvexReturns>;
|
|
39
|
+
};
|
|
40
|
+
type ActionServices<DatabaseSchema_ extends AnyWithProps> = Scheduler$1 | Auth$1 | StorageReader$1 | StorageWriter$1 | StorageActionWriter$1 | QueryRunner | MutationRunner | ActionRunner | VectorSearch<FromSchema<DatabaseSchema_>> | ActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>;
|
|
41
|
+
declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<(<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>["Type"]) => Effect.Effect<_confect_core_Ref0.Returns<Query>["Type"], effect_ParseResult0.ParseError>) | (<Action extends _confect_core_Ref0.AnyAction>(action: Action, args: _confect_core_Ref0.Args<Action>["Type"]) => Effect.Effect<any, effect_ParseResult0.ParseError, never>) | Auth$1 | {
|
|
42
|
+
runAfter: <FuncRef extends convex_server0.SchedulableFunctionReference>(delay: effect_Duration0.Duration, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
43
|
+
runAt: <FuncRef extends convex_server0.SchedulableFunctionReference>(dateTime: effect_DateTime0.DateTime, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
44
|
+
} | StorageReader$1 | StorageWriter$1 | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>["Type"]) => Effect.Effect<any, effect_ParseResult0.ParseError, never>) | GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>> | StorageActionWriter$1 | (<TableName extends TableNames<FromSchema<DatabaseSchema_>>, IndexName extends keyof convex_server0.VectorIndexes<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>>(tableName: TableName, indexName: IndexName, query: {
|
|
45
|
+
vector: number[];
|
|
46
|
+
limit?: number;
|
|
47
|
+
filter?: (q: convex_server0.VectorFilterBuilder<convex_server0.DocumentByInfo<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>, convex_server0.NamedVectorIndex<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>, IndexName>>) => convex_server0.FilterExpression<boolean>;
|
|
48
|
+
}) => Effect.Effect<{
|
|
49
|
+
_id: convex_values0.GenericId<TableName>;
|
|
50
|
+
_score: number;
|
|
51
|
+
}[], never, never>), never, never>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { ActionServices, RegisteredFunction, RegisteredFunction_d_exports, actionFunctionBase, actionLayer };
|
|
54
|
+
//# sourceMappingURL=RegisteredFunction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisteredFunction.d.ts","names":[],"sources":["../src/RegisteredFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;KAqBY,kBAAA,GACR,eAAA,CAAgB,kBAAA,EAAoB,mBAAA,SACpC,kBAAA,CAAmB,kBAAA,EAAoB,mBAAA,SACvC,gBAAA,CAAiB,kBAAA,EAAoB,mBAAA;AAAA,cAE5B,kBAAA,kBACI,YAAA,2BAEI,mBAAA;EAKnB,IAAA;EAAA,OAAA;EAAA,OAAA;EAAA;AAAA;EAMA,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,IAAA,EAAM,UAAA;EAC1B,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,OAAA,EAAS,aAAA;EAChC,OAAA,GAAU,CAAA,EAAG,IAAA,KAAS,MAAA,CAAO,MAAA,CAAO,OAAA,EAAS,CAAA,EAAG,CAAA;EAChD,WAAA,GACE,GAAA,EAAK,gBAAA,CAAiB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAC3D,KAAA,CAAM,KAAA,CAAM,CAAA;AAAA;QAAD,cAAA,CAAA,kBAAA;;iBAKT,gBAAA,CAAiB,QAAA,CAAmB,UAAA,CAAqB,MAAA,KAAS,UAAA,EAC3D,UAAA,KACX,OAAA,CAAQ,aAAA;AAAA;AAAA,KAeD,cAAA,yBACc,YAAA,IAEtB,WAAA,GACA,MAAA,GACA,eAAA,GACA,eAAA,GACA,qBAAA,GACA,WAAA,GACA,cAAA,GACA,YAAA,GACA,YAAA,CAA0B,UAAA,CAAqB,eAAA,KAC/C,SAAA,CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,cAGjC,WAAA,2BACa,YAAA,EAExB,cAAA,EAAgB,eAAA,EAChB,GAAA,EAAK,gBAAA,CACH,QAAA,CAAmB,UAAA,CAAqB,eAAA,QACzC,KAAA,CAAA,KAAA,iBAFoB,kBAAA,CAEpB,QAAA,EAAA,KAAA,EAAA,KAAA,EAAA,IAAA,EAAA,kBAAA,CAAA,IAAA,CAAA,KAAA,cAAA,MAAA,CAAA,MAAA,CAAA,kBAAA,CAAA,OAAA,CAAA,KAAA,WAAA,mBAAA,CAAA,UAAA,sBAAA,kBAAA,CAAA,SAAA,EAAA,MAAA,EAAA,MAAA,EAAA,IAAA,EAAA,kBAAA,CAAA,IAAA,CAAA,MAAA,cAAA,MAAA,CAAA,MAAA,MAAA,mBAAA,CAAA,UAAA,YAAA,MAAA;6BAAA,cAAA,CAAA,4BAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { ActionCtx } from "./ActionCtx.js";
|
|
3
|
+
import { layer } from "./ActionRunner.js";
|
|
4
|
+
import { layer as layer$1 } from "./Auth.js";
|
|
5
|
+
import { compileArgsSchema, compileReturnsSchema } from "./SchemaToValidator.js";
|
|
6
|
+
import { layer as layer$2 } from "./MutationRunner.js";
|
|
7
|
+
import { layer as layer$3 } from "./QueryRunner.js";
|
|
8
|
+
import { layer as layer$4 } from "./Scheduler.js";
|
|
9
|
+
import { StorageActionWriter as StorageActionWriter$1, StorageReader as StorageReader$1, StorageWriter as StorageWriter$1 } from "./Storage.js";
|
|
10
|
+
import { layer as layer$5 } from "./VectorSearch.js";
|
|
11
|
+
import { Effect, Layer, Schema, pipe } from "effect";
|
|
12
|
+
import "convex/server";
|
|
13
|
+
|
|
14
|
+
//#region src/RegisteredFunction.ts
|
|
15
|
+
var RegisteredFunction_exports = /* @__PURE__ */ __exportAll({
|
|
16
|
+
actionFunctionBase: () => actionFunctionBase,
|
|
17
|
+
actionLayer: () => actionLayer
|
|
18
|
+
});
|
|
19
|
+
const actionFunctionBase = ({ args, returns, handler, createLayer }) => ({
|
|
20
|
+
args: compileArgsSchema(args),
|
|
21
|
+
returns: compileReturnsSchema(returns),
|
|
22
|
+
handler: (ctx, actualArgs) => pipe(actualArgs, Schema.decode(args), Effect.orDie, Effect.andThen((decodedArgs) => handler(decodedArgs).pipe(Effect.provide(createLayer(ctx)))), Effect.andThen((convexReturns) => Schema.encodeUnknown(returns)(convexReturns)), Effect.runPromise)
|
|
23
|
+
});
|
|
24
|
+
const actionLayer = (databaseSchema, ctx) => Layer.mergeAll(layer$4(ctx.scheduler), layer$1(ctx.auth), StorageReader$1.layer(ctx.storage), StorageWriter$1.layer(ctx.storage), StorageActionWriter$1.layer(ctx.storage), layer$3(ctx.runQuery), layer$2(ctx.runMutation), layer(ctx.runAction), layer$5(ctx.vectorSearch), Layer.succeed(ActionCtx(), ctx));
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { RegisteredFunction_exports, actionFunctionBase, actionLayer };
|
|
28
|
+
//# sourceMappingURL=RegisteredFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegisteredFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","Scheduler.layer","Auth.layer","StorageReader","StorageWriter","StorageActionWriter","QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","VectorSearch.layer","ActionCtx.ActionCtx"],"sources":["../src/RegisteredFunction.ts"],"sourcesContent":["import {\n type DefaultFunctionArgs,\n type FunctionVisibility,\n type GenericActionCtx,\n type RegisteredAction,\n type RegisteredMutation,\n type RegisteredQuery,\n} from \"convex/server\";\nimport { Effect, Layer, pipe, Schema } from \"effect\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DataModel from \"./DataModel\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport { StorageActionWriter, StorageReader, StorageWriter } from \"./Storage\";\nimport * as VectorSearch from \"./VectorSearch\";\n\nexport type RegisteredFunction =\n | RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;\n\nexport const actionFunctionBase = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n R,\n>({\n args,\n returns,\n handler,\n createLayer,\n}: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (a: Args) => Effect.Effect<Returns, E, R>;\n createLayer: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n ) => Layer.Layer<R>;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n handler(decodedArgs).pipe(Effect.provide(createLayer(ctx))),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nexport type ActionServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> =\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | VectorSearch.VectorSearch<DataModel.FromSchema<DatabaseSchema_>>\n | ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >;\n\nexport const actionLayer = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n>(\n databaseSchema: DatabaseSchema_,\n ctx: GenericActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n) =>\n Layer.mergeAll(\n Scheduler.layer(ctx.scheduler),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n StorageActionWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n ActionRunner.layer(ctx.runAction),\n VectorSearch.layer(ctx.vectorSearch),\n Layer.succeed(\n ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >(),\n ctx,\n ),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,MAAa,sBAQX,EACA,MACA,SACA,SACA,mBAQK;CACL,MAAMA,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KACA,eAEA,KACE,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,OACP,OAAO,SAAS,gBACd,QAAQ,YAAY,CAAC,KAAK,OAAO,QAAQ,YAAY,IAAI,CAAC,CAAC,CAC5D,EACD,OAAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ;AAkBD,MAAa,eAGX,gBACA,QAIA,MAAM,SACJC,QAAgB,IAAI,UAAU,EAC9BC,QAAW,IAAI,KAAK,EACpBC,gBAAc,MAAM,IAAI,QAAQ,EAChCC,gBAAc,MAAM,IAAI,QAAQ,EAChCC,sBAAoB,MAAM,IAAI,QAAQ,EACtCC,QAAkB,IAAI,SAAS,EAC/BC,QAAqB,IAAI,YAAY,EACrCC,MAAmB,IAAI,UAAU,EACjCC,QAAmB,IAAI,aAAa,EACpC,MAAM,QACJC,WAEG,EACH,IACD,CACF"}
|
|
@@ -1,68 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AnyWithProps as AnyWithProps$1, IncludeSystemTables, Tables } from "./DatabaseSchema.js";
|
|
3
|
-
import { AnyWithProps as AnyWithProps$2 } from "./Api.js";
|
|
4
|
-
import { Auth as Auth$1 } from "./Auth.js";
|
|
5
|
-
import { DocumentDecodeError, DocumentEncodeError, WithoutSystemFields as WithoutSystemFields$1 } from "./Document.js";
|
|
6
|
-
import { TableInfo } from "./TableInfo.js";
|
|
7
|
-
import { DataModel, DocumentByName, FromSchema, TableInfoWithName, TableNames, ToConvex } from "./DataModel.js";
|
|
8
|
-
import { OrderedQuery as OrderedQuery$1 } from "./OrderedQuery.js";
|
|
9
|
-
import { GetByIdFailure, GetByIndexFailure } from "./QueryInitializer.js";
|
|
10
|
-
import { DatabaseReader } from "./DatabaseReader.js";
|
|
11
|
-
import { DatabaseWriter } from "./DatabaseWriter.js";
|
|
12
|
-
import { MutationCtx } from "./MutationCtx.js";
|
|
13
|
-
import { MutationRunner } from "./MutationRunner.js";
|
|
14
|
-
import { QueryRunner } from "./QueryRunner.js";
|
|
15
|
-
import { Scheduler as Scheduler$1 } from "./Scheduler.js";
|
|
16
|
-
import { StorageReader as StorageReader$1, StorageWriter as StorageWriter$1 } from "./Storage.js";
|
|
1
|
+
import { AnyWithProps as AnyWithProps$1 } from "./Api.js";
|
|
17
2
|
import { Impl } from "./Impl.js";
|
|
18
|
-
import {
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { DefaultFunctionArgs, FunctionVisibility, GenericMutationCtx, RegisteredAction, RegisteredMutation, RegisteredQuery } from "convex/server";
|
|
22
|
-
import * as convex_values0 from "convex/values";
|
|
23
|
-
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
3
|
+
import { RegisteredFunction } from "./RegisteredFunction.js";
|
|
4
|
+
import { AnyWithProps as AnyWithProps$2 } from "./RegistryItem.js";
|
|
5
|
+
import { Layer, Types } from "effect";
|
|
24
6
|
import * as Spec from "@confect/core/Spec";
|
|
25
|
-
import * as _confect_core_Types0 from "@confect/core/Types";
|
|
26
7
|
import * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
27
8
|
import * as GroupSpec from "@confect/core/GroupSpec";
|
|
28
|
-
import * as effect_Duration0 from "effect/Duration";
|
|
29
|
-
import * as effect_DateTime0 from "effect/DateTime";
|
|
30
9
|
|
|
31
10
|
//#region src/RegisteredFunctions.d.ts
|
|
32
11
|
declare namespace RegisteredFunctions_d_exports {
|
|
33
|
-
export { AnyWithProps,
|
|
12
|
+
export { AnyWithProps, RegisteredFunctions, make };
|
|
34
13
|
}
|
|
35
|
-
type RegisteredFunction = RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;
|
|
36
14
|
type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> = Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;
|
|
37
15
|
type RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = { [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<Groups, GroupName> extends infer Group extends GroupSpec.AnyWithProps ? GroupSpec.Groups<Group> extends infer SubGroups extends GroupSpec.AnyWithProps ? Types.Simplify<RegisteredFunctionsHelper<SubGroups> & { [FunctionName in FunctionSpec.Name<GroupSpec.Functions<Group>>]: FunctionSpec.WithName<GroupSpec.Functions<Group>, FunctionName> extends infer Function extends FunctionSpec.AnyWithProps ? FunctionSpec.RegisteredFunction<Function> : never }> : { [FunctionName in FunctionSpec.Name<GroupSpec.Functions<Group>>]: FunctionSpec.WithName<GroupSpec.Functions<Group>, FunctionName> extends infer Function extends FunctionSpec.AnyWithProps ? FunctionSpec.RegisteredFunction<Function> : never } : never };
|
|
38
16
|
interface AnyWithProps {
|
|
39
17
|
readonly [key: string]: RegisteredFunction | AnyWithProps;
|
|
40
18
|
}
|
|
41
|
-
declare const make: <Api_ extends AnyWithProps$
|
|
42
|
-
declare const mutationLayer: <Schema extends AnyWithProps$1>(schema: Schema, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<(<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>["Type"]) => Effect.Effect<any, effect_ParseResult0.ParseError, never>) | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>["Type"]) => Effect.Effect<_confect_core_Ref0.Returns<Query>["Type"], effect_ParseResult0.ParseError>) | {
|
|
43
|
-
runAfter: <FuncRef extends convex_server0.SchedulableFunctionReference>(delay: effect_Duration0.Duration, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
44
|
-
runAt: <FuncRef extends convex_server0.SchedulableFunctionReference>(dateTime: effect_DateTime0.DateTime, functionReference: FuncRef, ...args: convex_server0.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
45
|
-
} | GenericMutationCtx<ToConvex<FromSchema<Schema>>> | {
|
|
46
|
-
table: <const TableName extends Name<IncludeSystemTables<Tables<Schema>>>>(tableName: TableName) => {
|
|
47
|
-
readonly get: {
|
|
48
|
-
(id: convex_values0.GenericId<TableName>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
|
|
49
|
-
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<Schema>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"][IndexName]>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
50
|
-
};
|
|
51
|
-
readonly index: {
|
|
52
|
-
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"]>(indexName: IndexName, indexRange?: ((q: convex_server0.IndexRangeBuilder<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["convexDocument"], convex_server0.NamedIndex<TableInfoWithName<DataModel<IncludeSystemTables<Tables<Schema>>>, TableName>, IndexName>, 0>) => convex_server0.IndexRange) | undefined, order?: "asc" | "desc"): OrderedQuery$1<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>, TableName>;
|
|
53
|
-
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["indexes"]>(indexName: IndexName, order?: "asc" | "desc"): OrderedQuery$1<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>, TableName>;
|
|
54
|
-
};
|
|
55
|
-
readonly search: <IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["searchIndexes"]>(indexName: IndexName, searchFilter: (q: convex_server0.SearchFilterBuilder<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["convexDocument"], convex_server0.NamedSearchIndex<TableInfoWithName<DataModel<IncludeSystemTables<Tables<Schema>>>, TableName>, IndexName>>) => convex_server0.SearchFilter) => OrderedQuery$1<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>, TableName>;
|
|
56
|
-
};
|
|
57
|
-
} | {
|
|
58
|
-
table: <const TableName extends TableNames<FromSchema<Schema>>>(tableName: TableName) => {
|
|
59
|
-
insert: (document: WithoutSystemFields$1<DocumentByName<FromSchema<Schema>, TableName>>) => Effect.Effect<convex_values0.GenericId<TableName>, DocumentEncodeError, never>;
|
|
60
|
-
patch: (id: convex_values0.GenericId<TableName>, patchedValues: Partial<convex_server0.Expand<convex_server0.BetterOmit<DocumentByName<FromSchema<Schema>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentDecodeError | GetByIdFailure | DocumentEncodeError, never>;
|
|
61
|
-
replace: (id: convex_values0.GenericId<TableName>, value: convex_server0.Expand<convex_server0.BetterOmit<DocumentByName<FromSchema<Schema>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
62
|
-
delete: (id: convex_values0.GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
63
|
-
};
|
|
64
|
-
} | Auth$1 | StorageReader$1 | StorageWriter$1, never, never>;
|
|
65
|
-
type MutationServices<Schema extends AnyWithProps$1> = DatabaseReader<Schema> | DatabaseWriter<Schema> | Auth$1 | Scheduler$1 | StorageReader$1 | StorageWriter$1 | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<Schema>>>;
|
|
19
|
+
declare const make: <Api_ extends AnyWithProps$1>(impl: Layer.Layer<Impl<Api_, "Finalized">>, makeRegisteredFunction: (api: Api_, registryItem: AnyWithProps$2) => RegisteredFunction) => Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Api_["spec"]>>>;
|
|
66
20
|
//#endregion
|
|
67
|
-
export { AnyWithProps,
|
|
21
|
+
export { AnyWithProps, RegisteredFunctions, RegisteredFunctions_d_exports, make };
|
|
68
22
|
//# sourceMappingURL=RegisteredFunctions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunctions.d.ts","names":[],"sources":["../src/RegisteredFunctions.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"RegisteredFunctions.d.ts","names":[],"sources":["../src/RegisteredFunctions.ts"],"mappings":";;;;;;;;;;;;;KAYY,mBAAA,eAAkC,IAAA,CAAK,YAAA,IACjD,KAAA,CAAM,QAAA,CAAS,yBAAA,CAA0B,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,KAElD,yBAAA,gBAAyC,SAAA,CAAU,YAAA,oBACxC,SAAA,CAAU,IAAA,CAAK,MAAA,IAAU,SAAA,CAAU,QAAA,CAC/C,MAAA,EACA,SAAA,8BAC4B,SAAA,CAAU,YAAA,GACpC,SAAA,CAAU,MAAA,CAAO,KAAA,kCACf,SAAA,CAAU,YAAA,GACV,KAAA,CAAM,QAAA,CACJ,yBAAA,CAA0B,SAAA,uBACP,YAAA,CAAa,IAAA,CAC5B,SAAA,CAAU,SAAA,CAAU,KAAA,KAClB,YAAA,CAAa,QAAA,CACf,SAAA,CAAU,SAAA,CAAU,KAAA,GACpB,YAAA,iCAC+B,YAAA,CAAa,YAAA,GAC1C,YAAA,CAAa,kBAAA,CAAmB,QAAA,kCAKrB,YAAA,CAAa,IAAA,CAC5B,SAAA,CAAU,SAAA,CAAU,KAAA,KAClB,YAAA,CAAa,QAAA,CACf,SAAA,CAAU,SAAA,CAAU,KAAA,GACpB,YAAA,iCAC+B,YAAA,CAAa,YAAA,GAC1C,YAAA,CAAa,kBAAA,CAAmB,QAAA;AAAA,UAM7B,YAAA;EAAA,UACL,GAAA,WAAc,kBAAA,GAAwC,YAAA;AAAA;AAAA,cAGrD,IAAA,gBAAqB,cAAA,EAChC,IAAA,EAAM,KAAA,CAAM,KAAA,CAAM,IAAA,CAAU,IAAA,iBAC5B,sBAAA,GACE,GAAA,EAAK,IAAA,EACL,YAAA,EAAc,cAAA,KACX,kBAAA,KAAqC,KAAA,CAAA,QAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,MAAA,CAAA,IAAA"}
|
|
@@ -1,71 +1,19 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { ActionCtx } from "./ActionCtx.js";
|
|
3
|
-
import { layer } from "./ActionRunner.js";
|
|
4
|
-
import { layer as layer$1 } from "./Auth.js";
|
|
5
|
-
import { compileArgsSchema, compileReturnsSchema } from "./SchemaToValidator.js";
|
|
6
|
-
import { layer as layer$2 } from "./DatabaseReader.js";
|
|
7
|
-
import { layer as layer$3 } from "./DatabaseWriter.js";
|
|
8
2
|
import { mapLeaves } from "./internal/utils.js";
|
|
9
3
|
import { Registry } from "./Registry.js";
|
|
10
4
|
import { isRegistryItem } from "./RegistryItem.js";
|
|
11
|
-
import { layer as layer$4 } from "./MutationRunner.js";
|
|
12
|
-
import { layer as layer$5 } from "./QueryRunner.js";
|
|
13
|
-
import { layer as layer$6 } from "./Scheduler.js";
|
|
14
|
-
import { StorageActionWriter as StorageActionWriter$1, StorageReader as StorageReader$1, StorageWriter as StorageWriter$1 } from "./Storage.js";
|
|
15
5
|
import { Impl } from "./Impl.js";
|
|
16
|
-
import {
|
|
17
|
-
import { QueryCtx } from "./QueryCtx.js";
|
|
18
|
-
import { layer as layer$7 } from "./VectorSearch.js";
|
|
19
|
-
import { Effect, Layer, Match, Ref, Schema, pipe } from "effect";
|
|
20
|
-
import { actionGeneric, internalActionGeneric, internalMutationGeneric, internalQueryGeneric, mutationGeneric, queryGeneric } from "convex/server";
|
|
6
|
+
import { Effect, Match, Ref } from "effect";
|
|
21
7
|
|
|
22
8
|
//#region src/RegisteredFunctions.ts
|
|
23
|
-
var RegisteredFunctions_exports = /* @__PURE__ */ __exportAll({
|
|
24
|
-
|
|
25
|
-
mutationLayer: () => mutationLayer
|
|
26
|
-
});
|
|
27
|
-
const make = (impl) => Effect.gen(function* () {
|
|
9
|
+
var RegisteredFunctions_exports = /* @__PURE__ */ __exportAll({ make: () => make });
|
|
10
|
+
const make = (impl, makeRegisteredFunction) => Effect.gen(function* () {
|
|
28
11
|
const registry = yield* Registry;
|
|
29
12
|
const functionImplItems = yield* Ref.get(registry);
|
|
30
13
|
const { api, finalizationStatus } = yield* Impl();
|
|
31
14
|
return yield* Match.value(finalizationStatus).pipe(Match.withReturnType(), Match.when("Unfinalized", () => Effect.dieMessage("Impl is not finalized")), Match.when("Finalized", () => Effect.succeed(mapLeaves(functionImplItems, isRegistryItem, (registryItem) => makeRegisteredFunction(api, registryItem)))), Match.exhaustive);
|
|
32
15
|
}).pipe(Effect.provide(impl), Effect.runSync);
|
|
33
|
-
const makeRegisteredFunction = (api, { function_, handler }) => Match.value(function_.functionType).pipe(Match.when("query", () => {
|
|
34
|
-
return Match.value(function_.functionVisibility).pipe(Match.when("public", () => queryGeneric), Match.when("internal", () => internalQueryGeneric), Match.exhaustive)(queryFunction(api.databaseSchema, {
|
|
35
|
-
args: function_.args,
|
|
36
|
-
returns: function_.returns,
|
|
37
|
-
handler
|
|
38
|
-
}));
|
|
39
|
-
}), Match.when("mutation", () => {
|
|
40
|
-
return Match.value(function_.functionVisibility).pipe(Match.when("public", () => mutationGeneric), Match.when("internal", () => internalMutationGeneric), Match.exhaustive)(mutationFunction(api.databaseSchema, {
|
|
41
|
-
args: function_.args,
|
|
42
|
-
returns: function_.returns,
|
|
43
|
-
handler
|
|
44
|
-
}));
|
|
45
|
-
}), Match.when("action", () => {
|
|
46
|
-
return Match.value(function_.functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(actionFunction({
|
|
47
|
-
args: function_.args,
|
|
48
|
-
returns: function_.returns,
|
|
49
|
-
handler
|
|
50
|
-
}));
|
|
51
|
-
}), Match.exhaustive);
|
|
52
|
-
const queryFunction = (schema, { args, returns, handler }) => ({
|
|
53
|
-
args: compileArgsSchema(args),
|
|
54
|
-
returns: compileReturnsSchema(returns),
|
|
55
|
-
handler: (ctx, actualArgs) => pipe(actualArgs, Schema.decode(args), Effect.orDie, Effect.andThen((decodedArgs) => pipe(handler(decodedArgs), Effect.provide(Layer.mergeAll(layer$2(schema, ctx.db), layer$1(ctx.auth), StorageReader$1.layer(ctx.storage), layer$5(ctx.runQuery), Layer.succeed(QueryCtx(), ctx))))), Effect.andThen((convexReturns) => Schema.encodeUnknown(returns)(convexReturns)), Effect.runPromise)
|
|
56
|
-
});
|
|
57
|
-
const mutationLayer = (schema, ctx) => Layer.mergeAll(layer$2(schema, ctx.db), layer$3(schema, ctx.db), layer$1(ctx.auth), layer$6(ctx.scheduler), StorageReader$1.layer(ctx.storage), StorageWriter$1.layer(ctx.storage), layer$5(ctx.runQuery), layer$4(ctx.runMutation), Layer.succeed(MutationCtx(), ctx));
|
|
58
|
-
const mutationFunction = (schema, { args, returns, handler }) => ({
|
|
59
|
-
args: compileArgsSchema(args),
|
|
60
|
-
returns: compileReturnsSchema(returns),
|
|
61
|
-
handler: (ctx, actualArgs) => pipe(actualArgs, Schema.decode(args), Effect.orDie, Effect.andThen((decodedArgs) => handler(decodedArgs).pipe(Effect.provide(mutationLayer(schema, ctx)))), Effect.andThen((convexReturns) => Schema.encodeUnknown(returns)(convexReturns)), Effect.runPromise)
|
|
62
|
-
});
|
|
63
|
-
const actionFunction = ({ args, returns, handler }) => ({
|
|
64
|
-
args: compileArgsSchema(args),
|
|
65
|
-
returns: compileReturnsSchema(returns),
|
|
66
|
-
handler: (ctx, actualArgs) => pipe(actualArgs, Schema.decode(args), Effect.orDie, Effect.andThen((decodedArgs) => pipe(handler(decodedArgs), Effect.provide(Layer.mergeAll(layer$6(ctx.scheduler), layer$1(ctx.auth), StorageReader$1.layer(ctx.storage), StorageWriter$1.layer(ctx.storage), StorageActionWriter$1.layer(ctx.storage), layer$5(ctx.runQuery), layer$4(ctx.runMutation), layer(ctx.runAction), layer$7(ctx.vectorSearch), Layer.succeed(ActionCtx(), ctx))))), Effect.andThen((convexReturns) => Schema.encodeUnknown(returns)(convexReturns)), Effect.runPromise)
|
|
67
|
-
});
|
|
68
16
|
|
|
69
17
|
//#endregion
|
|
70
|
-
export { RegisteredFunctions_exports, make
|
|
18
|
+
export { RegisteredFunctions_exports, make };
|
|
71
19
|
//# sourceMappingURL=RegisteredFunctions.js.map
|