@gaganref/confect-server 10.3.1-fork.25 → 10.3.1-fork.27
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/dist/ActionCall.d.ts +30 -0
- package/dist/ActionCall.d.ts.map +1 -0
- package/dist/ActionCall.js +41 -0
- package/dist/ActionCall.js.map +1 -0
- package/dist/ActionRunner.js +2 -2
- package/dist/AiGatewayDecisionClient.js +1 -1
- package/dist/AiGatewayLanguageClient.js +1 -1
- package/dist/Auth.js +1 -1
- package/dist/Callback.js +3 -3
- package/dist/ConvexConfigProvider.js +2 -2
- package/dist/ConvexFunctionDefinitions.js +2 -2
- package/dist/ConvexLogger.js +1 -1
- package/dist/CronJobs.js +6 -6
- package/dist/DatabaseSchema.js +2 -2
- package/dist/DatabaseWriter.d.ts +36 -2
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +33 -6
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/ExecutionMetadata.js +1 -1
- package/dist/FunctionImpl.js +2 -2
- package/dist/FunctionRegistryItem.js +1 -1
- package/dist/GroupImpl.js +5 -5
- package/dist/Handler.d.ts +7 -3
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js.map +1 -1
- package/dist/HttpRouter.js +2 -2
- package/dist/MiddlewareImpl.js +1 -1
- package/dist/MutationRunner.js +2 -2
- package/dist/MutationTransactionContext.js +2 -2
- package/dist/QueryInitializer.js +2 -2
- package/dist/QueryRunner.js +2 -2
- package/dist/QueryStream.js +3 -3
- package/dist/QueryStreamCursor.js +1 -1
- package/dist/QueryStreamIndexPrefix.js +1 -1
- package/dist/QueryStreamIndexRange.js +2 -2
- package/dist/QueryStreamKey.js +1 -1
- package/dist/QueryStreamKeyBounds.js +2 -2
- package/dist/QueryStreamKeyLayout.js +2 -2
- package/dist/QueryStreamKeyValues.js +1 -1
- package/dist/QueryStreamPagination.js +1 -1
- package/dist/QueryStreamReadBudget.js +2 -2
- package/dist/QueryTransactionContext.js +2 -2
- package/dist/RegisteredConvexFunction.js +19 -19
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +55 -13
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredNodeFunction.js +1 -1
- package/dist/RegistryItems.js +1 -1
- package/dist/RequestMetadata.js +1 -1
- package/dist/Scheduler.js +2 -2
- package/dist/Storage.js +1 -1
- package/dist/StorageActionWriter.js +1 -1
- package/dist/StorageReader.js +1 -1
- package/dist/StorageWriter.js +1 -1
- package/dist/TransactionMetadata.js +1 -1
- package/dist/VectorSearch.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/internal/AiGatewayDecisionClient.js +1 -1
- package/dist/internal/AiGatewayLanguageClient.js +1 -1
- package/dist/internal/AiGatewayServiceToken.js +1 -1
- package/dist/internal/DocumentPatch.js +1 -1
- package/package.json +2 -2
- package/src/ActionCall.ts +82 -0
- package/src/DatabaseWriter.ts +90 -5
- package/src/Handler.ts +20 -5
- package/src/RegisteredFunction.ts +54 -1
- package/src/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunction.js","names":["ConvexLogger.layer","Scheduler.layer","Auth.layer","ExecutionMetadata.layer","RequestMetadata.layer","Storage.layer","QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","ActionCtx.ActionCtx","Auth.layerForTarget","ActionCtx.layer","VectorSearch.layer"],"sources":["../src/RegisteredFunction.ts"],"sourcesContent":["import type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport * as IdScope from \"@confect/core/IdScope\";\nimport type * as FunctionProvenance from \"@confect/core/FunctionProvenance\";\nimport * as MiddlewareSpec from \"@confect/core/MiddlewareSpec\";\nimport {\n compileArgsSchema,\n compileReturnsSchema,\n} from \"@confect/core/SchemaToValidator\";\nimport {\n type DefaultFunctionArgs,\n type FunctionVisibility,\n type GenericActionCtx,\n type GenericDataModel,\n type StorageReader as ConvexStorageReader,\n type RegisteredAction,\n type RegisteredMutation,\n type RegisteredQuery,\n} from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Console from \"effect/Console\";\nimport * as Effect from \"effect/Effect\";\nimport * as Result from \"effect/Result\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport type * as EffectScheduler from \"effect/Scheduler\";\nimport * as ActionCtx from \"./ActionCtx.js\";\nimport * as ActionRunner from \"./ActionRunner.js\";\nimport * as Auth from \"./Auth.js\";\nimport * as ConvexLogger from \"./ConvexLogger.js\";\nimport type * as DatabaseSchema from \"./DatabaseSchema.js\";\nimport type * as DataModel from \"./DataModel.js\";\nimport * as ExecutionMetadata from \"./ExecutionMetadata.js\";\nimport * as RequestMetadata from \"./RequestMetadata.js\";\nimport * as MutationRunner from \"./MutationRunner.js\";\nimport * as QueryRunner from \"./QueryRunner.js\";\nimport type * as ResolvedMiddleware from \"./ResolvedMiddleware.js\";\nimport * as Scheduler from \"./Scheduler.js\";\nimport * as Storage from \"./Storage.js\";\nimport * as StorageActionWriter from \"./StorageActionWriter.js\";\nimport type * as StorageReader from \"./StorageReader.js\";\nimport * as StorageWriter from \"./StorageWriter.js\";\nimport * as VectorSearch from \"./VectorSearch.js\";\nimport type * as Handler from \"./Handler.js\";\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 FunctionSpec.AnyWithProps\n ? FunctionSpec.GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n infer Args_ extends DefaultFunctionArgs,\n infer Returns_\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 : 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\n/**\n * Wrap a function's handler effect in its resolved middleware chain, per\n * invocation, after args decode. Iterated innermost-first so that the\n * first-attached (group-level, in attachment order) middleware ends up\n * outermost and runs first. Erased types: the public safety story lives at the\n * `MiddlewareSpec.MiddlewareImpl`/`MiddlewareImpl.make` signatures, and the\n * composed effect's error channel is re-accounted by\n * {@link combineErrorSchemas}.\n */\nexport const applyMiddleware = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>,\n invocation: MiddlewareSpec.MiddlewareOptions[\"invocation\"],\n): Effect.Effect<A, any, R> => {\n return resolvedMiddlewares.reduceRight<Effect.Effect<any, any, any>>(\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- The erased middleware error remains intact so runHandlerPromise can validate it against the combined error schema.\n (wrapped, middleware) => {\n const context =\n \"options\" in middleware.middlewareSpec\n ? { options: middleware.options, invocation }\n : { invocation };\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- Resolved middleware is type-erased after its public implementation boundary; its error and service channels are restored by the surrounding function contract.\n return middleware.middlewareImpl(wrapped, context);\n },\n effect,\n );\n};\n\n/**\n * The error-schema allowlist for a function with middleware: the function's own\n * declared `error` schema unioned with every covering middleware's error\n * schema. `undefined` (⇒ every failure dies) only when neither declares\n * one—mirroring the ref-side union clients decode against.\n */\nexport const combineErrorSchemas = (\n error: Schema.Codec<any, any> | undefined,\n resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>,\n): Schema.Codec<any, any> | undefined => {\n const schemas = [\n ...(error !== undefined ? [error] : []),\n ...MiddlewareSpec.errorSchemas(\n resolvedMiddlewares.map(({ middlewareSpec }) => middlewareSpec),\n ),\n ];\n return schemas.length === 0\n ? undefined\n : schemas.length === 1\n ? schemas[0]\n : Schema.Union(schemas);\n};\n\n/**\n * Run the `Effect` as a `Promise`. The error schema acts as an allowlist of\n * failures that may be surfaced to the client as a `ConvexError`:\n *\n * - With a schema: typed errors are schema-encoded and wrapped in a\n * `ConvexError`, then thrown so Convex surfaces the data to the client.\n * `Effect.either` escapes the failure channel before `runPromise` so the\n * thrown `ConvexError` retains its `Symbol.for(\"ConvexError\")` identity\n * instead of being wrapped in Effect's `FiberFailure`.\n * - Without a schema: every failure is converted to a defect via `Effect.orDie`,\n * so nothing—not even a `ConvexError` the handler placed in its error\n * channel—reaches the client as a `ConvexError`. The fiber dies and\n * `runPromise` rejects with a generic failure.\n *\n * Either way, a `ConvexError` _defect_—thrown imperatively rather than placed\n * in the error channel, e.g. the pagination protocol's `InvalidCursor` signal\n * from `QueryStream.paginate`—is rethrown bare so it retains its identity and\n * Convex serializes its `data` to the client, matching how a thrown\n * `ConvexError` behaves in a plain Convex handler.\n *\n * A `scheduler` in `runOptions` must be passed here as a run option rather than\n * provided via `Effect.provideService` inside `effect`: the run option lands in\n * the fiber's root context, while a service provided within `effect` pops\n * before the `orDie`/`catch`/`result` wrappers this function adds. The fiber's\n * op counter survives context pops, so a cooperative yield can fire inside\n * those wrappers—only a root-context scheduler covers them.\n */\nexport const runHandlerPromise =\n (\n errorSchema: Schema.Codec<any, any> | undefined,\n runOptions?: {\n readonly scheduler?: EffectScheduler.Scheduler | undefined;\n },\n ) =>\n <A, E>(effect: Effect.Effect<A, E>): Promise<A> => {\n // A `ConvexError` defect escapes into the (escaped) failure channel so\n // the `throw` below rethrows it with its identity intact.\n const rethrowConvexErrorDefects = Effect.catchDefect(\n (defect: unknown): Effect.Effect<never, ConvexError<any>> =>\n defect instanceof ConvexError\n ? Effect.fail(defect)\n : Effect.die(defect),\n );\n\n const withConvexError =\n errorSchema === undefined\n ? Effect.orDie(effect)\n : effect.pipe(\n Effect.catch((typedError) =>\n pipe(\n Schema.encodeEffect(errorSchema)(typedError),\n Effect.catchTag(\"SchemaError\", Effect.die),\n Effect.andThen((encodedError) =>\n Effect.fail(new ConvexError(encodedError)),\n ),\n ),\n ),\n );\n return Effect.runPromise(\n Effect.result(rethrowConvexErrorDefects(withConvexError)).pipe(\n Effect.provide(ConvexLogger.layer),\n Effect.provideService(Console.Console, globalThis.console),\n ),\n runOptions,\n ).then(\n Result.match({\n onFailure: (error) => {\n throw error;\n },\n onSuccess: (value) => value,\n }),\n );\n };\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 name,\n functionVisibility,\n args,\n returns,\n error,\n handler,\n resolvedMiddlewares = [],\n createLayer,\n scope = IdScope.app,\n}: {\n name: string;\n functionVisibility: FunctionVisibility;\n args: Schema.Codec<Args, ConvexArgs>;\n returns: Schema.Codec<Returns, ConvexReturns>;\n error: Schema.Codec<Error, Value> | undefined;\n handler: (a: Args) => Effect.Effect<Returns, E, R>;\n resolvedMiddlewares?: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>;\n createLayer: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n ) => Layer.Layer<R>;\n scope?: IdScope.IdScope;\n}) => ({\n args: compileArgsSchema(args, scope),\n returns: compileReturnsSchema(returns, scope),\n handler: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decodeUnknownEffect(args),\n Effect.catchTag(\"SchemaError\", Effect.die),\n );\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- Middleware errors are intentionally erased here and validated by runHandlerPromise against the combined error schema below.\n const decodedReturns = yield* applyMiddleware(\n handler(decodedArgs),\n resolvedMiddlewares,\n {\n name,\n functionType: \"action\",\n functionVisibility,\n args: decodedArgs,\n },\n ).pipe(Effect.provide(createLayer(ctx)));\n return yield* pipe(\n decodedReturns,\n Schema.encodeEffect(returns),\n Effect.catchTag(\"SchemaError\", Effect.die),\n );\n }).pipe(runHandlerPromise(combineErrorSchemas(error, resolvedMiddlewares))),\n});\n\nexport type ActionServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> = Handler.ActionServices<DatabaseSchema_>;\n\n/**\n * The ctx-backed action services that don't depend on a Confect database\n * schema. {@link actionLayer} adds the schema-typed `VectorSearch` on top; the\n * HTTP API handler uses this base directly.\n */\nexport const baseActionLayer = <ConvexDataModel extends GenericDataModel>(\n ctx: GenericActionCtx<ConvexDataModel>,\n) =>\n Layer.mergeAll(\n Scheduler.layer(ctx.scheduler),\n Auth.layer(ctx.auth),\n ExecutionMetadata.layer(ctx.meta),\n RequestMetadata.layer(ctx.meta),\n Storage.layer(ctx.storage),\n StorageWriter.StorageWriter.layer(ctx.storage),\n StorageActionWriter.StorageActionWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery.bind(ctx)),\n MutationRunner.layer(ctx.runMutation.bind(ctx)),\n ActionRunner.layer(ctx.runAction.bind(ctx)),\n Layer.succeed(ActionCtx.ActionCtx<ConvexDataModel>(), ctx),\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<DatabaseSchema.Scope<DatabaseSchema_>>(\n ctx.scheduler,\n databaseSchema.target.scope,\n ),\n Auth.layerForTarget<DatabaseSchema_[\"target\"]>(\n databaseSchema.target,\n ctx.auth,\n ),\n ExecutionMetadata.layer(ctx.meta),\n RequestMetadata.layer(ctx.meta),\n storageLayer<DatabaseSchema.Scope<DatabaseSchema_>>(ctx.storage),\n StorageWriter.StorageWriter.layer<DatabaseSchema.Scope<DatabaseSchema_>>(\n ctx.storage,\n databaseSchema.target.scope,\n ),\n StorageActionWriter.StorageActionWriter.layer<\n DatabaseSchema.Scope<DatabaseSchema_>\n >(ctx.storage, databaseSchema.target.scope),\n QueryRunner.layer(ctx.runQuery.bind(ctx)),\n MutationRunner.layer(ctx.runMutation.bind(ctx)),\n ActionRunner.layer(ctx.runAction.bind(ctx)),\n ActionCtx.layer<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>,\n DatabaseSchema.Scope<DatabaseSchema_>\n >(ctx, databaseSchema.target.scope),\n VectorSearch.layer(ctx.vectorSearch.bind(ctx)),\n );\n\n// Scoped readers share the same runtime service and ID strings. Reuse the\n// reader supplied by Storage so both APIs keep the same reader instance.\nexport const storageLayer = <Scope extends IdScope.IdScope>(\n reader: ConvexStorageReader,\n): Layer.Layer<Storage.Storage | StorageReader.ForScope<Scope>> =>\n Storage.layer(reader) as Layer.Layer<\n Storage.Storage | StorageReader.ForScope<Scope>\n >;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8IA,MAAa,mBACX,QACA,qBACA,eAC6B;CAC7B,OAAO,oBAAoB,aAExB,SAAS,eAAe;EACvB,MAAM,UACJ,aAAa,WAAW,iBACpB;GAAE,SAAS,WAAW;GAAS;EAAW,IAC1C,EAAE,WAAW;EAEnB,OAAO,WAAW,eAAe,SAAS,OAAO;CACnD,GACA,MACF;AACF;;;;;;;AAQA,MAAa,uBACX,OACA,wBACuC;CACvC,MAAM,UAAU,CACd,GAAI,UAAU,KAAA,IAAY,CAAC,KAAK,IAAI,CAAC,GACrC,GAAG,eAAe,aAChB,oBAAoB,KAAK,EAAE,qBAAqB,cAAc,CAChE,CACF;CACA,OAAO,QAAQ,WAAW,IACtB,KAAA,IACA,QAAQ,WAAW,IACjB,QAAQ,KACR,OAAO,MAAM,OAAO;AAC5B;;;;;;;;;;;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AAC,CAAC,KAAK,kBAAkB,oBAAoB,OAAO,mBAAmB,CAAC,CAAC;AAC9E;;;;;;AAWA,MAAa,mBACX,QAEA,MAAM,SACJC,QAAgB,IAAI,SAAS,GAC7BC,QAAW,IAAI,IAAI,GACnBC,QAAwB,IAAI,IAAI,GAChCC,QAAsB,IAAI,IAAI,GAC9BC,QAAc,IAAI,OAAO,GAAA,cACG,MAAM,IAAI,OAAO,GAAA,oBACL,MAAM,IAAI,OAAO,GACzDC,QAAkB,IAAI,SAAS,KAAK,GAAG,CAAC,GACxCC,QAAqB,IAAI,YAAY,KAAK,GAAG,CAAC,GAC9CC,QAAmB,IAAI,UAAU,KAAK,GAAG,CAAC,GAC1C,MAAM,QAAQC,UAAqC,GAAG,GAAG,CAC3D;AAEF,MAAa,eAGX,gBACA,QAIA,MAAM,SACJR,QACE,IAAI,WACJ,eAAe,OAAO,KACxB,GACAS,eACE,eAAe,QACf,IAAI,IACN,GACAP,QAAwB,IAAI,IAAI,GAChCC,QAAsB,IAAI,IAAI,GAC9B,aAAoD,IAAI,OAAO,GAAA,cACnC,MAC1B,IAAI,SACJ,eAAe,OAAO,KACxB,GAAA,oBACwC,MAEtC,IAAI,SAAS,eAAe,OAAO,KAAK,GAC1CE,QAAkB,IAAI,SAAS,KAAK,GAAG,CAAC,GACxCC,QAAqB,IAAI,YAAY,KAAK,GAAG,CAAC,GAC9CC,QAAmB,IAAI,UAAU,KAAK,GAAG,CAAC,GAC1CG,MAGE,KAAK,eAAe,OAAO,KAAK,GAClCC,SAAmB,IAAI,aAAa,KAAK,GAAG,CAAC,CAC/C;AAIF,MAAa,gBACX,WAEAP,QAAc,MAAM"}
|
|
1
|
+
{"version":3,"file":"RegisteredFunction.js","names":["ConvexLogger.layer","Scheduler.layer","Auth.layer","ExecutionMetadata.layer","RequestMetadata.layer","Storage.layer","QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","ActionCtx.ActionCtx","Auth.layerForTarget","ActionCtx.layer","VectorSearch.layer","ActionCall.ActionCallAlreadyUsed","ActionCall.SchedulingNotAllowed","ActionCall.NestedActionNotAllowed","ActionCall.ActionCallNotUsed"],"sources":["../src/RegisteredFunction.ts"],"sourcesContent":["import * as ActionCallSpec from \"@confect/core/ActionCall\";\nimport * as ActionCall from \"./ActionCall.js\";\nimport type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport * as IdScope from \"@confect/core/IdScope\";\nimport type * as FunctionProvenance from \"@confect/core/FunctionProvenance\";\nimport * as MiddlewareSpec from \"@confect/core/MiddlewareSpec\";\nimport {\n compileArgsSchema,\n compileReturnsSchema,\n} from \"@confect/core/SchemaToValidator\";\nimport {\n type DefaultFunctionArgs,\n type FunctionVisibility,\n type GenericActionCtx,\n type GenericDataModel,\n type StorageReader as ConvexStorageReader,\n type RegisteredAction,\n type RegisteredMutation,\n type RegisteredQuery,\n} from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Console from \"effect/Console\";\nimport * as Effect from \"effect/Effect\";\nimport * as Result from \"effect/Result\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport type * as EffectScheduler from \"effect/Scheduler\";\nimport * as ActionCtx from \"./ActionCtx.js\";\nimport * as ActionRunner from \"./ActionRunner.js\";\nimport * as Auth from \"./Auth.js\";\nimport * as ConvexLogger from \"./ConvexLogger.js\";\nimport type * as DatabaseSchema from \"./DatabaseSchema.js\";\nimport type * as DataModel from \"./DataModel.js\";\nimport * as ExecutionMetadata from \"./ExecutionMetadata.js\";\nimport * as RequestMetadata from \"./RequestMetadata.js\";\nimport * as MutationRunner from \"./MutationRunner.js\";\nimport * as QueryRunner from \"./QueryRunner.js\";\nimport type * as ResolvedMiddleware from \"./ResolvedMiddleware.js\";\nimport * as Scheduler from \"./Scheduler.js\";\nimport * as Storage from \"./Storage.js\";\nimport * as StorageActionWriter from \"./StorageActionWriter.js\";\nimport type * as StorageReader from \"./StorageReader.js\";\nimport * as StorageWriter from \"./StorageWriter.js\";\nimport * as VectorSearch from \"./VectorSearch.js\";\nimport type * as Handler from \"./Handler.js\";\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 FunctionSpec.AnyWithProps\n ? FunctionSpec.GetFunctionProvenance<FunctionSpec_> extends FunctionProvenance.Convex<\n infer Args_ extends DefaultFunctionArgs,\n infer Returns_\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 : 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\n/**\n * Wrap a function's handler effect in its resolved middleware chain, per\n * invocation, after args decode. Iterated innermost-first so that the\n * first-attached (group-level, in attachment order) middleware ends up\n * outermost and runs first. Erased types: the public safety story lives at the\n * `MiddlewareSpec.MiddlewareImpl`/`MiddlewareImpl.make` signatures, and the\n * composed effect's error channel is re-accounted by\n * {@link combineErrorSchemas}.\n */\nexport const applyMiddleware = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>,\n invocation: MiddlewareSpec.MiddlewareOptions[\"invocation\"],\n): Effect.Effect<A, any, R> => {\n return resolvedMiddlewares.reduceRight<Effect.Effect<any, any, any>>(\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- The erased middleware error remains intact so runHandlerPromise can validate it against the combined error schema.\n (wrapped, middleware) => {\n const context =\n \"options\" in middleware.middlewareSpec\n ? { options: middleware.options, invocation }\n : { invocation };\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- Resolved middleware is type-erased after its public implementation boundary; its error and service channels are restored by the surrounding function contract.\n return middleware.middlewareImpl(wrapped, context);\n },\n effect,\n );\n};\n\n/**\n * The error-schema allowlist for a function with middleware: the function's own\n * declared `error` schema unioned with every covering middleware's error\n * schema. `undefined` (⇒ every failure dies) only when neither declares\n * one—mirroring the ref-side union clients decode against.\n */\nexport const combineErrorSchemas = (\n error: Schema.Codec<any, any> | undefined,\n resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>,\n): Schema.Codec<any, any> | undefined => {\n const schemas = [\n ...(error !== undefined ? [error] : []),\n ...MiddlewareSpec.errorSchemas(\n resolvedMiddlewares.map(({ middlewareSpec }) => middlewareSpec),\n ),\n ];\n return schemas.length === 0\n ? undefined\n : schemas.length === 1\n ? schemas[0]\n : Schema.Union(schemas);\n};\n\n/**\n * Run the `Effect` as a `Promise`. The error schema acts as an allowlist of\n * failures that may be surfaced to the client as a `ConvexError`:\n *\n * - With a schema: typed errors are schema-encoded and wrapped in a\n * `ConvexError`, then thrown so Convex surfaces the data to the client.\n * `Effect.either` escapes the failure channel before `runPromise` so the\n * thrown `ConvexError` retains its `Symbol.for(\"ConvexError\")` identity\n * instead of being wrapped in Effect's `FiberFailure`.\n * - Without a schema: every failure is converted to a defect via `Effect.orDie`,\n * so nothing—not even a `ConvexError` the handler placed in its error\n * channel—reaches the client as a `ConvexError`. The fiber dies and\n * `runPromise` rejects with a generic failure.\n *\n * Either way, a `ConvexError` _defect_—thrown imperatively rather than placed\n * in the error channel, e.g. the pagination protocol's `InvalidCursor` signal\n * from `QueryStream.paginate`—is rethrown bare so it retains its identity and\n * Convex serializes its `data` to the client, matching how a thrown\n * `ConvexError` behaves in a plain Convex handler.\n *\n * A `scheduler` in `runOptions` must be passed here as a run option rather than\n * provided via `Effect.provideService` inside `effect`: the run option lands in\n * the fiber's root context, while a service provided within `effect` pops\n * before the `orDie`/`catch`/`result` wrappers this function adds. The fiber's\n * op counter survives context pops, so a cooperative yield can fire inside\n * those wrappers—only a root-context scheduler covers them.\n */\nexport const runHandlerPromise =\n (\n errorSchema: Schema.Codec<any, any> | undefined,\n runOptions?: {\n readonly scheduler?: EffectScheduler.Scheduler | undefined;\n },\n ) =>\n <A, E>(effect: Effect.Effect<A, E>): Promise<A> => {\n // A `ConvexError` defect escapes into the (escaped) failure channel so\n // the `throw` below rethrows it with its identity intact.\n const rethrowConvexErrorDefects = Effect.catchDefect(\n (defect: unknown): Effect.Effect<never, ConvexError<any>> =>\n defect instanceof ConvexError\n ? Effect.fail(defect)\n : Effect.die(defect),\n );\n\n const withConvexError =\n errorSchema === undefined\n ? Effect.orDie(effect)\n : effect.pipe(\n Effect.catch((typedError) =>\n pipe(\n Schema.encodeEffect(errorSchema)(typedError),\n Effect.catchTag(\"SchemaError\", Effect.die),\n Effect.andThen((encodedError) =>\n Effect.fail(new ConvexError(encodedError)),\n ),\n ),\n ),\n );\n return Effect.runPromise(\n Effect.result(rethrowConvexErrorDefects(withConvexError)).pipe(\n Effect.provide(ConvexLogger.layer),\n Effect.provideService(Console.Console, globalThis.console),\n ),\n runOptions,\n ).then(\n Result.match({\n onFailure: (error) => {\n throw error;\n },\n onSuccess: (value) => value,\n }),\n );\n };\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 name,\n functionVisibility,\n args,\n returns,\n error,\n handler,\n resolvedMiddlewares = [],\n createLayer,\n scope = IdScope.app,\n}: {\n name: string;\n functionVisibility: FunctionVisibility;\n args: Schema.Codec<Args, ConvexArgs>;\n returns: Schema.Codec<Returns, ConvexReturns>;\n error: Schema.Codec<Error, Value> | undefined;\n handler: (a: Args) => Effect.Effect<Returns, E, R>;\n resolvedMiddlewares?: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>;\n createLayer: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n ) => Layer.Layer<R>;\n scope?: IdScope.IdScope;\n}) => ({\n args: compileArgsSchema(args, scope),\n returns: compileReturnsSchema(returns, scope),\n handler: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decodeUnknownEffect(args),\n Effect.catchTag(\"SchemaError\", Effect.die),\n );\n const restricted = resolvedMiddlewares.some(\n ({ middlewareSpec }) =>\n middlewareSpec.key === ActionCallSpec.Middleware.key,\n )\n ? restrict(ctx)\n : undefined;\n // oxlint-disable-next-line effecttsgo/any-unknown-in-error-context -- Middleware errors are intentionally erased here and validated by runHandlerPromise against the combined error schema below.\n const decodedReturns = yield* applyMiddleware(\n handler(decodedArgs),\n resolvedMiddlewares,\n {\n name,\n functionType: \"action\",\n functionVisibility,\n args: decodedArgs,\n },\n ).pipe(Effect.provide(createLayer(restricted?.ctx ?? ctx)));\n if (restricted !== undefined) yield* restricted.check;\n return yield* pipe(\n decodedReturns,\n Schema.encodeEffect(returns),\n Effect.catchTag(\"SchemaError\", Effect.die),\n );\n }).pipe(runHandlerPromise(combineErrorSchemas(error, resolvedMiddlewares))),\n});\n\nexport type ActionServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> = Handler.ActionServices<DatabaseSchema_>;\n\n/**\n * The ctx-backed action services that don't depend on a Confect database\n * schema. {@link actionLayer} adds the schema-typed `VectorSearch` on top; the\n * HTTP API handler uses this base directly.\n */\nexport const baseActionLayer = <ConvexDataModel extends GenericDataModel>(\n ctx: GenericActionCtx<ConvexDataModel>,\n) =>\n Layer.mergeAll(\n Scheduler.layer(ctx.scheduler),\n Auth.layer(ctx.auth),\n ExecutionMetadata.layer(ctx.meta),\n RequestMetadata.layer(ctx.meta),\n Storage.layer(ctx.storage),\n StorageWriter.StorageWriter.layer(ctx.storage),\n StorageActionWriter.StorageActionWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery.bind(ctx)),\n MutationRunner.layer(ctx.runMutation.bind(ctx)),\n ActionRunner.layer(ctx.runAction.bind(ctx)),\n Layer.succeed(ActionCtx.ActionCtx<ConvexDataModel>(), ctx),\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<DatabaseSchema.Scope<DatabaseSchema_>>(\n ctx.scheduler,\n databaseSchema.target.scope,\n ),\n Auth.layerForTarget<DatabaseSchema_[\"target\"]>(\n databaseSchema.target,\n ctx.auth,\n ),\n ExecutionMetadata.layer(ctx.meta),\n RequestMetadata.layer(ctx.meta),\n storageLayer<DatabaseSchema.Scope<DatabaseSchema_>>(ctx.storage),\n StorageWriter.StorageWriter.layer<DatabaseSchema.Scope<DatabaseSchema_>>(\n ctx.storage,\n databaseSchema.target.scope,\n ),\n StorageActionWriter.StorageActionWriter.layer<\n DatabaseSchema.Scope<DatabaseSchema_>\n >(ctx.storage, databaseSchema.target.scope),\n QueryRunner.layer(ctx.runQuery.bind(ctx)),\n MutationRunner.layer(ctx.runMutation.bind(ctx)),\n ActionRunner.layer(ctx.runAction.bind(ctx)),\n ActionCtx.layer<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>,\n DatabaseSchema.Scope<DatabaseSchema_>\n >(ctx, databaseSchema.target.scope),\n VectorSearch.layer(ctx.vectorSearch.bind(ctx)),\n );\n\n// Scoped readers share the same runtime service and ID strings. Reuse the\n// reader supplied by Storage so both APIs keep the same reader instance.\nexport const storageLayer = <Scope extends IdScope.IdScope>(\n reader: ConvexStorageReader,\n): Layer.Layer<Storage.Storage | StorageReader.ForScope<Scope>> =>\n Storage.layer(reader) as Layer.Layer<\n Storage.Storage | StorageReader.ForScope<Scope>\n >;\n\n/**\n * Shares one dispatch budget across the entire middleware chain.\n */\nconst restrict = <Model extends GenericDataModel>(\n ctx: GenericActionCtx<Model>,\n) => {\n let dispatched = false;\n const claim = () => {\n if (dispatched) throw new ActionCall.ActionCallAlreadyUsed();\n dispatched = true;\n };\n const restricted: GenericActionCtx<Model> = {\n ...ctx,\n scheduler: {\n runAfter: () => {\n throw new ActionCall.SchedulingNotAllowed();\n },\n runAt: () => {\n throw new ActionCall.SchedulingNotAllowed();\n },\n cancel: () => {\n throw new ActionCall.SchedulingNotAllowed();\n },\n },\n runQuery: (...args) => {\n claim();\n return ctx.runQuery(...args);\n },\n runMutation: (...args) => {\n claim();\n return ctx.runMutation(...args);\n },\n runAction: () => {\n throw new ActionCall.NestedActionNotAllowed();\n },\n };\n return {\n ctx: restricted,\n check: Effect.suspend(() =>\n dispatched ? Effect.void : Effect.die(new ActionCall.ActionCallNotUsed()),\n ),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgJA,MAAa,mBACX,QACA,qBACA,eAC6B;CAC7B,OAAO,oBAAoB,aAExB,SAAS,eAAe;EACvB,MAAM,UACJ,aAAa,WAAW,iBACpB;GAAE,SAAS,WAAW;GAAS;EAAW,IAC1C,EAAE,WAAW;EAEnB,OAAO,WAAW,eAAe,SAAS,OAAO;CACnD,GACA,MACF;AACF;;;;;;;AAQA,MAAa,uBACX,OACA,wBACuC;CACvC,MAAM,UAAU,CACd,GAAI,UAAU,KAAA,IAAY,CAAC,KAAK,IAAI,CAAC,GACrC,GAAG,eAAe,aAChB,oBAAoB,KAAK,EAAE,qBAAqB,cAAc,CAChE,CACF;CACA,OAAO,QAAQ,WAAW,IACtB,KAAA,IACA,QAAQ,WAAW,IACjB,QAAQ,KACR,OAAO,MAAM,OAAO;AAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,qBAET,aACA,gBAIK,WAA4C;CAGjD,MAAM,4BAA4B,OAAO,aACtC,WACC,kBAA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zBL,GAAG;GACH,WAAW;IACT,gBAAgB;KACd,MAAM,IAAIC,qBAAgC;IAC5C;IACA,aAAa;KACX,MAAM,IAAIA,qBAAgC;IAC5C;IACA,cAAc;KACZ,MAAM,IAAIA,qBAAgC;IAC5C;GACF;GACA,WAAW,GAAG,SAAS;IACrB,MAAM;IACN,OAAO,IAAI,SAAS,GAAG,IAAI;GAC7B;GACA,cAAc,GAAG,SAAS;IACxB,MAAM;IACN,OAAO,IAAI,YAAY,GAAG,IAAI;GAChC;GACA,iBAAiB;IACf,MAAM,IAAIC,uBAAkC;GAC9C;EAGc;EACd,OAAO,OAAO,cACZ,aAAa,OAAO,OAAO,OAAO,IAAI,IAAIC,kBAA6B,CAAC,CAC1E;CACF;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { mapLeaves } from "./internal/utils.js";
|
|
2
3
|
import { make as make$1 } from "./GroupRegistry.js";
|
|
3
4
|
import { isFunctionRegistryItem } from "./FunctionRegistryItem.js";
|
|
4
5
|
import { actionFunctionBase, actionLayer } from "./RegisteredFunction.js";
|
|
5
6
|
import { resolve } from "./ResolvedMiddleware.js";
|
|
6
|
-
import { mapLeaves } from "./internal/utils.js";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
8
|
import { actionGeneric, internalActionGeneric } from "convex/server";
|
|
9
9
|
import * as Match from "effect/Match";
|
package/dist/RegistryItems.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { isMiddlewareRegistryItem } from "./MiddlewareRegistryItem.js";
|
|
3
3
|
import { isFunctionRegistryItem } from "./FunctionRegistryItem.js";
|
|
4
|
-
import { pipe } from "effect/Function";
|
|
5
4
|
import * as Array from "effect/Array";
|
|
6
5
|
import * as Record from "effect/Record";
|
|
6
|
+
import { pipe } from "effect/Function";
|
|
7
7
|
//#region src/RegistryItems.ts
|
|
8
8
|
var RegistryItems_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
functionNames: () => functionNames,
|
package/dist/RequestMetadata.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import * as Context from "effect/Context";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
3
|
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
5
|
//#region src/RequestMetadata.ts
|
|
6
6
|
var RequestMetadata_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
RequestMetadata: () => RequestMetadata,
|
package/dist/Scheduler.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import * as Context from "effect/Context";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
3
|
import * as Effect from "effect/Effect";
|
|
5
|
-
import * as
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
6
5
|
import { Ref } from "@confect/core";
|
|
7
6
|
import * as DateTime from "effect/DateTime";
|
|
7
|
+
import * as Duration from "effect/Duration";
|
|
8
8
|
//#region src/Scheduler.ts
|
|
9
9
|
var Scheduler_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
Scheduler: () => Scheduler,
|
package/dist/Storage.js
CHANGED
|
@@ -3,8 +3,8 @@ import { StorageActionWriter } from "./StorageActionWriter.js";
|
|
|
3
3
|
import { StorageReader } from "./StorageReader.js";
|
|
4
4
|
import { StorageWriter } from "./StorageWriter.js";
|
|
5
5
|
import * as Context from "effect/Context";
|
|
6
|
-
import * as Layer from "effect/Layer";
|
|
7
6
|
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
8
|
//#region src/Storage.ts
|
|
9
9
|
var Storage_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
Storage: () => Storage,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { BlobNotFoundError } from "./BlobNotFoundError.js";
|
|
3
3
|
import * as Context from "effect/Context";
|
|
4
|
-
import * as Layer from "effect/Layer";
|
|
5
4
|
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
6
|
import { flow } from "effect/Function";
|
|
7
7
|
import * as Option from "effect/Option";
|
|
8
8
|
//#region src/StorageActionWriter.ts
|
package/dist/StorageReader.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { BlobNotFoundError } from "./BlobNotFoundError.js";
|
|
3
3
|
import * as Context from "effect/Context";
|
|
4
|
-
import * as Layer from "effect/Layer";
|
|
5
4
|
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
7
7
|
import { flow, pipe } from "effect/Function";
|
|
8
8
|
import * as Option from "effect/Option";
|
package/dist/StorageWriter.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { BlobNotFoundError } from "./BlobNotFoundError.js";
|
|
3
3
|
import * as Context from "effect/Context";
|
|
4
|
-
import * as Layer from "effect/Layer";
|
|
5
4
|
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
7
7
|
import { pipe } from "effect/Function";
|
|
8
8
|
//#region src/StorageWriter.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import * as Context from "effect/Context";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
3
|
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
5
|
//#region src/TransactionMetadata.ts
|
|
6
6
|
var TransactionMetadata_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
TransactionMetadata: () => TransactionMetadata,
|
package/dist/VectorSearch.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import * as Context from "effect/Context";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
3
|
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
5
|
//#region src/VectorSearch.ts
|
|
6
6
|
var VectorSearch_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
VectorSearch: () => VectorSearch,
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,uBAAuB,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,uBAAuB,MAAM,8BAA8B,CAAC;AACxE,OAAO,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,oBAAoB,MAAM,2BAA2B,CAAC;AAClE,OAAO,KAAK,yBAAyB,MAAM,gCAAgC,CAAC;AAC5E,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC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5C,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,mBAAmB,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { ActionCtx_exports } from "./ActionCtx.js";
|
|
2
2
|
import { ActionRunner_exports } from "./ActionRunner.js";
|
|
3
|
+
import { Registry_exports } from "./Registry.js";
|
|
4
|
+
import { MiddlewareRegistryItem_exports } from "./MiddlewareRegistryItem.js";
|
|
5
|
+
import { MiddlewareImpl_exports } from "./MiddlewareImpl.js";
|
|
6
|
+
import { MutationTransactionContext_exports } from "./MutationTransactionContext.js";
|
|
7
|
+
import { MutationRunner_exports } from "./MutationRunner.js";
|
|
8
|
+
import { QueryTransactionContext_exports } from "./QueryTransactionContext.js";
|
|
9
|
+
import { QueryRunner_exports } from "./QueryRunner.js";
|
|
10
|
+
import { Scheduler_exports } from "./Scheduler.js";
|
|
11
|
+
import { ActionCall_exports } from "./ActionCall.js";
|
|
3
12
|
import { AiGatewayDecisionClient_exports } from "./AiGatewayDecisionClient.js";
|
|
4
13
|
import { AiGatewayDecisionModel_exports } from "./AiGatewayDecisionModel.js";
|
|
5
14
|
import { AiGatewayLanguageClient_exports } from "./AiGatewayLanguageClient.js";
|
|
@@ -8,8 +17,6 @@ import { Auth_exports } from "./Auth.js";
|
|
|
8
17
|
import { BlobNotFoundError_exports } from "./BlobNotFoundError.js";
|
|
9
18
|
import { Callback_exports } from "./Callback.js";
|
|
10
19
|
import { ConvexConfigProvider_exports } from "./ConvexConfigProvider.js";
|
|
11
|
-
import { Registry_exports } from "./Registry.js";
|
|
12
|
-
import { MiddlewareRegistryItem_exports } from "./MiddlewareRegistryItem.js";
|
|
13
20
|
import { FunctionRegistryItem_exports } from "./FunctionRegistryItem.js";
|
|
14
21
|
import { DatabaseSchema_exports } from "./DatabaseSchema.js";
|
|
15
22
|
import { Document_exports } from "./Document.js";
|
|
@@ -31,13 +38,8 @@ import { ExecutionMetadata_exports } from "./ExecutionMetadata.js";
|
|
|
31
38
|
import { RequestMetadata_exports } from "./RequestMetadata.js";
|
|
32
39
|
import { TransactionMetadata_exports } from "./TransactionMetadata.js";
|
|
33
40
|
import { MutationCtx_exports } from "./MutationCtx.js";
|
|
34
|
-
import { MutationTransactionContext_exports } from "./MutationTransactionContext.js";
|
|
35
|
-
import { MutationRunner_exports } from "./MutationRunner.js";
|
|
36
41
|
import { QueryCtx_exports } from "./QueryCtx.js";
|
|
37
|
-
import { QueryTransactionContext_exports } from "./QueryTransactionContext.js";
|
|
38
|
-
import { QueryRunner_exports } from "./QueryRunner.js";
|
|
39
42
|
import { ConvexLogger_exports } from "./ConvexLogger.js";
|
|
40
|
-
import { Scheduler_exports } from "./Scheduler.js";
|
|
41
43
|
import { StorageActionWriter_exports } from "./StorageActionWriter.js";
|
|
42
44
|
import { StorageReader_exports } from "./StorageReader.js";
|
|
43
45
|
import { StorageWriter_exports } from "./StorageWriter.js";
|
|
@@ -55,8 +57,7 @@ import { RegistryItems_exports } from "./RegistryItems.js";
|
|
|
55
57
|
import { GroupImpl_exports } from "./GroupImpl.js";
|
|
56
58
|
import { Handler_exports } from "./Handler.js";
|
|
57
59
|
import { HttpRouter_exports } from "./HttpRouter.js";
|
|
58
|
-
import { MiddlewareImpl_exports } from "./MiddlewareImpl.js";
|
|
59
60
|
import { OfficialComponent_exports } from "./OfficialComponent.js";
|
|
60
61
|
import { RegisteredFunctions_exports } from "./RegisteredFunctions.js";
|
|
61
62
|
import { TableInfo_exports } from "./TableInfo.js";
|
|
62
|
-
export { ActionCtx_exports as ActionCtx, ActionRunner_exports as ActionRunner, AiGatewayDecisionClient_exports as AiGatewayDecisionClient, AiGatewayDecisionModel_exports as AiGatewayDecisionModel, AiGatewayLanguageClient_exports as AiGatewayLanguageClient, AiGatewayLanguageModel_exports as AiGatewayLanguageModel, Auth_exports as Auth, BlobNotFoundError_exports as BlobNotFoundError, Callback_exports as Callback, ConvexConfigProvider_exports as ConvexConfigProvider, ConvexFunctionDefinitions_exports as ConvexFunctionDefinitions, ConvexLogger_exports as ConvexLogger, CronJob_exports as CronJob, CronJobs_exports as CronJobs, DataModel_exports as DataModel, DatabaseReader_exports as DatabaseReader, DatabaseSchema_exports as DatabaseSchema, DatabaseWriter_exports as DatabaseWriter, Document_exports as Document, ExecutionMetadata_exports as ExecutionMetadata, FunctionImpl_exports as FunctionImpl, FunctionRegistryItem_exports as FunctionRegistryItem, GroupImpl_exports as GroupImpl, Handler_exports as Handler, HttpRouter_exports as HttpRouter, MiddlewareImpl_exports as MiddlewareImpl, MiddlewareRegistryItem_exports as MiddlewareRegistryItem, MutationCtx_exports as MutationCtx, MutationRunner_exports as MutationRunner, MutationTransactionContext_exports as MutationTransactionContext, OfficialComponent_exports as OfficialComponent, OrderedQuery_exports as OrderedQuery, QueryCtx_exports as QueryCtx, QueryInitializer_exports as QueryInitializer, QueryRunner_exports as QueryRunner, QueryStream_exports as QueryStream, QueryStreamCursor_exports as QueryStreamCursor, QueryStreamIndexRange_exports as QueryStreamIndexRange, QueryStreamKeyBounds_exports as QueryStreamKeyBounds, QueryStreamKeyLabels_exports as QueryStreamKeyLabels, QueryStreamKeyLayout_exports as QueryStreamKeyLayout, QueryStreamKeyValues_exports as QueryStreamKeyValues, QueryStreamOrderDirection_exports as QueryStreamOrderDirection, QueryStreamReadBudget_exports as QueryStreamReadBudget, QueryTransactionContext_exports as QueryTransactionContext, RegisteredConvexFunction_exports as RegisteredConvexFunction, RegisteredFunction_exports as RegisteredFunction, RegisteredFunctions_exports as RegisteredFunctions, Registry_exports as Registry, RegistryItems_exports as RegistryItems, RequestMetadata_exports as RequestMetadata, ResolvedMiddleware_exports as ResolvedMiddleware, Scheduler_exports as Scheduler, Storage_exports as Storage, StorageActionWriter_exports as StorageActionWriter, StorageReader_exports as StorageReader, StorageWriter_exports as StorageWriter, Table_exports as Table, TableInfo_exports as TableInfo, TransactionMetadata_exports as TransactionMetadata, VectorSearch_exports as VectorSearch };
|
|
63
|
+
export { ActionCall_exports as ActionCall, ActionCtx_exports as ActionCtx, ActionRunner_exports as ActionRunner, AiGatewayDecisionClient_exports as AiGatewayDecisionClient, AiGatewayDecisionModel_exports as AiGatewayDecisionModel, AiGatewayLanguageClient_exports as AiGatewayLanguageClient, AiGatewayLanguageModel_exports as AiGatewayLanguageModel, Auth_exports as Auth, BlobNotFoundError_exports as BlobNotFoundError, Callback_exports as Callback, ConvexConfigProvider_exports as ConvexConfigProvider, ConvexFunctionDefinitions_exports as ConvexFunctionDefinitions, ConvexLogger_exports as ConvexLogger, CronJob_exports as CronJob, CronJobs_exports as CronJobs, DataModel_exports as DataModel, DatabaseReader_exports as DatabaseReader, DatabaseSchema_exports as DatabaseSchema, DatabaseWriter_exports as DatabaseWriter, Document_exports as Document, ExecutionMetadata_exports as ExecutionMetadata, FunctionImpl_exports as FunctionImpl, FunctionRegistryItem_exports as FunctionRegistryItem, GroupImpl_exports as GroupImpl, Handler_exports as Handler, HttpRouter_exports as HttpRouter, MiddlewareImpl_exports as MiddlewareImpl, MiddlewareRegistryItem_exports as MiddlewareRegistryItem, MutationCtx_exports as MutationCtx, MutationRunner_exports as MutationRunner, MutationTransactionContext_exports as MutationTransactionContext, OfficialComponent_exports as OfficialComponent, OrderedQuery_exports as OrderedQuery, QueryCtx_exports as QueryCtx, QueryInitializer_exports as QueryInitializer, QueryRunner_exports as QueryRunner, QueryStream_exports as QueryStream, QueryStreamCursor_exports as QueryStreamCursor, QueryStreamIndexRange_exports as QueryStreamIndexRange, QueryStreamKeyBounds_exports as QueryStreamKeyBounds, QueryStreamKeyLabels_exports as QueryStreamKeyLabels, QueryStreamKeyLayout_exports as QueryStreamKeyLayout, QueryStreamKeyValues_exports as QueryStreamKeyValues, QueryStreamOrderDirection_exports as QueryStreamOrderDirection, QueryStreamReadBudget_exports as QueryStreamReadBudget, QueryTransactionContext_exports as QueryTransactionContext, RegisteredConvexFunction_exports as RegisteredConvexFunction, RegisteredFunction_exports as RegisteredFunction, RegisteredFunctions_exports as RegisteredFunctions, Registry_exports as Registry, RegistryItems_exports as RegistryItems, RequestMetadata_exports as RequestMetadata, ResolvedMiddleware_exports as ResolvedMiddleware, Scheduler_exports as Scheduler, Storage_exports as Storage, StorageActionWriter_exports as StorageActionWriter, StorageReader_exports as StorageReader, StorageWriter_exports as StorageWriter, Table_exports as Table, TableInfo_exports as TableInfo, TransactionMetadata_exports as TransactionMetadata, VectorSearch_exports as VectorSearch };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AiGatewayServiceToken, transformClientRequest } from "./AiGatewayServiceToken.js";
|
|
2
2
|
import { AI_GATEWAY_API_URL } from "./constants.js";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
3
|
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
5
|
import * as OpenRouterClient from "@effect/ai-openrouter/OpenRouterClient";
|
|
6
6
|
//#region src/internal/AiGatewayDecisionClient.ts
|
|
7
7
|
const make = Effect.gen(function* () {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AiGatewayServiceToken, transformClientRequest } from "./AiGatewayServiceToken.js";
|
|
2
2
|
import { AI_GATEWAY_API_URL } from "./constants.js";
|
|
3
|
-
import * as Layer from "effect/Layer";
|
|
4
3
|
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
5
|
import * as OpenAiClient from "@effect/ai-openai-compat/OpenAiClient";
|
|
6
6
|
//#region src/internal/AiGatewayLanguageClient.ts
|
|
7
7
|
const make = Effect.gen(function* () {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Context from "effect/Context";
|
|
2
|
-
import * as Layer from "effect/Layer";
|
|
3
2
|
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
4
|
import { getServiceToken } from "convex/server";
|
|
5
5
|
import * as Schema from "effect/Schema";
|
|
6
6
|
import * as HttpClient from "effect/http/HttpClient";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Record from "effect/Record";
|
|
2
3
|
import * as Schema from "effect/Schema";
|
|
3
4
|
import { pipe } from "effect/Function";
|
|
4
5
|
import * as SchemaAST from "effect/SchemaAST";
|
|
5
|
-
import * as Record from "effect/Record";
|
|
6
6
|
//#region src/internal/DocumentPatch.ts
|
|
7
7
|
const patchEncoders = /* @__PURE__ */ new WeakMap();
|
|
8
8
|
/**
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gaganref/confect-server",
|
|
3
|
-
"version": "10.3.1-fork.
|
|
3
|
+
"version": "10.3.1-fork.27",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@effect/ai-openai-compat": "4.0.4",
|
|
6
6
|
"@effect/ai-openrouter": "4.0.4"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.
|
|
9
|
+
"@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.27",
|
|
10
10
|
"@effect/platform-node": "^4.0.0",
|
|
11
11
|
"convex": "^1.45.0",
|
|
12
12
|
"effect": "^4.0.4"
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as ActionCall from "@confect/core/ActionCall";
|
|
2
|
+
import * as Ref from "@confect/core/Ref";
|
|
3
|
+
import type { FunctionReference } from "convex/server";
|
|
4
|
+
import * as Context from "effect/Context";
|
|
5
|
+
import * as Data from "effect/Data";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as ActionCtx from "./ActionCtx.js";
|
|
8
|
+
import * as ActionRunner from "./ActionRunner.js";
|
|
9
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
10
|
+
import type * as DataModel from "./DataModel.js";
|
|
11
|
+
import type * as Handler from "./Handler.js";
|
|
12
|
+
import * as MiddlewareImpl from "./MiddlewareImpl.js";
|
|
13
|
+
import * as MutationRunner from "./MutationRunner.js";
|
|
14
|
+
import * as QueryRunner from "./QueryRunner.js";
|
|
15
|
+
import * as Scheduler from "./Scheduler.js";
|
|
16
|
+
|
|
17
|
+
export class ActionCallAlreadyUsed extends Data.TaggedError(
|
|
18
|
+
"ActionCallAlreadyUsed",
|
|
19
|
+
)<{}> {}
|
|
20
|
+
export class ActionCallNotUsed extends Data.TaggedError(
|
|
21
|
+
"ActionCallNotUsed",
|
|
22
|
+
)<{}> {}
|
|
23
|
+
export class MissingFunctionType extends Data.TaggedError(
|
|
24
|
+
"MissingFunctionType",
|
|
25
|
+
)<{}> {}
|
|
26
|
+
export class NestedActionNotAllowed extends Data.TaggedError(
|
|
27
|
+
"NestedActionNotAllowed",
|
|
28
|
+
)<{}> {}
|
|
29
|
+
|
|
30
|
+
export class SchedulingNotAllowed extends Data.TaggedError(
|
|
31
|
+
"SchedulingNotAllowed",
|
|
32
|
+
)<{}> {}
|
|
33
|
+
|
|
34
|
+
export const layer = <S extends DatabaseSchema.AnyWithProps>(schema: S) =>
|
|
35
|
+
MiddlewareImpl.make(schema, ActionCall.Middleware, (effect) =>
|
|
36
|
+
Effect.gen(function* () {
|
|
37
|
+
const ctx = yield* ActionCtx.ActionCtx<
|
|
38
|
+
DataModel.ToConvex<DataModel.FromSchema<S>>,
|
|
39
|
+
DatabaseSchema.Scope<S>
|
|
40
|
+
>();
|
|
41
|
+
let claimed = false;
|
|
42
|
+
const call: ActionCall.Call = <
|
|
43
|
+
Target extends Ref.AnyQuery | Ref.AnyMutation,
|
|
44
|
+
>(
|
|
45
|
+
ref: Target,
|
|
46
|
+
...args: Ref.OptionalArgs<NoInfer<Target>>
|
|
47
|
+
) =>
|
|
48
|
+
Effect.suspend(() => {
|
|
49
|
+
if (claimed) return Effect.die(new ActionCallAlreadyUsed());
|
|
50
|
+
claimed = true;
|
|
51
|
+
if (ref.functionType !== "query" && ref.functionType !== "mutation")
|
|
52
|
+
return Effect.die(new MissingFunctionType());
|
|
53
|
+
return Ref.runWithCodec(
|
|
54
|
+
ref,
|
|
55
|
+
(args[0] ?? {}) as Ref.Args<Target>,
|
|
56
|
+
(native, encoded) =>
|
|
57
|
+
ref.functionType === "query"
|
|
58
|
+
? ctx.runQuery(
|
|
59
|
+
native as FunctionReference<"query">,
|
|
60
|
+
encoded as never,
|
|
61
|
+
)
|
|
62
|
+
: ctx.runMutation(
|
|
63
|
+
native as FunctionReference<"mutation">,
|
|
64
|
+
encoded as never,
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
return yield* effect.pipe(
|
|
69
|
+
Effect.provideService(ActionCall.ActionCall, call),
|
|
70
|
+
Effect.updateContext(
|
|
71
|
+
(context: Context.Context<Handler.ActionServices<S>>) =>
|
|
72
|
+
Context.omit(
|
|
73
|
+
QueryRunner.QueryRunner,
|
|
74
|
+
MutationRunner.MutationRunner,
|
|
75
|
+
ActionRunner.ActionRunner,
|
|
76
|
+
ActionCtx.ActionCtx(),
|
|
77
|
+
Scheduler.Scheduler,
|
|
78
|
+
)(context),
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
}),
|
|
82
|
+
);
|
package/src/DatabaseWriter.ts
CHANGED
|
@@ -100,11 +100,54 @@ export type DatabaseWriterTag<
|
|
|
100
100
|
DatabaseWriterService<DatabaseSchema_, Docs>
|
|
101
101
|
>;
|
|
102
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Decoded documents surrounding one successful write.
|
|
105
|
+
*/
|
|
106
|
+
export type Change<S extends DatabaseSchema.AnyWithProps> = {
|
|
107
|
+
[Name in DataModel.TableNames<DataModel.FromSchema<S>>]: {
|
|
108
|
+
readonly tableName: Name;
|
|
109
|
+
} & (
|
|
110
|
+
| {
|
|
111
|
+
readonly operation: "insert";
|
|
112
|
+
readonly oldDoc: null;
|
|
113
|
+
readonly newDoc: DocumentByName_<DataModel.FromSchema<S>, Name>;
|
|
114
|
+
}
|
|
115
|
+
| {
|
|
116
|
+
readonly operation: "update";
|
|
117
|
+
readonly oldDoc: DocumentByName_<DataModel.FromSchema<S>, Name>;
|
|
118
|
+
readonly newDoc: DocumentByName_<DataModel.FromSchema<S>, Name>;
|
|
119
|
+
}
|
|
120
|
+
| {
|
|
121
|
+
readonly operation: "delete";
|
|
122
|
+
readonly oldDoc: DocumentByName_<DataModel.FromSchema<S>, Name>;
|
|
123
|
+
readonly newDoc: null;
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}[DataModel.TableNames<DataModel.FromSchema<S>>];
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Runs after the write, in its transaction. A defect aborts the mutation.
|
|
130
|
+
*
|
|
131
|
+
* Only writes through this writer are observed. Raw `ctx.db`, `MutationCtx`
|
|
132
|
+
* writes and a second `DatabaseWriter.make` bypass the hook, so a host that
|
|
133
|
+
* relies on it keeps raw writers out of its functions. Component writers and
|
|
134
|
+
* nested `runMutation` calls each need their own hook installation.
|
|
135
|
+
*
|
|
136
|
+
* Concurrent writes to one document (for example under `Effect.all`) can
|
|
137
|
+
* interleave the read-write-read steps. Await them sequentially when the hook
|
|
138
|
+
* needs exact per-write snapshots. The writer takes no lock, because a hook
|
|
139
|
+
* that writes through the same writer would deadlock under one.
|
|
140
|
+
*/
|
|
141
|
+
export type Hook<S extends DatabaseSchema.AnyWithProps> = (
|
|
142
|
+
change: Change<S>,
|
|
143
|
+
) => Effect.Effect<void>;
|
|
144
|
+
|
|
103
145
|
export const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
|
|
104
146
|
databaseSchema: DatabaseSchema_,
|
|
105
147
|
convexDatabaseWriter: GenericDatabaseWriter<
|
|
106
148
|
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>
|
|
107
149
|
>,
|
|
150
|
+
hook?: Hook<DatabaseSchema_>,
|
|
108
151
|
): DatabaseWriterService<DatabaseSchema_> => {
|
|
109
152
|
type DataModel_ = DataModel.FromSchema<DatabaseSchema_>;
|
|
110
153
|
|
|
@@ -267,11 +310,52 @@ export const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
|
|
|
267
310
|
convexDatabaseWriter.delete(id as unknown as GenericId<TableName>),
|
|
268
311
|
);
|
|
269
312
|
|
|
313
|
+
const accessor = { insert, patch, replace, delete: delete_ };
|
|
314
|
+
if (hook === undefined) return accessor;
|
|
315
|
+
|
|
316
|
+
const read = (id: DataModel.Id<DataModel_, TableName>) =>
|
|
317
|
+
QueryInitializer.getById<Table.AnyWithProps, TableName>(
|
|
318
|
+
convexDatabaseWriter as any,
|
|
319
|
+
tableDef,
|
|
320
|
+
)(id as unknown as GenericId<TableName>);
|
|
321
|
+
const notify = (
|
|
322
|
+
operation: "insert" | "update" | "delete",
|
|
323
|
+
oldDoc: unknown,
|
|
324
|
+
newDoc: unknown,
|
|
325
|
+
) =>
|
|
326
|
+
hook({ tableName, operation, oldDoc, newDoc } as Change<DatabaseSchema_>);
|
|
327
|
+
const update =
|
|
328
|
+
<A extends ReadonlyArray<unknown>, E, BeforeError>(
|
|
329
|
+
before: (
|
|
330
|
+
id: DataModel.Id<DataModel_, TableName>,
|
|
331
|
+
) => Effect.Effect<unknown, BeforeError>,
|
|
332
|
+
write: (
|
|
333
|
+
id: DataModel.Id<DataModel_, TableName>,
|
|
334
|
+
...args: A
|
|
335
|
+
) => Effect.Effect<void, E>,
|
|
336
|
+
) =>
|
|
337
|
+
(id: DataModel.Id<DataModel_, TableName>, ...args: A) =>
|
|
338
|
+
Effect.gen(function* () {
|
|
339
|
+
const oldDoc = yield* before(id);
|
|
340
|
+
yield* write(id, ...args);
|
|
341
|
+
yield* notify("update", oldDoc, yield* read(id).pipe(Effect.orDie));
|
|
342
|
+
});
|
|
343
|
+
|
|
270
344
|
return {
|
|
271
|
-
insert
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
345
|
+
insert: (document: Parameters<typeof insert>[0]) =>
|
|
346
|
+
Effect.gen(function* () {
|
|
347
|
+
const id = yield* insert(document);
|
|
348
|
+
yield* notify("insert", null, yield* read(id).pipe(Effect.orDie));
|
|
349
|
+
return id;
|
|
350
|
+
}),
|
|
351
|
+
patch: update(read, patch),
|
|
352
|
+
replace: update((id) => read(id).pipe(Effect.orDie), replace),
|
|
353
|
+
delete: (id: DataModel.Id<DataModel_, TableName>) =>
|
|
354
|
+
Effect.gen(function* () {
|
|
355
|
+
const oldDoc = yield* read(id).pipe(Effect.orDie);
|
|
356
|
+
yield* delete_(id);
|
|
357
|
+
yield* notify("delete", oldDoc, null);
|
|
358
|
+
}),
|
|
275
359
|
};
|
|
276
360
|
};
|
|
277
361
|
|
|
@@ -298,8 +382,9 @@ export const layer = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
|
|
|
298
382
|
convexDatabaseWriter: GenericDatabaseWriter<
|
|
299
383
|
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>
|
|
300
384
|
>,
|
|
385
|
+
hook?: Hook<DatabaseSchema_>,
|
|
301
386
|
) =>
|
|
302
387
|
Layer.succeed(
|
|
303
388
|
DatabaseWriter<DatabaseSchema_>(),
|
|
304
|
-
make(databaseSchema, convexDatabaseWriter),
|
|
389
|
+
make(databaseSchema, convexDatabaseWriter, hook),
|
|
305
390
|
);
|
package/src/Handler.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ActionCall } from "@confect/core/ActionCall";
|
|
1
2
|
import type { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
2
3
|
import type * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
3
4
|
import type * as NodeServices from "@effect/platform-node/NodeServices";
|
|
@@ -114,9 +115,7 @@ export type MutationServices<
|
|
|
114
115
|
/**
|
|
115
116
|
* Shared by both action runtimes.
|
|
116
117
|
*/
|
|
117
|
-
|
|
118
|
-
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
119
|
-
> =
|
|
118
|
+
type RawActionServices<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =
|
|
120
119
|
| Scheduler.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
121
120
|
| (DatabaseSchema_["target"]["kind"] extends "component" ? never : Auth.Auth)
|
|
122
121
|
| StorageReader.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
@@ -134,6 +133,22 @@ export type ActionServices<
|
|
|
134
133
|
DatabaseSchema.Scope<DatabaseSchema_>
|
|
135
134
|
>;
|
|
136
135
|
|
|
136
|
+
export type ActionServices<S extends DatabaseSchema.AnyWithProps, R = never> = [
|
|
137
|
+
Extract<R, ActionCall>,
|
|
138
|
+
] extends [never]
|
|
139
|
+
? RawActionServices<S>
|
|
140
|
+
: Exclude<
|
|
141
|
+
RawActionServices<S>,
|
|
142
|
+
| Scheduler.ForScope<DatabaseSchema.Scope<S>>
|
|
143
|
+
| QueryRunner.QueryRunner
|
|
144
|
+
| MutationRunner.MutationRunner
|
|
145
|
+
| ActionRunner.ActionRunner
|
|
146
|
+
| ActionCtx.ActionCtx<
|
|
147
|
+
DataModel.ToConvex<DataModel.FromSchema<S>>,
|
|
148
|
+
DatabaseSchema.Scope<S>
|
|
149
|
+
>
|
|
150
|
+
>;
|
|
151
|
+
|
|
137
152
|
export type ConfectProvenanceQuery<
|
|
138
153
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
139
154
|
FunctionSpec_ extends
|
|
@@ -153,7 +168,7 @@ export type ConvexRuntimeAction<
|
|
|
153
168
|
FunctionSpec_ extends
|
|
154
169
|
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>,
|
|
155
170
|
R = never,
|
|
156
|
-
> = Base<FunctionSpec_, ActionServices<DatabaseSchema_> | R>;
|
|
171
|
+
> = Base<FunctionSpec_, ActionServices<DatabaseSchema_, R> | R>;
|
|
157
172
|
|
|
158
173
|
export type NodeRuntimeAction<
|
|
159
174
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
@@ -162,7 +177,7 @@ export type NodeRuntimeAction<
|
|
|
162
177
|
R = never,
|
|
163
178
|
> = Base<
|
|
164
179
|
FunctionSpec_,
|
|
165
|
-
ActionServices<DatabaseSchema_> | NodeServices.NodeServices | R
|
|
180
|
+
ActionServices<DatabaseSchema_, R> | NodeServices.NodeServices | R
|
|
166
181
|
>;
|
|
167
182
|
|
|
168
183
|
type Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (
|