@confect/server 2.0.0 → 4.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 +33 -0
- package/dist/ActionRunner.d.ts +2 -2
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/ActionRunner.js +9 -7
- package/dist/ActionRunner.js.map +1 -1
- package/dist/BlobNotFoundError.d.ts +17 -0
- package/dist/BlobNotFoundError.d.ts.map +1 -0
- package/dist/BlobNotFoundError.js +14 -0
- package/dist/BlobNotFoundError.js.map +1 -0
- package/dist/CronJob.d.ts +22 -0
- package/dist/CronJob.d.ts.map +1 -0
- package/dist/CronJob.js +23 -0
- package/dist/CronJob.js.map +1 -0
- package/dist/CronJobs.d.ts +28 -0
- package/dist/CronJobs.d.ts.map +1 -0
- package/dist/CronJobs.js +75 -0
- package/dist/CronJobs.js.map +1 -0
- package/dist/DatabaseWriter.d.ts +4 -4
- package/dist/FunctionImpl.js +2 -2
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/Handler.d.ts +22 -14
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js.map +1 -1
- package/dist/HttpApi.d.ts +3 -1
- package/dist/HttpApi.d.ts.map +1 -1
- package/dist/HttpApi.js +3 -1
- package/dist/HttpApi.js.map +1 -1
- package/dist/MutationRunner.d.ts +2 -2
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +9 -7
- package/dist/MutationRunner.js.map +1 -1
- package/dist/OrderedQuery.d.ts +2 -2
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/OrderedQuery.js +3 -2
- package/dist/OrderedQuery.js.map +1 -1
- package/dist/QueryInitializer.d.ts +1 -1
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryRunner.d.ts +2 -2
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +7 -5
- package/dist/QueryRunner.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +11 -10
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +23 -19
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +20 -7
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +3 -1
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +4 -4
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +3 -3
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +6 -5
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/RegistryItem.d.ts +9 -9
- package/dist/RegistryItem.d.ts.map +1 -1
- package/dist/RegistryItem.js +2 -2
- package/dist/RegistryItem.js.map +1 -1
- package/dist/StorageActionWriter.d.ts +35 -0
- package/dist/StorageActionWriter.d.ts.map +1 -0
- package/dist/StorageActionWriter.js +20 -0
- package/dist/StorageActionWriter.js.map +1 -0
- package/dist/StorageReader.d.ts +26 -0
- package/dist/StorageReader.d.ts.map +1 -0
- package/dist/StorageReader.js +17 -0
- package/dist/StorageReader.js.map +1 -0
- package/dist/StorageWriter.d.ts +29 -0
- package/dist/StorageWriter.d.ts.map +1 -0
- package/dist/StorageWriter.js +20 -0
- package/dist/StorageWriter.js.map +1 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.js +7 -2
- package/package.json +4 -4
- package/src/ActionRunner.ts +27 -13
- package/src/BlobNotFoundError.ts +12 -0
- package/src/CronJob.ts +45 -0
- package/src/CronJobs.ts +161 -0
- package/src/FunctionImpl.ts +3 -3
- package/src/Handler.ts +42 -19
- package/src/HttpApi.ts +3 -1
- package/src/MutationRunner.ts +27 -13
- package/src/OrderedQuery.ts +15 -6
- package/src/QueryRunner.ts +22 -8
- package/src/RegisteredConvexFunction.ts +54 -42
- package/src/RegisteredFunction.ts +89 -2
- package/src/RegisteredFunctions.ts +10 -11
- package/src/RegisteredNodeFunction.ts +23 -13
- package/src/RegistryItem.ts +9 -12
- package/src/StorageActionWriter.ts +28 -0
- package/src/StorageReader.ts +27 -0
- package/src/StorageWriter.ts +26 -0
- package/src/index.ts +7 -2
- package/dist/Storage.d.ts +0 -69
- package/dist/Storage.d.ts.map +0 -1
- package/dist/Storage.js +0 -46
- package/dist/Storage.js.map +0 -1
- package/src/Storage.ts +0 -87
package/dist/HttpApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpApi.js","names":["QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","Scheduler.layer","Auth.layer","StorageReader","StorageWriter","StorageActionWriter","ActionCtx.ActionCtx","ConvexConfigProvider.make"],"sources":["../src/HttpApi.ts"],"sourcesContent":["import {\n type HttpApi,\n HttpApiBuilder,\n HttpApiScalar,\n type HttpApp,\n type HttpRouter,\n HttpServer,\n} from \"@effect/platform\";\nimport {\n type HttpRouter as ConvexHttpRouter,\n type GenericActionCtx,\n type GenericDataModel,\n httpActionGeneric,\n httpRouter,\n ROUTABLE_HTTP_METHODS,\n type RouteSpecWithPathPrefix,\n} from \"convex/server\";\nimport { Array, Layer, pipe, Record } from \"effect\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport { StorageActionWriter
|
|
1
|
+
{"version":3,"file":"HttpApi.js","names":["QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","Scheduler.layer","Auth.layer","StorageReader","StorageWriter","StorageActionWriter","ActionCtx.ActionCtx","ConvexConfigProvider.make"],"sources":["../src/HttpApi.ts"],"sourcesContent":["import {\n type HttpApi,\n HttpApiBuilder,\n HttpApiScalar,\n type HttpApp,\n type HttpRouter,\n HttpServer,\n} from \"@effect/platform\";\nimport {\n type HttpRouter as ConvexHttpRouter,\n type GenericActionCtx,\n type GenericDataModel,\n httpActionGeneric,\n httpRouter,\n ROUTABLE_HTTP_METHODS,\n type RouteSpecWithPathPrefix,\n} from \"convex/server\";\nimport { Array, Layer, pipe, Record } from \"effect\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport { StorageActionWriter } from \"./StorageActionWriter\";\nimport { StorageReader } from \"./StorageReader\";\nimport { StorageWriter } from \"./StorageWriter\";\n\ntype Middleware = (\n httpApp: HttpApp.Default,\n) => HttpApp.Default<\n never,\n HttpApi.Api | HttpApiBuilder.Router | HttpRouter.HttpRouter.DefaultServices\n>;\n\nconst makeHandler =\n <DataModel extends GenericDataModel>({\n pathPrefix,\n apiLive,\n middleware,\n scalar,\n }: {\n pathPrefix: RoutePath;\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | GenericActionCtx<DataModel>\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n }) =>\n (ctx: GenericActionCtx<DataModel>, request: Request): Promise<Response> => {\n const ApiLive = apiLive.pipe(\n Layer.provide(\n Layer.mergeAll(\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n ActionRunner.layer(ctx.runAction),\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 Layer.succeed(ActionCtx.ActionCtx<DataModel>(), ctx),\n ),\n ),\n );\n\n const ApiDocsLive = HttpApiScalar.layer({\n path: `${pathPrefix}docs`,\n scalar: {\n baseServerURL: `${process.env[\"CONVEX_SITE_URL\"]}${pathPrefix}`,\n ...scalar,\n },\n }).pipe(Layer.provide(ApiLive));\n\n const EnvLive = Layer.mergeAll(\n ApiLive,\n ApiDocsLive,\n HttpServer.layerContext,\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n );\n\n const { handler } = HttpApiBuilder.toWebHandler(\n EnvLive,\n middleware ? { middleware } : {},\n );\n\n return handler(request);\n };\n\nconst makeHttpAction = <DataModel extends GenericDataModel>({\n pathPrefix,\n apiLive,\n middleware,\n scalar,\n}: {\n pathPrefix: RoutePath;\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | GenericActionCtx<DataModel>\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n}) =>\n httpActionGeneric(\n makeHandler<DataModel>({\n pathPrefix,\n apiLive,\n ...(middleware ? { middleware } : {}),\n ...(scalar ? { scalar } : {}),\n }) as unknown as (\n ctx: GenericActionCtx<GenericDataModel>,\n request: Request,\n ) => Promise<Response>,\n );\n\nexport type HttpApi_ = {\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n};\n\nexport type RoutePath = \"/\" | `/${string}/`;\n\nconst mountEffectHttpApi =\n <DataModel extends GenericDataModel>({\n pathPrefix,\n apiLive,\n middleware,\n scalar,\n }: {\n pathPrefix: RoutePath;\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | GenericActionCtx<DataModel>\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n }) =>\n (convexHttpRouter: ConvexHttpRouter): ConvexHttpRouter => {\n const handler = makeHttpAction<DataModel>({\n pathPrefix,\n apiLive,\n ...(middleware ? { middleware } : {}),\n ...(scalar ? { scalar } : {}),\n });\n\n Array.forEach(ROUTABLE_HTTP_METHODS, (method) => {\n const routeSpec: RouteSpecWithPathPrefix = {\n pathPrefix,\n method,\n handler,\n };\n convexHttpRouter.route(routeSpec);\n });\n\n return convexHttpRouter;\n };\n\ntype HttpApis = Partial<Record<RoutePath, HttpApi_>>;\n\nexport const make = (httpApis: HttpApis): ConvexHttpRouter => {\n applyMonkeyPatches();\n\n return pipe(\n httpApis as Record<RoutePath, HttpApi_>,\n Record.toEntries,\n Array.reduce(\n httpRouter(),\n (convexHttpRouter, [pathPrefix, { apiLive, middleware, scalar }]) =>\n mountEffectHttpApi({\n pathPrefix: pathPrefix as RoutePath,\n apiLive,\n ...(middleware ? { middleware } : {}),\n ...(scalar ? { scalar } : {}),\n })(convexHttpRouter),\n ),\n );\n};\n\nconst applyMonkeyPatches = () => {\n // These are necessary until the Convex runtime supports these APIs. See https://discord.com/channels/1019350475847499849/1281364098419785760\n\n // eslint-disable-next-line no-global-assign\n URL = class extends URL {\n override get username() {\n return \"\";\n }\n override get password() {\n return \"\";\n }\n };\n\n Object.defineProperty(Request.prototype, \"signal\", {\n get: () => new AbortSignal(),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,eACiC,EACnC,YACA,SACA,YACA,cAmBD,KAAkC,YAAwC;CACzE,MAAM,UAAU,QAAQ,KACtB,MAAM,QACJ,MAAM,SACJA,QAA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B,CAAC,YAAY,EAAE,SAAS,YAAY,cACrD,mBAAmB;EACL;EACZ;EACA,GAAI,aAAa,EAAE,YAAY,GAAG,EAAE;EACpC,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;EAC7B,CAAC,CAAC,iBAAiB,CACvB,CACF;;AAGH,MAAM,2BAA2B;AAI/B,OAAM,cAAc,IAAI;EACtB,IAAa,WAAW;AACtB,UAAO;;EAET,IAAa,WAAW;AACtB,UAAO;;;AAIX,QAAO,eAAe,QAAQ,WAAW,UAAU,EACjD,WAAW,IAAI,aAAa,EAC7B,CAAC"}
|
package/dist/MutationRunner.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ import { GenericMutationCtx } from "convex/server";
|
|
|
6
6
|
declare namespace MutationRunner_d_exports {
|
|
7
7
|
export { MutationRollback, MutationRunner, layer };
|
|
8
8
|
}
|
|
9
|
-
declare const MutationRunner: Context.Tag<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>
|
|
9
|
+
declare const MutationRunner: Context.Tag<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) => Effect.Effect<Ref$1.Returns<Mutation>, ParseResult.ParseError>), <Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) => Effect.Effect<Ref$1.Returns<Mutation>, ParseResult.ParseError>>;
|
|
10
10
|
type MutationRunner = typeof MutationRunner.Identifier;
|
|
11
|
-
declare const layer: (runMutation: GenericMutationCtx<any>["runMutation"]) => Layer.Layer<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>
|
|
11
|
+
declare const layer: (runMutation: GenericMutationCtx<any>["runMutation"]) => Layer.Layer<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) => Effect.Effect<Ref$1.Returns<Mutation>, ParseResult.ParseError>), never, never>;
|
|
12
12
|
declare const MutationRollback_base: Schema.TaggedErrorClass<MutationRollback, "MutationRollback", {
|
|
13
13
|
readonly _tag: Schema.tag<"MutationRollback">;
|
|
14
14
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationRunner.d.ts","names":[],"sources":["../src/MutationRunner.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"MutationRunner.d.ts","names":[],"sources":["../src/MutationRunner.ts"],"mappings":";;;;;;;;cAoCa,cAAA,EAAc,OAAA,CAAA,GAAA,oBA7BP,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,QAAA,GAAW,WAAA,CAAY,UAAA,sBAHlC,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,QAAA,GAAW,WAAA,CAAY,UAAA;AAAA,KA6B1C,cAAA,UAAwB,cAAA,CAAe,UAAA;AAAA,cAEtC,KAAA,GAAS,WAAA,EAAa,kBAAA,yBAAsC,KAAA,CAAA,KAAA,oBAlCrD,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,QAAA,GAAW,WAAA,CAAY,UAAA;AAAA,cAgCH,qBAAA;;;;;;cAEtC,gBAAA,SAAyB,qBAAA;EAAA,IAQvB,OAAA,CAAA;AAAA"}
|
package/dist/MutationRunner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
2
|
+
import { Context, Effect, Layer, Match, Schema } from "effect";
|
|
3
3
|
import * as Ref$1 from "@confect/core/Ref";
|
|
4
4
|
import "convex/server";
|
|
5
5
|
|
|
@@ -9,15 +9,17 @@ var MutationRunner_exports = /* @__PURE__ */ __exportAll({
|
|
|
9
9
|
MutationRunner: () => MutationRunner,
|
|
10
10
|
layer: () => layer
|
|
11
11
|
});
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const make = (runMutation) => (mutation, args) => Effect.gen(function* () {
|
|
13
|
+
const functionSpec = Ref$1.getFunctionSpec(mutation);
|
|
14
14
|
const functionName = Ref$1.getConvexFunctionName(mutation);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
return yield* Match.value(functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionSpec) => Effect.gen(function* () {
|
|
16
|
+
const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(args);
|
|
17
|
+
const encodedReturns = yield* Effect.promise(() => runMutation(functionName, encodedArgs));
|
|
18
|
+
return yield* Schema.decode(confectFunctionSpec.returns)(encodedReturns);
|
|
19
|
+
})), Match.tag("Convex", () => Effect.promise(() => runMutation(functionName, args))), Match.exhaustive);
|
|
18
20
|
});
|
|
19
21
|
const MutationRunner = Context.GenericTag("@confect/server/MutationRunner");
|
|
20
|
-
const layer = (runMutation) => Layer.succeed(MutationRunner,
|
|
22
|
+
const layer = (runMutation) => Layer.succeed(MutationRunner, make(runMutation));
|
|
21
23
|
var MutationRollback = class extends Schema.TaggedError()("MutationRollback", {
|
|
22
24
|
mutationName: Schema.String,
|
|
23
25
|
error: Schema.Unknown
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationRunner.js","names":["Ref"],"sources":["../src/MutationRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericMutationCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Schema } from \"effect\";\n\nconst
|
|
1
|
+
{"version":3,"file":"MutationRunner.js","names":["Ref"],"sources":["../src/MutationRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericMutationCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Match, Schema } from \"effect\";\n\nconst make =\n (runMutation: GenericMutationCtx<any>[\"runMutation\"]) =>\n <Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n args: Ref.Args<Mutation>,\n ): Effect.Effect<Ref.Returns<Mutation>, ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionSpec = Ref.getFunctionSpec(mutation);\n const functionName = Ref.getConvexFunctionName(mutation);\n\n return yield* Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionSpec) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(\n args,\n );\n const encodedReturns = yield* Effect.promise(() =>\n runMutation(functionName as any, encodedArgs),\n );\n return yield* Schema.decode(confectFunctionSpec.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () =>\n Effect.promise(() => runMutation(functionName as any, args as any)),\n ),\n Match.exhaustive,\n );\n });\n\nexport const MutationRunner = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/MutationRunner\",\n);\nexport type MutationRunner = typeof MutationRunner.Identifier;\n\nexport const layer = (runMutation: GenericMutationCtx<any>[\"runMutation\"]) =>\n Layer.succeed(MutationRunner, make(runMutation));\n\nexport class MutationRollback extends Schema.TaggedError<MutationRollback>()(\n \"MutationRollback\",\n {\n mutationName: Schema.String,\n error: Schema.Unknown,\n },\n) {\n /* v8 ignore start */\n override get message(): string {\n return `Mutation ${this.mutationName} failed and was rolled back.\\n\\n${this.error}`;\n }\n /* v8 ignore stop */\n}\n"],"mappings":";;;;;;;;;;;AAKA,MAAM,QACH,iBAEC,UACA,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,eAAeA,MAAI,gBAAgB,SAAS;CAClD,MAAM,eAAeA,MAAI,sBAAsB,SAAS;AAExD,QAAO,OAAO,MAAM,MAAM,aAAa,mBAAmB,CAAC,KACzD,MAAM,IAAI,YAAY,wBACpB,OAAO,IAAI,aAAa;EACtB,MAAM,cAAc,OAAO,OAAO,OAAO,oBAAoB,KAAK,CAChE,KACD;EACD,MAAM,iBAAiB,OAAO,OAAO,cACnC,YAAY,cAAqB,YAAY,CAC9C;AACD,SAAO,OAAO,OAAO,OAAO,oBAAoB,QAAQ,CACtD,eACD;GACD,CACH,EACD,MAAM,IAAI,gBACR,OAAO,cAAc,YAAY,cAAqB,KAAY,CAAC,CACpE,EACD,MAAM,WACP;EACD;AAEN,MAAa,iBAAiB,QAAQ,WACpC,iCACD;AAGD,MAAa,SAAS,gBACpB,MAAM,QAAQ,gBAAgB,KAAK,YAAY,CAAC;AAElD,IAAa,mBAAb,cAAsC,OAAO,aAA+B,CAC1E,oBACA;CACE,cAAc,OAAO;CACrB,OAAO,OAAO;CACf,CACF,CAAC;;CAEA,IAAa,UAAkB;AAC7B,SAAO,YAAY,KAAK,aAAa,kCAAkC,KAAK"}
|
package/dist/OrderedQuery.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DocumentDecodeError } from "./Document.js";
|
|
2
2
|
import { AnyWithProps, ConvexTableInfo, TableSchema } from "./TableInfo.js";
|
|
3
3
|
import { Effect, Option, Stream } from "effect";
|
|
4
|
-
import { OrderedQuery as OrderedQuery$1, PaginationResult } from "convex/server";
|
|
4
|
+
import { ExpressionOrValue, FilterBuilder, OrderedQuery as OrderedQuery$1, PaginationResult } from "convex/server";
|
|
5
5
|
|
|
6
6
|
//#region src/OrderedQuery.d.ts
|
|
7
7
|
declare namespace OrderedQuery_d_exports {
|
|
@@ -15,7 +15,7 @@ type OrderedQuery<TableInfo_ extends AnyWithProps, _TableName extends string> =
|
|
|
15
15
|
readonly paginate: (options: {
|
|
16
16
|
cursor: string | null;
|
|
17
17
|
numItems: number;
|
|
18
|
-
}) => Effect.Effect<PaginationResult<TableInfo_["document"]>, DocumentDecodeError>;
|
|
18
|
+
}, filter?: (q: FilterBuilder<ConvexTableInfo<TableInfo_>>) => ExpressionOrValue<boolean>) => Effect.Effect<PaginationResult<TableInfo_["document"]>, DocumentDecodeError>;
|
|
19
19
|
};
|
|
20
20
|
declare const make: <TableInfo_ extends AnyWithProps, TableName extends string>(query: OrderedQuery$1<ConvexTableInfo<TableInfo_>>, tableName: TableName, tableSchema: TableSchema<TableInfo_>) => OrderedQuery<TableInfo_, TableName>;
|
|
21
21
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderedQuery.d.ts","names":[],"sources":["../src/OrderedQuery.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"OrderedQuery.d.ts","names":[],"sources":["../src/OrderedQuery.ts"],"mappings":";;;;;;;;;KAUY,YAAA,oBACS,YAAA;EAAA,SAGV,KAAA,QAAa,MAAA,CAAO,MAAA,CAC3B,MAAA,CAAO,MAAA,CAAO,UAAA,eACd,mBAAA;EAAA,SAEO,IAAA,GACP,CAAA,aACG,MAAA,CAAO,MAAA,CACV,aAAA,CAAc,UAAA,eACd,mBAAA;EAAA,SAEO,OAAA,QAAe,MAAA,CAAO,MAAA,CAC7B,aAAA,CAAc,UAAA,eACd,mBAAA;EAAA,SAEO,MAAA,QAAc,MAAA,CAAO,MAAA,CAC5B,UAAA,cACA,mBAAA;EAAA,SAEO,QAAA,GACP,OAAA;IACE,MAAA;IACA,QAAA;EAAA,GAEF,MAAA,IACE,CAAA,EAAG,aAAA,CAAc,eAAA,CAA0B,UAAA,OACxC,iBAAA,cACF,MAAA,CAAO,MAAA,CACV,gBAAA,CAAiB,UAAA,eACjB,mBAAA;AAAA;AAAA,cAIS,IAAA,sBACQ,YAAA,4BAGnB,KAAA,EAAO,cAAA,CAAmB,eAAA,CAA0B,UAAA,IACpD,SAAA,EAAW,SAAA,EACX,WAAA,EAAa,WAAA,CAAsB,UAAA,MAClC,YAAA,CAAa,UAAA,EAAY,SAAA"}
|
package/dist/OrderedQuery.js
CHANGED
|
@@ -10,8 +10,9 @@ const make = (query, tableName, tableSchema) => {
|
|
|
10
10
|
const first = () => pipe(stream(), Stream.take(1), Stream.runHead);
|
|
11
11
|
const take = (n) => pipe(stream(), Stream.take(n), Stream.runCollect, Effect.map((chunk) => Chunk.toReadonlyArray(chunk)));
|
|
12
12
|
const collect = () => pipe(stream(), Stream.runCollect, Effect.map(Chunk.toReadonlyArray));
|
|
13
|
-
const paginate = (options) => Effect.gen(function* () {
|
|
14
|
-
const
|
|
13
|
+
const paginate = (options, filter) => Effect.gen(function* () {
|
|
14
|
+
const filteredQuery = filter !== void 0 ? query.filter(filter) : query;
|
|
15
|
+
const paginationResult = yield* Effect.promise(() => filteredQuery.paginate(options));
|
|
15
16
|
return {
|
|
16
17
|
page: yield* Effect.forEach(paginationResult.page, decode(tableName, tableSchema)),
|
|
17
18
|
isDone: paginationResult.isDone,
|
package/dist/OrderedQuery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderedQuery.js","names":["Document.decode"],"sources":["../src/OrderedQuery.ts"],"sourcesContent":["import type {\n OrderedQuery as ConvexOrderedQuery,\n PaginationResult,\n} from \"convex/server\";\nimport { Chunk, Effect, identity, type Option, pipe, Stream } from \"effect\";\nimport * as Document from \"./Document\";\nimport type * as TableInfo from \"./TableInfo\";\n\nexport type OrderedQuery<\n TableInfo_ extends TableInfo.AnyWithProps,\n _TableName extends string,\n> = {\n readonly first: () => Effect.Effect<\n Option.Option<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n readonly take: (\n n: number,\n ) => Effect.Effect<\n ReadonlyArray<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n readonly collect: () => Effect.Effect<\n ReadonlyArray<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n readonly stream: () => Stream.Stream<\n TableInfo_[\"document\"],\n Document.DocumentDecodeError\n >;\n readonly paginate: (options: {\n
|
|
1
|
+
{"version":3,"file":"OrderedQuery.js","names":["Document.decode"],"sources":["../src/OrderedQuery.ts"],"sourcesContent":["import type {\n ExpressionOrValue,\n FilterBuilder,\n OrderedQuery as ConvexOrderedQuery,\n PaginationResult,\n} from \"convex/server\";\nimport { Chunk, Effect, identity, type Option, pipe, Stream } from \"effect\";\nimport * as Document from \"./Document\";\nimport type * as TableInfo from \"./TableInfo\";\n\nexport type OrderedQuery<\n TableInfo_ extends TableInfo.AnyWithProps,\n _TableName extends string,\n> = {\n readonly first: () => Effect.Effect<\n Option.Option<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n readonly take: (\n n: number,\n ) => Effect.Effect<\n ReadonlyArray<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n readonly collect: () => Effect.Effect<\n ReadonlyArray<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n readonly stream: () => Stream.Stream<\n TableInfo_[\"document\"],\n Document.DocumentDecodeError\n >;\n readonly paginate: (\n options: {\n cursor: string | null;\n numItems: number;\n },\n filter?: (\n q: FilterBuilder<TableInfo.ConvexTableInfo<TableInfo_>>,\n ) => ExpressionOrValue<boolean>,\n ) => Effect.Effect<\n PaginationResult<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n};\n\nexport const make = <\n TableInfo_ extends TableInfo.AnyWithProps,\n TableName extends string,\n>(\n query: ConvexOrderedQuery<TableInfo.ConvexTableInfo<TableInfo_>>,\n tableName: TableName,\n tableSchema: TableInfo.TableSchema<TableInfo_>,\n): OrderedQuery<TableInfo_, TableName> => {\n type OrderedQueryFunction<\n FunctionName extends keyof OrderedQuery<TableInfo_, TableName>,\n > = OrderedQuery<TableInfo_, TableName>[FunctionName];\n\n const streamEncoded = Stream.fromAsyncIterable(query, identity).pipe(\n Stream.orDie,\n );\n\n const stream: OrderedQueryFunction<\"stream\"> = () =>\n pipe(\n streamEncoded,\n Stream.mapEffect(Document.decode(tableName, tableSchema)),\n );\n\n const first: OrderedQueryFunction<\"first\"> = () =>\n pipe(stream(), Stream.take(1), Stream.runHead);\n\n const take: OrderedQueryFunction<\"take\"> = (n: number) =>\n pipe(\n stream(),\n Stream.take(n),\n Stream.runCollect,\n Effect.map((chunk) => Chunk.toReadonlyArray(chunk)),\n );\n\n const collect: OrderedQueryFunction<\"collect\"> = () =>\n pipe(stream(), Stream.runCollect, Effect.map(Chunk.toReadonlyArray));\n\n const paginate: OrderedQueryFunction<\"paginate\"> = (options, filter) =>\n Effect.gen(function* () {\n const filteredQuery = filter !== undefined ? query.filter(filter) : query;\n\n const paginationResult = yield* Effect.promise(() =>\n filteredQuery.paginate(options),\n );\n\n const parsedPage = yield* Effect.forEach(\n paginationResult.page,\n Document.decode(tableName, tableSchema),\n );\n\n return {\n page: parsedPage,\n isDone: paginationResult.isDone,\n continueCursor: paginationResult.continueCursor,\n /* v8 ignore start */\n ...(paginationResult.splitCursor\n ? { splitCursor: paginationResult.splitCursor }\n : {}),\n ...(paginationResult.pageStatus\n ? { pageStatus: paginationResult.pageStatus }\n : {}),\n /* v8 ignore stop */\n };\n });\n\n return {\n first,\n take,\n collect,\n paginate,\n stream,\n };\n};\n"],"mappings":";;;;;;AA8CA,MAAa,QAIX,OACA,WACA,gBACwC;CAKxC,MAAM,gBAAgB,OAAO,kBAAkB,OAAO,SAAS,CAAC,KAC9D,OAAO,MACR;CAED,MAAM,eACJ,KACE,eACA,OAAO,UAAUA,OAAgB,WAAW,YAAY,CAAC,CAC1D;CAEH,MAAM,cACJ,KAAK,QAAQ,EAAE,OAAO,KAAK,EAAE,EAAE,OAAO,QAAQ;CAEhD,MAAM,QAAsC,MAC1C,KACE,QAAQ,EACR,OAAO,KAAK,EAAE,EACd,OAAO,YACP,OAAO,KAAK,UAAU,MAAM,gBAAgB,MAAM,CAAC,CACpD;CAEH,MAAM,gBACJ,KAAK,QAAQ,EAAE,OAAO,YAAY,OAAO,IAAI,MAAM,gBAAgB,CAAC;CAEtE,MAAM,YAA8C,SAAS,WAC3D,OAAO,IAAI,aAAa;EACtB,MAAM,gBAAgB,WAAW,SAAY,MAAM,OAAO,OAAO,GAAG;EAEpE,MAAM,mBAAmB,OAAO,OAAO,cACrC,cAAc,SAAS,QAAQ,CAChC;AAOD,SAAO;GACL,MANiB,OAAO,OAAO,QAC/B,iBAAiB,MACjBA,OAAgB,WAAW,YAAY,CACxC;GAIC,QAAQ,iBAAiB;GACzB,gBAAgB,iBAAiB;GAEjC,GAAI,iBAAiB,cACjB,EAAE,aAAa,iBAAiB,aAAa,GAC7C,EAAE;GACN,GAAI,iBAAiB,aACjB,EAAE,YAAY,iBAAiB,YAAY,GAC3C,EAAE;GAEP;GACD;AAEJ,QAAO;EACL;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -24,7 +24,7 @@ type QueryInitializer<DataModel_ extends AnyWithProps$2, TableName extends Table
|
|
|
24
24
|
readonly search: <IndexName extends keyof SearchIndexes<_ConvexTableInfo>>(indexName: IndexName, searchFilter: (q: SearchFilterBuilder<DocumentByInfo<_ConvexTableInfo>, NamedSearchIndex<_ConvexTableInfo, IndexName>>) => SearchFilter) => OrderedQuery$1<_TableInfo, TableName>;
|
|
25
25
|
};
|
|
26
26
|
declare const make: <Tables extends AnyWithProps, TableName extends Name<Tables>>(tableName: TableName, convexDatabaseReader: BaseDatabaseReader<ToConvex<FromTables<Tables>>>, table: WithName<Tables, TableName>) => QueryInitializer<DataModel<Tables>, TableName, TableInfoWithName<DataModel<Tables>, TableName>, TableInfoWithName_<DataModel<Tables>, TableName>>;
|
|
27
|
-
declare const getById: <Tables extends AnyWithProps, TableName extends Name<Tables>>(tableName: TableName, convexDatabaseReader: BaseDatabaseReader<ToConvex<FromTables<Tables>>>, table: WithName<Tables, TableName>) => (id: GenericId<TableName>) => Effect.Effect<any,
|
|
27
|
+
declare const getById: <Tables extends AnyWithProps, TableName extends Name<Tables>>(tableName: TableName, convexDatabaseReader: BaseDatabaseReader<ToConvex<FromTables<Tables>>>, table: WithName<Tables, TableName>) => (id: GenericId<TableName>) => Effect.Effect<any, GetByIdFailure | DocumentDecodeError, never>;
|
|
28
28
|
declare const GetByIdFailure_base: Schema.TaggedErrorClass<GetByIdFailure, "GetByIdFailure", {
|
|
29
29
|
readonly _tag: Schema.tag<"GetByIdFailure">;
|
|
30
30
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryInitializer.d.ts","names":[],"sources":["../src/QueryInitializer.ts"],"mappings":";;;;;;;;;;;;;;KA6BK,gBAAA,oBACgB,cAAA,oBACD,UAAA,CAAqB,UAAA,4BACd,gBAAA,qBACN,cAAA;EAAA,SAEV,GAAA;IAAA,CAEL,EAAA,EAAI,SAAA,CAAU,SAAA,IACb,MAAA,CAAO,MAAA,CACR,UAAA,cACA,mBAAA,GAA+B,cAAA;IAAA,yBAER,OAAA,CAAQ,gBAAA,GAC/B,SAAA,EAAW,SAAA,KACR,gBAAA,EAAkB,oBAAA,CACnB,QAAA,CAAmB,UAAA,GACnB,SAAA,EACA,OAAA,CAAQ,gBAAA,EAAkB,SAAA,KAE3B,MAAA,CAAO,MAAA,CACR,UAAA,cACA,mBAAA,GAA+B,iBAAA;EAAA;EAAA,SAG1B,KAAA;IAAA,yBACkB,OAAA,CAAQ,gBAAA,GAC/B,SAAA,EAAW,SAAA,EACX,UAAA,IACE,CAAA,EAAG,iBAAA,CACD,UAAA,oBACA,UAAA,CAAW,gBAAA,EAAkB,SAAA,OAE5B,UAAA,EACL,KAAA,oBACC,cAAA,CAA0B,UAAA,EAAY,SAAA;IAAA,yBAChB,OAAA,CAAQ,gBAAA,GAC/B,SAAA,EAAW,SAAA,EACX,KAAA,oBACC,cAAA,CAA0B,UAAA,EAAY,SAAA;EAAA;EAAA,SAElC,MAAA,2BAAiC,aAAA,CAAc,gBAAA,GACtD,SAAA,EAAW,SAAA,EACX,YAAA,GACE,CAAA,EAAG,mBAAA,CACD,cAAA,CAAe,gBAAA,GACf,gBAA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A;EAAA,IAOrB,OAAA,CAAA;AAAA;AAAA,cAOd,sBAAA;;;;;;;cAEY,iBAAA,SAA0B,sBAAA;EAAA,IAQxB,OAAA,CAAA;AAAA"}
|
package/dist/QueryRunner.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ import { GenericQueryCtx } from "convex/server";
|
|
|
6
6
|
declare namespace QueryRunner_d_exports {
|
|
7
7
|
export { QueryRunner, layer };
|
|
8
8
|
}
|
|
9
|
-
declare const QueryRunner: Context.Tag<(<Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>
|
|
9
|
+
declare const QueryRunner: Context.Tag<(<Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>) => Effect.Effect<Ref$1.Returns<Query>, ParseResult.ParseError>), <Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>) => Effect.Effect<Ref$1.Returns<Query>, ParseResult.ParseError>>;
|
|
10
10
|
type QueryRunner = typeof QueryRunner.Identifier;
|
|
11
|
-
declare const layer: (runQuery: GenericQueryCtx<any>["runQuery"]) => Layer.Layer<(<Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>
|
|
11
|
+
declare const layer: (runQuery: GenericQueryCtx<any>["runQuery"]) => Layer.Layer<(<Query extends Ref$1.AnyQuery>(query: Query, args: Ref$1.Args<Query>) => Effect.Effect<Ref$1.Returns<Query>, ParseResult.ParseError>), never, never>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { QueryRunner, QueryRunner_d_exports, layer };
|
|
14
14
|
//# sourceMappingURL=QueryRunner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryRunner.d.ts","names":[],"sources":["../src/QueryRunner.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"QueryRunner.d.ts","names":[],"sources":["../src/QueryRunner.ts"],"mappings":";;;;;;;;cAoCa,WAAA,EAAW,OAAA,CAAA,GAAA,iBA7BP,KAAA,CAAI,QAAA,EAAQ,KAAA,EAClB,KAAA,EAAK,IAAA,EACN,KAAA,CAAI,IAAA,CAAK,KAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,KAAA,GAAQ,WAAA,CAAY,UAAA,mBAHlC,KAAA,CAAI,QAAA,EAAQ,KAAA,EAClB,KAAA,EAAK,IAAA,EACN,KAAA,CAAI,IAAA,CAAK,KAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,KAAA,GAAQ,WAAA,CAAY,UAAA;AAAA,KA6BvC,WAAA,UAAqB,WAAA,CAAY,UAAA;AAAA,cAEhC,KAAA,GAAS,QAAA,EAAU,eAAA,sBAAgC,KAAA,CAAA,KAAA,iBAlC/C,KAAA,CAAI,QAAA,EAAQ,KAAA,EAClB,KAAA,EAAK,IAAA,EACN,KAAA,CAAI,IAAA,CAAK,KAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,KAAA,GAAQ,WAAA,CAAY,UAAA"}
|
package/dist/QueryRunner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
2
|
+
import { Context, Effect, Layer, Match, Schema } from "effect";
|
|
3
3
|
import * as Ref$1 from "@confect/core/Ref";
|
|
4
4
|
import "convex/server";
|
|
5
5
|
|
|
@@ -9,11 +9,13 @@ var QueryRunner_exports = /* @__PURE__ */ __exportAll({
|
|
|
9
9
|
layer: () => layer
|
|
10
10
|
});
|
|
11
11
|
const make = (runQuery) => (query, args) => Effect.gen(function* () {
|
|
12
|
-
const
|
|
12
|
+
const functionSpec = Ref$1.getFunctionSpec(query);
|
|
13
13
|
const functionName = Ref$1.getConvexFunctionName(query);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
return yield* Match.value(functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionSpec) => Effect.gen(function* () {
|
|
15
|
+
const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(args);
|
|
16
|
+
const encodedReturns = yield* Effect.promise(() => runQuery(functionName, encodedArgs));
|
|
17
|
+
return yield* Schema.decode(confectFunctionSpec.returns)(encodedReturns);
|
|
18
|
+
})), Match.tag("Convex", () => Effect.promise(() => runQuery(functionName, args))), Match.exhaustive);
|
|
17
19
|
});
|
|
18
20
|
const QueryRunner = Context.GenericTag("@confect/server/QueryRunner");
|
|
19
21
|
const layer = (runQuery) => Layer.succeed(QueryRunner, make(runQuery));
|
package/dist/QueryRunner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryRunner.js","names":["Ref"],"sources":["../src/QueryRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericQueryCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Schema } from \"effect\";\n\nconst make =\n (runQuery: GenericQueryCtx<any>[\"runQuery\"]) =>\n <Query extends Ref.AnyQuery>(\n query: Query,\n args: Ref.Args<Query
|
|
1
|
+
{"version":3,"file":"QueryRunner.js","names":["Ref"],"sources":["../src/QueryRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericQueryCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Match, Schema } from \"effect\";\n\nconst make =\n (runQuery: GenericQueryCtx<any>[\"runQuery\"]) =>\n <Query extends Ref.AnyQuery>(\n query: Query,\n args: Ref.Args<Query>,\n ): Effect.Effect<Ref.Returns<Query>, ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionSpec = Ref.getFunctionSpec(query);\n const functionName = Ref.getConvexFunctionName(query);\n\n return yield* Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionSpec) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(\n args,\n );\n const encodedReturns = yield* Effect.promise(() =>\n runQuery(functionName as any, encodedArgs),\n );\n return yield* Schema.decode(confectFunctionSpec.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () =>\n Effect.promise(() => runQuery(functionName as any, args as any)),\n ),\n Match.exhaustive,\n );\n });\n\nexport const QueryRunner = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/QueryRunner\",\n);\nexport type QueryRunner = typeof QueryRunner.Identifier;\n\nexport const layer = (runQuery: GenericQueryCtx<any>[\"runQuery\"]) =>\n Layer.succeed(QueryRunner, make(runQuery));\n"],"mappings":";;;;;;;;;;AAKA,MAAM,QACH,cAEC,OACA,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,eAAeA,MAAI,gBAAgB,MAAM;CAC/C,MAAM,eAAeA,MAAI,sBAAsB,MAAM;AAErD,QAAO,OAAO,MAAM,MAAM,aAAa,mBAAmB,CAAC,KACzD,MAAM,IAAI,YAAY,wBACpB,OAAO,IAAI,aAAa;EACtB,MAAM,cAAc,OAAO,OAAO,OAAO,oBAAoB,KAAK,CAChE,KACD;EACD,MAAM,iBAAiB,OAAO,OAAO,cACnC,SAAS,cAAqB,YAAY,CAC3C;AACD,SAAO,OAAO,OAAO,OAAO,oBAAoB,QAAQ,CACtD,eACD;GACD,CACH,EACD,MAAM,IAAI,gBACR,OAAO,cAAc,SAAS,cAAqB,KAAY,CAAC,CACjE,EACD,MAAM,WACP;EACD;AAEN,MAAa,cAAc,QAAQ,WACjC,8BACD;AAGD,MAAa,SAAS,aACpB,MAAM,QAAQ,aAAa,KAAK,SAAS,CAAC"}
|
|
@@ -13,8 +13,9 @@ import { MutationCtx } from "./MutationCtx.js";
|
|
|
13
13
|
import { MutationRunner } from "./MutationRunner.js";
|
|
14
14
|
import { QueryRunner } from "./QueryRunner.js";
|
|
15
15
|
import { Scheduler as Scheduler$1 } from "./Scheduler.js";
|
|
16
|
-
import { StorageReader as StorageReader$1
|
|
17
|
-
import {
|
|
16
|
+
import { StorageReader as StorageReader$1 } from "./StorageReader.js";
|
|
17
|
+
import { StorageWriter as StorageWriter$1 } from "./StorageWriter.js";
|
|
18
|
+
import { Any } from "./RegisteredFunction.js";
|
|
18
19
|
import { AnyWithProps as AnyWithProps$1 } from "./RegistryItem.js";
|
|
19
20
|
import { Effect, Layer } from "effect";
|
|
20
21
|
import * as _confect_core_Ref0 from "@confect/core/Ref";
|
|
@@ -22,22 +23,22 @@ import * as convex_server0 from "convex/server";
|
|
|
22
23
|
import { GenericMutationCtx } from "convex/server";
|
|
23
24
|
import * as convex_values0 from "convex/values";
|
|
24
25
|
import * as _confect_core_Types0 from "@confect/core/Types";
|
|
26
|
+
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
25
27
|
import * as effect_Duration0 from "effect/Duration";
|
|
26
28
|
import * as effect_DateTime0 from "effect/DateTime";
|
|
27
|
-
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
28
29
|
|
|
29
30
|
//#region src/RegisteredConvexFunction.d.ts
|
|
30
31
|
declare namespace RegisteredConvexFunction_d_exports {
|
|
31
32
|
export { MutationServices, make, mutationLayer };
|
|
32
33
|
}
|
|
33
34
|
declare const make: <Api_ extends AnyWithPropsWithRuntime<"Convex">>(api: Api_, {
|
|
34
|
-
|
|
35
|
+
functionSpec,
|
|
35
36
|
handler
|
|
36
|
-
}: AnyWithProps$1) =>
|
|
37
|
-
declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<GenericMutationCtx<ToConvex<FromSchema<Schema>>> | {
|
|
37
|
+
}: AnyWithProps$1) => Any;
|
|
38
|
+
declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<Auth$1 | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>, effect_ParseResult0.ParseError>) | GenericMutationCtx<ToConvex<FromSchema<Schema>>> | {
|
|
38
39
|
table: <const TableName extends Name<IncludeSystemTables<Tables<Schema>>>>(tableName: TableName) => {
|
|
39
40
|
readonly get: {
|
|
40
|
-
(id: convex_values0.GenericId<TableName>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"],
|
|
41
|
+
(id: convex_values0.GenericId<TableName>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], GetByIdFailure | DocumentDecodeError, never>;
|
|
41
42
|
<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
|
};
|
|
43
44
|
readonly index: {
|
|
@@ -49,14 +50,14 @@ declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx:
|
|
|
49
50
|
} | {
|
|
50
51
|
table: <const TableName extends TableNames<FromSchema<Schema>>>(tableName: TableName) => {
|
|
51
52
|
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,
|
|
53
|
+
patch: (id: convex_values0.GenericId<TableName>, patchedValues: Partial<convex_server0.Expand<convex_server0.BetterOmit<DocumentByName<FromSchema<Schema>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentEncodeError | GetByIdFailure | DocumentDecodeError, never>;
|
|
53
54
|
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
55
|
delete: (id: convex_values0.GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
55
56
|
};
|
|
56
|
-
} |
|
|
57
|
+
} | {
|
|
57
58
|
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
59
|
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 | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>
|
|
60
|
+
} | StorageReader$1 | StorageWriter$1 | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>) => Effect.Effect<_confect_core_Ref0.Returns<Query>, effect_ParseResult0.ParseError>), never, never>;
|
|
60
61
|
type MutationServices<Schema extends AnyWithProps> = DatabaseReader<Schema> | DatabaseWriter<Schema> | Auth$1 | Scheduler$1 | StorageReader$1 | StorageWriter$1 | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<Schema>>>;
|
|
61
62
|
//#endregion
|
|
62
63
|
export { MutationServices, RegisteredConvexFunction_d_exports, make, mutationLayer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredConvexFunction.d.ts","names":[],"sources":["../src/RegisteredConvexFunction.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"RegisteredConvexFunction.d.ts","names":[],"sources":["../src/RegisteredConvexFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgCa,IAAA,gBAAqB,uBAAA,YAChC,GAAA,EAAK,IAAA;EACL,YAAA;EAAA;AAAA,GAA2B,cAAA,KAC1B,GAAA;AAAA,cAiIU,aAAA,kBAAgC,YAAA,EAC3C,MAAA,EAAQ,MAAA,EACR,GAAA,EAAK,kBAAA,CAAmB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAAS,KAAA,CAAA,KAAA,CAAA,MAAA,sBAAA,kBAAA,CAAA,WAAA,EAAA,QAAA,EAAA,QAAA,EAAA,IAAA,EAAA,kBAAA,CAAA,IAAA,CAAA,QAAA,MAAA,MAAA,CAAA,MAAA,CAAA,kBAAA,CAAA,OAAA,CAAA,QAAA,GAAA,mBAAA,CAAA,UAAA,KAAA,kBAAA,CAAA,QAAA,CAAA,UAAA,CAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;KAoB/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"}
|
|
@@ -7,7 +7,8 @@ import { layer as layer$2 } from "./DatabaseWriter.js";
|
|
|
7
7
|
import { layer as layer$3 } from "./MutationRunner.js";
|
|
8
8
|
import { layer as layer$4 } from "./QueryRunner.js";
|
|
9
9
|
import { layer as layer$5 } from "./Scheduler.js";
|
|
10
|
-
import { StorageReader as StorageReader$1
|
|
10
|
+
import { StorageReader as StorageReader$1 } from "./StorageReader.js";
|
|
11
|
+
import { StorageWriter as StorageWriter$1 } from "./StorageWriter.js";
|
|
11
12
|
import { MutationCtx } from "./MutationCtx.js";
|
|
12
13
|
import { QueryCtx } from "./QueryCtx.js";
|
|
13
14
|
import { actionFunctionBase, actionLayer } from "./RegisteredFunction.js";
|
|
@@ -19,24 +20,27 @@ var RegisteredConvexFunction_exports = /* @__PURE__ */ __exportAll({
|
|
|
19
20
|
make: () => make,
|
|
20
21
|
mutationLayer: () => mutationLayer
|
|
21
22
|
});
|
|
22
|
-
const make = (api, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
23
|
+
const make = (api, { functionSpec, handler }) => Match.value(functionSpec.functionProvenance).pipe(Match.tag("Convex", () => handler), Match.tag("Confect", () => {
|
|
24
|
+
const { functionVisibility, functionProvenance } = functionSpec;
|
|
25
|
+
return Match.value(functionSpec.runtimeAndFunctionType.functionType).pipe(Match.when("query", () => {
|
|
26
|
+
return Match.value(functionVisibility).pipe(Match.when("public", () => queryGeneric), Match.when("internal", () => internalQueryGeneric), Match.exhaustive)(queryFunction(api.databaseSchema, {
|
|
27
|
+
args: functionProvenance.args,
|
|
28
|
+
returns: functionProvenance.returns,
|
|
29
|
+
handler
|
|
30
|
+
}));
|
|
31
|
+
}), Match.when("mutation", () => {
|
|
32
|
+
return Match.value(functionVisibility).pipe(Match.when("public", () => mutationGeneric), Match.when("internal", () => internalMutationGeneric), Match.exhaustive)(mutationFunction(api.databaseSchema, {
|
|
33
|
+
args: functionProvenance.args,
|
|
34
|
+
returns: functionProvenance.returns,
|
|
35
|
+
handler
|
|
36
|
+
}));
|
|
37
|
+
}), Match.when("action", () => {
|
|
38
|
+
return Match.value(functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(convexActionFunction(api.databaseSchema, {
|
|
39
|
+
args: functionProvenance.args,
|
|
40
|
+
returns: functionProvenance.returns,
|
|
41
|
+
handler
|
|
42
|
+
}));
|
|
43
|
+
}), Match.exhaustive);
|
|
40
44
|
}), Match.exhaustive);
|
|
41
45
|
const queryFunction = (databaseSchema, { args, returns, handler }) => ({
|
|
42
46
|
args: compileArgsSchema(args),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredConvexFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","StorageReader","QueryRunner.layer","QueryCtx.QueryCtx","ConvexConfigProvider.make","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 * as ConvexConfigProvider from \"./ConvexConfigProvider\";\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 Layer.setConfigProvider(ConvexConfigProvider.make()),\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 Layer.setConfigProvider(ConvexConfigProvider.make()),\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) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(schema, ctx),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,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,gB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qB,QAAQ,IAAI,GAAG,EACpCM,QAAqB,QAAQ,IAAI,GAAG,EACpCL,MAAW,IAAI,KAAK,EACpBM,QAAgB,IAAI,UAAU,EAC9BL,gBAAc,MAAM,IAAI,QAAQ,EAChCM,gBAAc,MAAM,IAAI,QAAQ,EAChCL,QAAkB,IAAI,SAAS,EAC/BM,QAAqB,IAAI,YAAY,EACrC,MAAM,QACJC,aAEG,EACH,IACD,EACD,MAAM,kBAAkBL,QAA2B,CAAC,CACrD;AAaH,MAAM,oBAQJ,QACA,EACE,MACA,SACA,eAME;CACJ,MAAMP,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,cAaFY,mBAAsC;CACpC;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,QAAQ,IAAI,EAC3C,MAAM,kBAAkBP,QAA2B,CAAC,CACrD;CACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"RegisteredConvexFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","StorageReader","QueryRunner.layer","QueryCtx.QueryCtx","ConvexConfigProvider.make","DatabaseWriter.layer","Scheduler.layer","StorageWriter","MutationRunner.layer","MutationCtx.MutationCtx","RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredConvexFunction.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport {\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 ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as Handler from \"./Handler\";\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 } from \"./StorageReader\";\nimport { StorageWriter } from \"./StorageWriter\";\n\nexport const make = <Api_ extends Api.AnyWithPropsWithRuntime<\"Convex\">>(\n api: Api_,\n { functionSpec, handler }: RegistryItem.AnyWithProps,\n): RegisteredFunction.Any =>\n Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Convex\", () => handler as RegisteredFunction.Any),\n Match.tag(\"Confect\", () => {\n const { functionVisibility, functionProvenance } =\n functionSpec as FunctionSpec.AnyConfect;\n\n return Match.value(functionSpec.runtimeAndFunctionType.functionType).pipe(\n Match.when(\"query\", () => {\n const genericFunction = Match.value(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: functionProvenance.args,\n returns: functionProvenance.returns,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.when(\"mutation\", () => {\n const genericFunction = Match.value(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: functionProvenance.args,\n returns: functionProvenance.returns,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.when(\"action\", () => {\n const genericFunction = Match.value(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: functionProvenance.args,\n returns: functionProvenance.returns,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.exhaustive,\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 Layer.setConfigProvider(ConvexConfigProvider.make()),\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 Layer.setConfigProvider(ConvexConfigProvider.make()),\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) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(schema, ctx),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,QACX,KACA,EAAE,cAAc,cAEhB,MAAM,MAAM,aAAa,mBAAmB,CAAC,KAC3C,MAAM,IAAI,gBAAgB,QAAkC,EAC5D,MAAM,IAAI,iBAAiB;CACzB,MAAM,EAAE,oBAAoB,uBAC1B;AAEF,QAAO,MAAM,MAAM,aAAa,uBAAuB,aAAa,CAAC,KACnE,MAAM,KAAK,eAAe;AAOxB,SANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gBAAgB,aAAa,EACxC,MAAM,KAAK,kBAAkB,qBAAqB,EAClD,MAAM,WACP,CAGC,cAAc,IAAI,gBAAgB;GAChC,MAAM,mBAAmB;GACzB,S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,IAAI,UAAU,EAC9BL,gBAAc,MAAM,IAAI,QAAQ,EAChCM,gBAAc,MAAM,IAAI,QAAQ,EAChCL,QAAkB,IAAI,SAAS,EAC/BM,QAAqB,IAAI,YAAY,EACrC,MAAM,QACJC,aAEG,EACH,IACD,EACD,MAAM,kBAAkBL,QAA2B,CAAC,CACrD;AAaH,MAAM,oBAQJ,QACA,EACE,MACA,SACA,eAME;CACJ,MAAMP,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,cAaFY,mBAAsC;CACpC;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,QAAQ,IAAI,EAC3C,MAAM,kBAAkBP,QAA2B,CAAC,CACrD;CACJ,CAAC"}
|
|
@@ -6,22 +6,35 @@ import { FromSchema, TableNames, ToConvex } from "./DataModel.js";
|
|
|
6
6
|
import { MutationRunner } from "./MutationRunner.js";
|
|
7
7
|
import { QueryRunner } from "./QueryRunner.js";
|
|
8
8
|
import { Scheduler as Scheduler$1 } from "./Scheduler.js";
|
|
9
|
-
import { StorageActionWriter as StorageActionWriter$1
|
|
9
|
+
import { StorageActionWriter as StorageActionWriter$1 } from "./StorageActionWriter.js";
|
|
10
|
+
import { StorageReader as StorageReader$1 } from "./StorageReader.js";
|
|
11
|
+
import { StorageWriter as StorageWriter$1 } from "./StorageWriter.js";
|
|
10
12
|
import { VectorSearch } from "./VectorSearch.js";
|
|
11
13
|
import { Effect, Layer, Schema } from "effect";
|
|
12
14
|
import * as _confect_core_Ref0 from "@confect/core/Ref";
|
|
13
15
|
import * as convex_server0 from "convex/server";
|
|
14
16
|
import { DefaultFunctionArgs, FunctionVisibility, GenericActionCtx, RegisteredAction, RegisteredMutation, RegisteredQuery } from "convex/server";
|
|
17
|
+
import { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
15
18
|
import * as convex_values0 from "convex/values";
|
|
19
|
+
import * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
20
|
+
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
16
21
|
import * as effect_Duration0 from "effect/Duration";
|
|
17
22
|
import * as effect_DateTime0 from "effect/DateTime";
|
|
18
|
-
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
19
23
|
|
|
20
24
|
//#region src/RegisteredFunction.d.ts
|
|
21
25
|
declare namespace RegisteredFunction_d_exports {
|
|
22
|
-
export { ActionServices, RegisteredFunction, actionFunctionBase, actionLayer };
|
|
26
|
+
export { ActionServices, Any, ConvexRegisteredFunction, RegisteredFunction, actionFunctionBase, actionLayer };
|
|
23
27
|
}
|
|
24
|
-
type
|
|
28
|
+
type Any = RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;
|
|
29
|
+
type ConfectRegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec.EncodedArgs<FunctionSpec_> extends infer Args_ extends DefaultFunctionArgs ? RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "query" ? RegisteredQuery<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "mutation" ? RegisteredMutation<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "action" ? RegisteredAction<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>> : never : never;
|
|
30
|
+
type ConvexRegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends {
|
|
31
|
+
functionProvenance: {
|
|
32
|
+
_tag: "Convex";
|
|
33
|
+
_args: infer Args_ extends DefaultFunctionArgs;
|
|
34
|
+
_returns: infer Returns_;
|
|
35
|
+
};
|
|
36
|
+
} ? RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "query" ? RegisteredQuery<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Returns_> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "mutation" ? RegisteredMutation<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Returns_> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "action" ? RegisteredAction<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Returns_> : never : never;
|
|
37
|
+
type RegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConvex> ? ConvexRegisteredFunction<FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConfect> ? ConfectRegisteredFunction<FunctionSpec_> : never;
|
|
25
38
|
declare const actionFunctionBase: <Schema extends AnyWithProps, Args, ConvexArgs extends DefaultFunctionArgs, Returns, ConvexReturns, E, R>({
|
|
26
39
|
args,
|
|
27
40
|
returns,
|
|
@@ -38,10 +51,10 @@ declare const actionFunctionBase: <Schema extends AnyWithProps, Args, ConvexArgs
|
|
|
38
51
|
handler: (ctx: GenericActionCtx<ToConvex<FromSchema<Schema>>>, actualArgs: ConvexArgs) => Promise<ConvexReturns>;
|
|
39
52
|
};
|
|
40
53
|
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<(<
|
|
54
|
+
declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<Auth$1 | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>, effect_ParseResult0.ParseError>) | StorageActionWriter$1 | {
|
|
42
55
|
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
56
|
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 | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>
|
|
57
|
+
} | StorageReader$1 | StorageWriter$1 | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>) => Effect.Effect<_confect_core_Ref0.Returns<Query>, effect_ParseResult0.ParseError>) | GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>> | (<Action extends _confect_core_Ref0.AnyAction>(action: Action, args: _confect_core_Ref0.Args<Action>) => Effect.Effect<_confect_core_Ref0.Returns<Action>, effect_ParseResult0.ParseError>) | (<TableName extends TableNames<FromSchema<DatabaseSchema_>>, IndexName extends keyof convex_server0.VectorIndexes<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>>(tableName: TableName, indexName: IndexName, query: {
|
|
45
58
|
vector: number[];
|
|
46
59
|
limit?: number;
|
|
47
60
|
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>;
|
|
@@ -50,5 +63,5 @@ declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema
|
|
|
50
63
|
_score: number;
|
|
51
64
|
}[], never, never>), never, never>;
|
|
52
65
|
//#endregion
|
|
53
|
-
export { ActionServices, RegisteredFunction, RegisteredFunction_d_exports, actionFunctionBase, actionLayer };
|
|
66
|
+
export { ActionServices, Any, ConvexRegisteredFunction, RegisteredFunction, RegisteredFunction_d_exports, actionFunctionBase, actionLayer };
|
|
54
67
|
//# sourceMappingURL=RegisteredFunction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunction.d.ts","names":[],"sources":["../src/RegisteredFunction.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"RegisteredFunction.d.ts","names":[],"sources":["../src/RegisteredFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;KAyBY,GAAA,GACR,eAAA,CAAgB,kBAAA,EAAoB,mBAAA,SACpC,kBAAA,CAAmB,kBAAA,EAAoB,mBAAA,SACvC,gBAAA,CAAiB,kBAAA,EAAoB,mBAAA;AAA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compileReturnsSchema } from "./SchemaToValidator.js"
|
|
|
6
6
|
import { layer as layer$2 } from "./MutationRunner.js";
|
|
7
7
|
import { layer as layer$3 } from "./QueryRunner.js";
|
|
8
8
|
import { layer as layer$4 } from "./Scheduler.js";
|
|
9
|
-
import { StorageActionWriter as StorageActionWriter$1
|
|
9
|
+
import { StorageActionWriter as StorageActionWriter$1 } from "./StorageActionWriter.js";
|
|
10
|
+
import { StorageReader as StorageReader$1 } from "./StorageReader.js";
|
|
11
|
+
import { StorageWriter as StorageWriter$1 } from "./StorageWriter.js";
|
|
10
12
|
import { layer as layer$5 } from "./VectorSearch.js";
|
|
11
13
|
import { Effect, Layer, Schema, pipe } from "effect";
|
|
12
14
|
import "convex/server";
|
|
@@ -1 +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
|
|
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 type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport type * as FunctionProvenance from \"@confect/core/FunctionProvenance\";\nimport {\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 } from \"./StorageActionWriter\";\nimport { StorageReader } from \"./StorageReader\";\nimport { StorageWriter } from \"./StorageWriter\";\nimport * as VectorSearch from \"./VectorSearch\";\n\nexport type Any =\n | RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;\n\ntype ConfectRegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec.EncodedArgs<FunctionSpec_> extends infer Args_ extends\n DefaultFunctionArgs\n ? RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"query\"\n ? RegisteredQuery<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"mutation\"\n ? RegisteredMutation<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"action\"\n ? RegisteredAction<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : never\n : never;\n\nexport type ConvexRegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> = FunctionSpec_ extends {\n functionProvenance: {\n _tag: \"Convex\";\n _args: infer Args_ extends DefaultFunctionArgs;\n _returns: infer Returns_;\n };\n}\n ? RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"query\"\n ? RegisteredQuery<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"mutation\"\n ? RegisteredMutation<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"action\"\n ? RegisteredAction<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : never\n : never;\n\nexport type RegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRegisteredFunction<FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRegisteredFunction<FunctionSpec_>\n : never;\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":";;;;;;;;;;;;;;;;;;;;AAiHA,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"}
|