@gaganref/confect-server 0.0.0-stage → 10.3.1-fork.2
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 +2119 -0
- package/LICENSE +7 -0
- package/README.md +16 -2
- package/dist/ActionCtx.d.ts +10 -0
- package/dist/ActionCtx.d.ts.map +1 -0
- package/dist/ActionCtx.js +18 -0
- package/dist/ActionCtx.js.map +1 -0
- package/dist/ActionRunner.d.ts +16 -0
- package/dist/ActionRunner.d.ts.map +1 -0
- package/dist/ActionRunner.js +18 -0
- package/dist/ActionRunner.js.map +1 -0
- package/dist/AiGatewayDecisionClient.d.ts +20 -0
- package/dist/AiGatewayDecisionClient.d.ts.map +1 -0
- package/dist/AiGatewayDecisionClient.js +31 -0
- package/dist/AiGatewayDecisionClient.js.map +1 -0
- package/dist/AiGatewayDecisionModel.d.ts +24 -0
- package/dist/AiGatewayDecisionModel.d.ts.map +1 -0
- package/dist/AiGatewayDecisionModel.js +27 -0
- package/dist/AiGatewayDecisionModel.js.map +1 -0
- package/dist/AiGatewayLanguageClient.d.ts +21 -0
- package/dist/AiGatewayLanguageClient.d.ts.map +1 -0
- package/dist/AiGatewayLanguageClient.js +32 -0
- package/dist/AiGatewayLanguageClient.js.map +1 -0
- package/dist/AiGatewayLanguageModel.d.ts +95 -0
- package/dist/AiGatewayLanguageModel.d.ts.map +1 -0
- package/dist/AiGatewayLanguageModel.js +42 -0
- package/dist/AiGatewayLanguageModel.js.map +1 -0
- package/dist/Auth.d.ts +20 -0
- package/dist/Auth.d.ts.map +1 -0
- package/dist/Auth.js +31 -0
- package/dist/Auth.js.map +1 -0
- package/dist/BlobNotFoundError.d.ts +9 -0
- package/dist/BlobNotFoundError.d.ts.map +1 -0
- package/dist/BlobNotFoundError.js +13 -0
- package/dist/BlobNotFoundError.js.map +1 -0
- package/dist/Callback.d.ts +31 -0
- package/dist/Callback.d.ts.map +1 -0
- package/dist/Callback.js +182 -0
- package/dist/Callback.js.map +1 -0
- package/dist/ComponentCtx.d.ts +71 -0
- package/dist/ComponentCtx.d.ts.map +1 -0
- package/dist/ComponentCtx.js +0 -0
- package/dist/ConvexConfigProvider.d.ts +21 -0
- package/dist/ConvexConfigProvider.d.ts.map +1 -0
- package/dist/ConvexConfigProvider.js +36 -0
- package/dist/ConvexConfigProvider.js.map +1 -0
- package/dist/ConvexFunctionDefinitions.d.ts +25 -0
- package/dist/ConvexFunctionDefinitions.d.ts.map +1 -0
- package/dist/ConvexFunctionDefinitions.js +25 -0
- package/dist/ConvexFunctionDefinitions.js.map +1 -0
- package/dist/ConvexLogger.d.ts +17 -0
- package/dist/ConvexLogger.d.ts.map +1 -0
- package/dist/ConvexLogger.js +33 -0
- package/dist/ConvexLogger.js.map +1 -0
- package/dist/CronJob.d.ts +14 -0
- package/dist/CronJob.d.ts.map +1 -0
- package/dist/CronJob.js +22 -0
- package/dist/CronJob.js.map +1 -0
- package/dist/CronJobs.d.ts +22 -0
- package/dist/CronJobs.d.ts.map +1 -0
- package/dist/CronJobs.js +83 -0
- package/dist/CronJobs.js.map +1 -0
- package/dist/DataModel.d.ts +28 -0
- package/dist/DataModel.d.ts.map +1 -0
- package/dist/DataModel.js +7 -0
- package/dist/DataModel.js.map +1 -0
- package/dist/DatabaseReader.d.ts +26 -0
- package/dist/DatabaseReader.d.ts.map +1 -0
- package/dist/DatabaseReader.js +33 -0
- package/dist/DatabaseReader.js.map +1 -0
- package/dist/DatabaseSchema.d.ts +67 -0
- package/dist/DatabaseSchema.d.ts.map +1 -0
- package/dist/DatabaseSchema.js +61 -0
- package/dist/DatabaseSchema.js.map +1 -0
- package/dist/DatabaseWriter.d.ts +44 -0
- package/dist/DatabaseWriter.d.ts.map +1 -0
- package/dist/DatabaseWriter.js +47 -0
- package/dist/DatabaseWriter.js.map +1 -0
- package/dist/Document.d.ts +37 -0
- package/dist/Document.d.ts.map +1 -0
- package/dist/Document.js +54 -0
- package/dist/Document.js.map +1 -0
- package/dist/ExecutionMetadata.d.ts +13 -0
- package/dist/ExecutionMetadata.d.ts.map +1 -0
- package/dist/ExecutionMetadata.js +19 -0
- package/dist/ExecutionMetadata.js.map +1 -0
- package/dist/FunctionImpl.d.ts +39 -0
- package/dist/FunctionImpl.d.ts.map +1 -0
- package/dist/FunctionImpl.js +46 -0
- package/dist/FunctionImpl.js.map +1 -0
- package/dist/FunctionRegistryItem.d.ts +36 -0
- package/dist/FunctionRegistryItem.d.ts.map +1 -0
- package/dist/FunctionRegistryItem.js +34 -0
- package/dist/FunctionRegistryItem.js.map +1 -0
- package/dist/GroupImpl.d.ts +77 -0
- package/dist/GroupImpl.d.ts.map +1 -0
- package/dist/GroupImpl.js +81 -0
- package/dist/GroupImpl.js.map +1 -0
- package/dist/GroupRegistry.d.ts +8 -0
- package/dist/GroupRegistry.d.ts.map +1 -0
- package/dist/GroupRegistry.js +26 -0
- package/dist/GroupRegistry.js.map +1 -0
- package/dist/Handler.d.ts +47 -0
- package/dist/Handler.d.ts.map +1 -0
- package/dist/Handler.js +7 -0
- package/dist/Handler.js.map +1 -0
- package/dist/HttpRouter.d.ts +80 -0
- package/dist/HttpRouter.d.ts.map +1 -0
- package/dist/HttpRouter.js +195 -0
- package/dist/HttpRouter.js.map +1 -0
- package/dist/MiddlewareImpl.d.ts +79 -0
- package/dist/MiddlewareImpl.d.ts.map +1 -0
- package/dist/MiddlewareImpl.js +58 -0
- package/dist/MiddlewareImpl.js.map +1 -0
- package/dist/MiddlewareRegistryItem.d.ts +12 -0
- package/dist/MiddlewareRegistryItem.d.ts.map +1 -0
- package/dist/MiddlewareRegistryItem.js +15 -0
- package/dist/MiddlewareRegistryItem.js.map +1 -0
- package/dist/MutationCtx.d.ts +10 -0
- package/dist/MutationCtx.d.ts.map +1 -0
- package/dist/MutationCtx.js +18 -0
- package/dist/MutationCtx.js.map +1 -0
- package/dist/MutationRunner.d.ts +27 -0
- package/dist/MutationRunner.d.ts.map +1 -0
- package/dist/MutationRunner.js +28 -0
- package/dist/MutationRunner.js.map +1 -0
- package/dist/MutationTransactionContext.d.ts +17 -0
- package/dist/MutationTransactionContext.d.ts.map +1 -0
- package/dist/MutationTransactionContext.js +20 -0
- package/dist/MutationTransactionContext.js.map +1 -0
- package/dist/OrderedQuery.d.ts +32 -0
- package/dist/OrderedQuery.d.ts.map +1 -0
- package/dist/OrderedQuery.js +36 -0
- package/dist/OrderedQuery.js.map +1 -0
- package/dist/QueryCtx.d.ts +10 -0
- package/dist/QueryCtx.d.ts.map +1 -0
- package/dist/QueryCtx.js +18 -0
- package/dist/QueryCtx.js.map +1 -0
- package/dist/QueryInitializer.d.ts +75 -0
- package/dist/QueryInitializer.d.ts.map +1 -0
- package/dist/QueryInitializer.js +105 -0
- package/dist/QueryInitializer.js.map +1 -0
- package/dist/QueryRunner.d.ts +46 -0
- package/dist/QueryRunner.d.ts.map +1 -0
- package/dist/QueryRunner.js +30 -0
- package/dist/QueryRunner.js.map +1 -0
- package/dist/QueryStream.d.ts +678 -0
- package/dist/QueryStream.d.ts.map +1 -0
- package/dist/QueryStream.js +943 -0
- package/dist/QueryStream.js.map +1 -0
- package/dist/QueryStreamCursor.d.ts +39 -0
- package/dist/QueryStreamCursor.d.ts.map +1 -0
- package/dist/QueryStreamCursor.js +52 -0
- package/dist/QueryStreamCursor.js.map +1 -0
- package/dist/QueryStreamIndexPrefix.d.ts +48 -0
- package/dist/QueryStreamIndexPrefix.d.ts.map +1 -0
- package/dist/QueryStreamIndexPrefix.js +38 -0
- package/dist/QueryStreamIndexPrefix.js.map +1 -0
- package/dist/QueryStreamIndexRange.d.ts +193 -0
- package/dist/QueryStreamIndexRange.d.ts.map +1 -0
- package/dist/QueryStreamIndexRange.js +241 -0
- package/dist/QueryStreamIndexRange.js.map +1 -0
- package/dist/QueryStreamKey.d.ts +64 -0
- package/dist/QueryStreamKey.d.ts.map +1 -0
- package/dist/QueryStreamKey.js +69 -0
- package/dist/QueryStreamKey.js.map +1 -0
- package/dist/QueryStreamKeyBounds.d.ts +136 -0
- package/dist/QueryStreamKeyBounds.d.ts.map +1 -0
- package/dist/QueryStreamKeyBounds.js +208 -0
- package/dist/QueryStreamKeyBounds.js.map +1 -0
- package/dist/QueryStreamKeyLabels.d.ts +27 -0
- package/dist/QueryStreamKeyLabels.d.ts.map +1 -0
- package/dist/QueryStreamKeyLabels.js +22 -0
- package/dist/QueryStreamKeyLabels.js.map +1 -0
- package/dist/QueryStreamKeyLayout.d.ts +179 -0
- package/dist/QueryStreamKeyLayout.d.ts.map +1 -0
- package/dist/QueryStreamKeyLayout.js +167 -0
- package/dist/QueryStreamKeyLayout.js.map +1 -0
- package/dist/QueryStreamKeyValues.d.ts +40 -0
- package/dist/QueryStreamKeyValues.d.ts.map +1 -0
- package/dist/QueryStreamKeyValues.js +57 -0
- package/dist/QueryStreamKeyValues.js.map +1 -0
- package/dist/QueryStreamOrderDirection.d.ts +24 -0
- package/dist/QueryStreamOrderDirection.d.ts.map +1 -0
- package/dist/QueryStreamOrderDirection.js +11 -0
- package/dist/QueryStreamOrderDirection.js.map +1 -0
- package/dist/QueryStreamPagination.d.ts +264 -0
- package/dist/QueryStreamPagination.d.ts.map +1 -0
- package/dist/QueryStreamPagination.js +172 -0
- package/dist/QueryStreamPagination.js.map +1 -0
- package/dist/QueryStreamReadBudget.d.ts +63 -0
- package/dist/QueryStreamReadBudget.d.ts.map +1 -0
- package/dist/QueryStreamReadBudget.js +81 -0
- package/dist/QueryStreamReadBudget.js.map +1 -0
- package/dist/QueryTransactionContext.d.ts +16 -0
- package/dist/QueryTransactionContext.d.ts.map +1 -0
- package/dist/QueryTransactionContext.js +17 -0
- package/dist/QueryTransactionContext.js.map +1 -0
- package/dist/RegisteredConvexFunction.d.ts +359 -0
- package/dist/RegisteredConvexFunction.d.ts.map +1 -0
- package/dist/RegisteredConvexFunction.js +154 -0
- package/dist/RegisteredConvexFunction.js.map +1 -0
- package/dist/RegisteredFunction.d.ts +143 -0
- package/dist/RegisteredFunction.d.ts.map +1 -0
- package/dist/RegisteredFunction.js +125 -0
- package/dist/RegisteredFunction.js.map +1 -0
- package/dist/RegisteredFunctions.d.ts +57 -0
- package/dist/RegisteredFunctions.d.ts.map +1 -0
- package/dist/RegisteredFunctions.js +32 -0
- package/dist/RegisteredFunctions.js.map +1 -0
- package/dist/RegisteredNodeFunction.d.ts +11 -0
- package/dist/RegisteredNodeFunction.d.ts.map +1 -0
- package/dist/RegisteredNodeFunction.js +45 -0
- package/dist/RegisteredNodeFunction.js.map +1 -0
- package/dist/Registry.d.ts +12 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/Registry.js +17 -0
- package/dist/Registry.js.map +1 -0
- package/dist/RegistryItems.d.ts +21 -0
- package/dist/RegistryItems.d.ts.map +1 -0
- package/dist/RegistryItems.js +27 -0
- package/dist/RegistryItems.js.map +1 -0
- package/dist/RequestMetadata.d.ts +12 -0
- package/dist/RequestMetadata.d.ts.map +1 -0
- package/dist/RequestMetadata.js +16 -0
- package/dist/RequestMetadata.js.map +1 -0
- package/dist/ResolvedMiddleware.d.ts +24 -0
- package/dist/ResolvedMiddleware.d.ts.map +1 -0
- package/dist/ResolvedMiddleware.js +34 -0
- package/dist/ResolvedMiddleware.js.map +1 -0
- package/dist/Scheduler.d.ts +31 -0
- package/dist/Scheduler.d.ts.map +1 -0
- package/dist/Scheduler.js +35 -0
- package/dist/Scheduler.js.map +1 -0
- package/dist/Storage.d.ts +22 -0
- package/dist/Storage.d.ts.map +1 -0
- package/dist/Storage.js +27 -0
- package/dist/Storage.js.map +1 -0
- package/dist/StorageActionWriter.d.ts +35 -0
- package/dist/StorageActionWriter.d.ts.map +1 -0
- package/dist/StorageActionWriter.js +24 -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 +22 -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 +24 -0
- package/dist/StorageWriter.js.map +1 -0
- package/dist/Table.d.ts +274 -0
- package/dist/Table.d.ts.map +1 -0
- package/dist/Table.js +70 -0
- package/dist/Table.js.map +1 -0
- package/dist/TableInfo.d.ts +44 -0
- package/dist/TableInfo.d.ts.map +1 -0
- package/dist/TableInfo.js +7 -0
- package/dist/TableInfo.js.map +1 -0
- package/dist/TransactionMetadata.d.ts +12 -0
- package/dist/TransactionMetadata.d.ts.map +1 -0
- package/dist/TransactionMetadata.js +16 -0
- package/dist/TransactionMetadata.js.map +1 -0
- package/dist/VectorSearch.d.ts +23 -0
- package/dist/VectorSearch.d.ts.map +1 -0
- package/dist/VectorSearch.js +17 -0
- package/dist/VectorSearch.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/internal/AiGatewayDecisionClient.d.ts +7 -0
- package/dist/internal/AiGatewayDecisionClient.d.ts.map +1 -0
- package/dist/internal/AiGatewayDecisionClient.js +19 -0
- package/dist/internal/AiGatewayDecisionClient.js.map +1 -0
- package/dist/internal/AiGatewayLanguageClient.d.ts +7 -0
- package/dist/internal/AiGatewayLanguageClient.d.ts.map +1 -0
- package/dist/internal/AiGatewayLanguageClient.js +19 -0
- package/dist/internal/AiGatewayLanguageClient.js.map +1 -0
- package/dist/internal/AiGatewayServiceToken.d.ts +46 -0
- package/dist/internal/AiGatewayServiceToken.d.ts.map +1 -0
- package/dist/internal/AiGatewayServiceToken.js +62 -0
- package/dist/internal/AiGatewayServiceToken.js.map +1 -0
- package/dist/internal/constants.d.ts +2 -0
- package/dist/internal/constants.d.ts.map +1 -0
- package/dist/internal/constants.js +6 -0
- package/dist/internal/constants.js.map +1 -0
- package/dist/internal/utils.d.ts +13 -0
- package/dist/internal/utils.d.ts.map +1 -0
- package/dist/internal/utils.js +50 -0
- package/dist/internal/utils.js.map +1 -0
- package/dist/node.d.ts +2 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +1 -0
- package/package.json +68 -3
- package/src/ActionCtx.ts +45 -0
- package/src/ActionRunner.ts +36 -0
- package/src/AiGatewayDecisionClient.ts +40 -0
- package/src/AiGatewayDecisionModel.ts +46 -0
- package/src/AiGatewayLanguageClient.ts +41 -0
- package/src/AiGatewayLanguageModel.ts +61 -0
- package/src/Auth.ts +51 -0
- package/src/BlobNotFoundError.ts +12 -0
- package/src/Callback.ts +313 -0
- package/src/ComponentCtx.ts +192 -0
- package/src/ConvexConfigProvider.ts +39 -0
- package/src/ConvexFunctionDefinitions.ts +91 -0
- package/src/ConvexLogger.ts +43 -0
- package/src/CronJob.ts +42 -0
- package/src/CronJobs.ts +165 -0
- package/src/DataModel.ts +81 -0
- package/src/DatabaseReader.ts +118 -0
- package/src/DatabaseSchema.ts +139 -0
- package/src/DatabaseWriter.ts +232 -0
- package/src/Document.ts +146 -0
- package/src/ExecutionMetadata.ts +26 -0
- package/src/FunctionImpl.ts +96 -0
- package/src/FunctionRegistryItem.ts +85 -0
- package/src/GroupImpl.ts +167 -0
- package/src/GroupRegistry.ts +41 -0
- package/src/Handler.ts +191 -0
- package/src/HttpRouter.ts +388 -0
- package/src/MiddlewareImpl.ts +247 -0
- package/src/MiddlewareRegistryItem.ts +21 -0
- package/src/MutationCtx.ts +45 -0
- package/src/MutationRunner.ts +66 -0
- package/src/MutationTransactionContext.ts +48 -0
- package/src/OrderedQuery.ts +136 -0
- package/src/QueryCtx.ts +45 -0
- package/src/QueryInitializer.ts +537 -0
- package/src/QueryRunner.ts +91 -0
- package/src/QueryStream.ts +2476 -0
- package/src/QueryStreamCursor.ts +99 -0
- package/src/QueryStreamIndexPrefix.ts +79 -0
- package/src/QueryStreamIndexRange.ts +489 -0
- package/src/QueryStreamKey.ts +118 -0
- package/src/QueryStreamKeyBounds.ts +395 -0
- package/src/QueryStreamKeyLabels.ts +56 -0
- package/src/QueryStreamKeyLayout.ts +382 -0
- package/src/QueryStreamKeyValues.ts +112 -0
- package/src/QueryStreamOrderDirection.ts +29 -0
- package/src/QueryStreamPagination.ts +357 -0
- package/src/QueryStreamReadBudget.ts +167 -0
- package/src/QueryTransactionContext.ts +37 -0
- package/src/RegisteredConvexFunction.ts +415 -0
- package/src/RegisteredFunction.ts +391 -0
- package/src/RegisteredFunctions.ts +88 -0
- package/src/RegisteredNodeFunction.ts +120 -0
- package/src/Registry.ts +17 -0
- package/src/RegistryItems.ts +40 -0
- package/src/RequestMetadata.ts +20 -0
- package/src/ResolvedMiddleware.ts +70 -0
- package/src/Scheduler.ts +85 -0
- package/src/Storage.ts +37 -0
- package/src/StorageActionWriter.ts +59 -0
- package/src/StorageReader.ts +59 -0
- package/src/StorageWriter.ts +58 -0
- package/src/Table.ts +156 -0
- package/src/TableInfo.ts +106 -0
- package/src/TransactionMetadata.ts +20 -0
- package/src/VectorSearch.ts +75 -0
- package/src/index.ts +87 -0
- package/src/internal/AiGatewayDecisionClient.ts +16 -0
- package/src/internal/AiGatewayLanguageClient.ts +16 -0
- package/src/internal/AiGatewayServiceToken.ts +129 -0
- package/src/internal/constants.ts +1 -0
- package/src/internal/utils.ts +89 -0
- package/src/node.ts +1 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
2
|
+
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
3
|
+
import type * as MiddlewareSpec from "@confect/core/MiddlewareSpec";
|
|
4
|
+
import * as Registry from "./Registry";
|
|
5
|
+
import * as Context from "effect/Context";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
|
+
import * as Ref from "effect/Ref";
|
|
9
|
+
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
10
|
+
import type * as Handler from "./Handler";
|
|
11
|
+
import { setNestedProperty } from "./internal/utils";
|
|
12
|
+
import * as FunctionRegistryItem from "./FunctionRegistryItem";
|
|
13
|
+
|
|
14
|
+
export interface FunctionImpl<Name_ extends string> {
|
|
15
|
+
readonly name: Name_;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const FunctionImpl = <Name_ extends string>({ name }: { name: Name_ }) =>
|
|
19
|
+
Context.Service<FunctionImpl<Name_>>(`@confect/server/FunctionImpl/${name}`);
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Register a single function's implementation into the group's `Registry`.
|
|
23
|
+
*
|
|
24
|
+
* The function is registered under a flat, single-segment key (its own `name`),
|
|
25
|
+
* not a project-wide dot-path. Each group's impl layer is built in
|
|
26
|
+
* isolation—`RegisteredFunctions.buildForGroup` (and the CLI's `validateImpl`)
|
|
27
|
+
* provide a fresh `Registry` per group—so function names only need to be unique
|
|
28
|
+
* within their own group.
|
|
29
|
+
*
|
|
30
|
+
* `databaseSchema` is retained purely as a type-level carrier: the handler's
|
|
31
|
+
* ctx-service requirements (`DatabaseReader`, `QueryCtx<DataModel>`, …) are
|
|
32
|
+
* derived from it via `Handler.WithName`. It is not read at runtime—the
|
|
33
|
+
* generated per-group registry forwards the schema value to the function
|
|
34
|
+
* builders—so impls depend on `_generated/schema` (table schemas) rather than
|
|
35
|
+
* `_generated/api` (which transitively imports every function spec).
|
|
36
|
+
*/
|
|
37
|
+
export const make = <
|
|
38
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
39
|
+
Group extends GroupSpec.AnyWithProps,
|
|
40
|
+
const Name_ extends FunctionSpec.Name<GroupSpec.Functions<Group>>,
|
|
41
|
+
>(
|
|
42
|
+
_databaseSchema: DatabaseSchema_,
|
|
43
|
+
group: Group,
|
|
44
|
+
name: Name_,
|
|
45
|
+
handler: Handler.WithName<
|
|
46
|
+
DatabaseSchema_,
|
|
47
|
+
GroupSpec.Functions<Group>,
|
|
48
|
+
Name_,
|
|
49
|
+
MiddlewareSpec.Provides<
|
|
50
|
+
| GroupSpec.MiddlewareSpecs<Group>
|
|
51
|
+
| FunctionSpec.MiddlewareSpecs<
|
|
52
|
+
FunctionSpec.WithName<GroupSpec.Functions<Group>, Name_>
|
|
53
|
+
>
|
|
54
|
+
>
|
|
55
|
+
>,
|
|
56
|
+
): Layer.Layer<FunctionImpl<Name_>> => {
|
|
57
|
+
const functionSpec = group.functions[name]!;
|
|
58
|
+
|
|
59
|
+
return Layer.effect(
|
|
60
|
+
FunctionImpl<Name_>({ name }),
|
|
61
|
+
Effect.gen(function* () {
|
|
62
|
+
const registry = yield* Registry.Registry;
|
|
63
|
+
|
|
64
|
+
yield* Ref.update(registry, (registryItems) =>
|
|
65
|
+
setNestedProperty(
|
|
66
|
+
registryItems,
|
|
67
|
+
[name],
|
|
68
|
+
FunctionRegistryItem.make({
|
|
69
|
+
functionSpec,
|
|
70
|
+
groupMiddlewareAttachments: group.middlewareAttachments,
|
|
71
|
+
handler,
|
|
72
|
+
}),
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return { name };
|
|
77
|
+
}),
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Get the function implementation service type for a specific function name.
|
|
83
|
+
*/
|
|
84
|
+
export type ForFunction<Name_ extends string> = FunctionImpl<Name_>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get all function implementation services required for a group spec.
|
|
88
|
+
*/
|
|
89
|
+
export type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =
|
|
90
|
+
FunctionSpec.Name<
|
|
91
|
+
GroupSpec.Functions<Group>
|
|
92
|
+
> extends infer FunctionNames extends string
|
|
93
|
+
? FunctionNames extends string
|
|
94
|
+
? FunctionImpl<FunctionNames>
|
|
95
|
+
: never
|
|
96
|
+
: never;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type * as MiddlewareAttachment from "@confect/core/MiddlewareAttachment";
|
|
2
|
+
import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
3
|
+
import * as Lazy from "@confect/core/Lazy";
|
|
4
|
+
import type { FunctionType, FunctionVisibility } from "convex/server";
|
|
5
|
+
import * as Match from "effect/Match";
|
|
6
|
+
import * as Predicate from "effect/Predicate";
|
|
7
|
+
import type * as Schema from "effect/Schema";
|
|
8
|
+
import type * as Handler from "./Handler";
|
|
9
|
+
|
|
10
|
+
export const TypeId = "~@confect/server/FunctionRegistryItem";
|
|
11
|
+
export type TypeId = typeof TypeId;
|
|
12
|
+
|
|
13
|
+
export const isFunctionRegistryItem = (value: unknown): value is AnyWithProps =>
|
|
14
|
+
Predicate.hasProperty(value, TypeId);
|
|
15
|
+
|
|
16
|
+
const FunctionRegistryItemProto = {
|
|
17
|
+
[TypeId]: TypeId,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A function registered by `FunctionImpl.make`, one of two shapes keyed by the
|
|
22
|
+
* spec's provenance.
|
|
23
|
+
*/
|
|
24
|
+
export type AnyWithProps =
|
|
25
|
+
| ConfectFunctionRegistryItem
|
|
26
|
+
| ConvexFunctionRegistryItem;
|
|
27
|
+
|
|
28
|
+
export interface ConfectFunctionRegistryItem {
|
|
29
|
+
readonly [TypeId]: TypeId;
|
|
30
|
+
readonly _tag: "Confect";
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly functionVisibility: FunctionVisibility;
|
|
33
|
+
readonly functionType: FunctionType;
|
|
34
|
+
readonly args: Schema.Codec<any, any>;
|
|
35
|
+
readonly returns: Schema.Codec<any, any>;
|
|
36
|
+
readonly error?: Schema.Codec<any, any>;
|
|
37
|
+
readonly middlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;
|
|
38
|
+
readonly handler: Handler.AnyConfectProvenance;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface ConvexFunctionRegistryItem {
|
|
42
|
+
readonly [TypeId]: TypeId;
|
|
43
|
+
readonly _tag: "Convex";
|
|
44
|
+
readonly handler: Handler.AnyConvexProvenance;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const make = ({
|
|
48
|
+
functionSpec,
|
|
49
|
+
groupMiddlewareAttachments,
|
|
50
|
+
handler,
|
|
51
|
+
}: {
|
|
52
|
+
functionSpec: FunctionSpec.AnyWithProps;
|
|
53
|
+
groupMiddlewareAttachments: ReadonlyArray<MiddlewareAttachment.MiddlewareAttachment>;
|
|
54
|
+
handler: Handler.Any;
|
|
55
|
+
}): AnyWithProps =>
|
|
56
|
+
Match.value(functionSpec.functionProvenance).pipe(
|
|
57
|
+
Match.tag("Convex", (): AnyWithProps =>
|
|
58
|
+
Object.assign(Object.create(FunctionRegistryItemProto), {
|
|
59
|
+
_tag: "Convex" as const,
|
|
60
|
+
handler: handler as Handler.AnyConvexProvenance,
|
|
61
|
+
}),
|
|
62
|
+
),
|
|
63
|
+
Match.tag("Confect", (provenance): AnyWithProps => {
|
|
64
|
+
const item = Object.assign(Object.create(FunctionRegistryItemProto), {
|
|
65
|
+
_tag: "Confect" as const,
|
|
66
|
+
name: functionSpec.name,
|
|
67
|
+
functionVisibility: functionSpec.functionVisibility,
|
|
68
|
+
functionType: functionSpec.runtimeAndFunctionType.functionType,
|
|
69
|
+
middlewareAttachments: [
|
|
70
|
+
...groupMiddlewareAttachments,
|
|
71
|
+
...functionSpec.middlewareAttachments,
|
|
72
|
+
],
|
|
73
|
+
handler: handler as Handler.AnyConfectProvenance,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
Lazy.defineProperty(item, "args", () => provenance.args);
|
|
77
|
+
Lazy.defineProperty(item, "returns", () => provenance.returns);
|
|
78
|
+
if ("error" in provenance) {
|
|
79
|
+
Lazy.defineProperty(item, "error", () => provenance.error);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return item as AnyWithProps;
|
|
83
|
+
}),
|
|
84
|
+
Match.exhaustive,
|
|
85
|
+
);
|
package/src/GroupImpl.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
2
|
+
import type * as MiddlewareSpec from "@confect/core/MiddlewareSpec";
|
|
3
|
+
import * as Registry from "./Registry";
|
|
4
|
+
import * as RegistryItems from "./RegistryItems";
|
|
5
|
+
import * as Array from "effect/Array";
|
|
6
|
+
import * as Context from "effect/Context";
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
import * as Option from "effect/Option";
|
|
10
|
+
import * as Predicate from "effect/Predicate";
|
|
11
|
+
import * as Ref from "effect/Ref";
|
|
12
|
+
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
13
|
+
import type * as FunctionImpl from "./FunctionImpl";
|
|
14
|
+
import type * as MiddlewareImpl from "./MiddlewareImpl";
|
|
15
|
+
|
|
16
|
+
export const TypeId = "~@confect/server/GroupImpl";
|
|
17
|
+
export type TypeId = typeof TypeId;
|
|
18
|
+
|
|
19
|
+
export type FinalizationStatus = "Unfinalized" | "Finalized";
|
|
20
|
+
|
|
21
|
+
export interface GroupImpl<
|
|
22
|
+
FinalizationStatus_ extends FinalizationStatus = "Unfinalized",
|
|
23
|
+
> {
|
|
24
|
+
readonly [TypeId]: TypeId;
|
|
25
|
+
readonly finalizationStatus: FinalizationStatus_;
|
|
26
|
+
/**
|
|
27
|
+
* Names of every function registered into this group's layer scope by
|
|
28
|
+
* `FunctionImpl.make`. Authoritative only when `finalizationStatus` is
|
|
29
|
+
* `"Finalized"`; the `"Unfinalized"` value is set to `[]` at `make`-time
|
|
30
|
+
* since the list is only known once `finalize` snapshots the registry.
|
|
31
|
+
*/
|
|
32
|
+
readonly registeredFunctionNames: ReadonlyArray<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Keys of every middleware whose implementation registered into this group's
|
|
35
|
+
* layer scope via `MiddlewareImpl.make` (and friends). Same authoritativeness
|
|
36
|
+
* caveat as `registeredFunctionNames`. Lets consumers (the CLI's
|
|
37
|
+
* `validateImpl`) verify middleware-impl completeness against a `GroupSpec`'s
|
|
38
|
+
* attached middleware without inspecting the `Registry`.
|
|
39
|
+
*/
|
|
40
|
+
readonly registeredMiddlewareKeys: ReadonlyArray<string>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface Any extends GroupImpl<FinalizationStatus> {}
|
|
44
|
+
|
|
45
|
+
export const isGroupImpl = (u: unknown): u is Any =>
|
|
46
|
+
Predicate.hasProperty(u, TypeId);
|
|
47
|
+
|
|
48
|
+
export interface AnyFinalized extends GroupImpl<"Finalized"> {}
|
|
49
|
+
export interface AnyUnfinalized extends GroupImpl<"Unfinalized"> {}
|
|
50
|
+
|
|
51
|
+
export const isFinalizedGroupImpl = (u: unknown): u is AnyFinalized =>
|
|
52
|
+
isGroupImpl(u) && u.finalizationStatus === "Finalized";
|
|
53
|
+
|
|
54
|
+
export const isUnfinalizedGroupImpl = (u: unknown): u is AnyUnfinalized =>
|
|
55
|
+
isGroupImpl(u) && u.finalizationStatus === "Unfinalized";
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Build the runtime tag for a `GroupImpl` service. The finalization status is
|
|
59
|
+
* embedded in the tag string so that `Unfinalized` and `Finalized` are distinct
|
|
60
|
+
* services at runtime; consumers of a finalized layer (the server's
|
|
61
|
+
* `RegisteredFunctions.buildForGroup` and the CLI's `validateImpl`) retrieve
|
|
62
|
+
* the typed `Finalized` service directly rather than scanning the context.
|
|
63
|
+
*
|
|
64
|
+
* The tag is keyed only by finalization status—no group path—because each
|
|
65
|
+
* group's impl layer is built in its own isolated scope
|
|
66
|
+
* (`buildForGroup`/`validateImpl` each provide a fresh `Registry`), so at most
|
|
67
|
+
* one `GroupImpl` service of each status exists per build.
|
|
68
|
+
*/
|
|
69
|
+
export const GroupImpl = <FinalizationStatus_ extends FinalizationStatus>({
|
|
70
|
+
finalizationStatus,
|
|
71
|
+
}: {
|
|
72
|
+
finalizationStatus: FinalizationStatus_;
|
|
73
|
+
}) =>
|
|
74
|
+
Context.Service<GroupImpl<FinalizationStatus_>>(
|
|
75
|
+
`@confect/server/GroupImpl/${finalizationStatus}`,
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Begin a group's impl layer. `databaseSchema` and `group` are retained only as
|
|
80
|
+
* type-level carriers (`group` drives the required `FunctionImpl` services via
|
|
81
|
+
* `FromGroupSpec<Group>`; `databaseSchema` keeps the impl's dependency on
|
|
82
|
+
* `_generated/schema` symmetric with `FunctionImpl.make`). Neither is read at
|
|
83
|
+
* runtime.
|
|
84
|
+
*/
|
|
85
|
+
export const make = <
|
|
86
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
87
|
+
Group extends GroupSpec.AnyWithProps,
|
|
88
|
+
>(
|
|
89
|
+
_databaseSchema: DatabaseSchema_,
|
|
90
|
+
_group: Group &
|
|
91
|
+
MiddlewareSpec.ValidateImplRequires<
|
|
92
|
+
GroupSpec.Functions<Group>,
|
|
93
|
+
GroupSpec.MiddlewareSpecs<Group>
|
|
94
|
+
>,
|
|
95
|
+
): Layer.Layer<
|
|
96
|
+
GroupImpl<"Unfinalized">,
|
|
97
|
+
never,
|
|
98
|
+
FunctionImpl.FromGroupSpec<Group> | MiddlewareImpl.FromGroupSpec<Group>
|
|
99
|
+
> =>
|
|
100
|
+
Layer.succeed(
|
|
101
|
+
GroupImpl<"Unfinalized">({ finalizationStatus: "Unfinalized" }),
|
|
102
|
+
{
|
|
103
|
+
[TypeId]: TypeId,
|
|
104
|
+
finalizationStatus: "Unfinalized" as const,
|
|
105
|
+
registeredFunctionNames: [],
|
|
106
|
+
registeredMiddlewareKeys: [],
|
|
107
|
+
},
|
|
108
|
+
) as Layer.Layer<
|
|
109
|
+
GroupImpl<"Unfinalized">,
|
|
110
|
+
never,
|
|
111
|
+
FunctionImpl.FromGroupSpec<Group> | MiddlewareImpl.FromGroupSpec<Group>
|
|
112
|
+
>;
|
|
113
|
+
|
|
114
|
+
const findUnfinalizedGroupImpl = <S>(
|
|
115
|
+
context: Context.Context<S>,
|
|
116
|
+
): Option.Option<AnyUnfinalized> =>
|
|
117
|
+
Array.findFirst(context.mapUnsafe.values(), isUnfinalizedGroupImpl);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Mark a `GroupImpl` layer as fully implemented. The parameter type defaults
|
|
121
|
+
* `RIn = never`, so passing a layer that still requires any `FunctionImpl`
|
|
122
|
+
* service produces a type error at the impl author's site. The codegen boundary
|
|
123
|
+
* requires the resulting `"Finalized"` brand, so omitting this call is also
|
|
124
|
+
* rejected downstream.
|
|
125
|
+
*
|
|
126
|
+
* As a side effect of finalization, the names of every `FunctionImpl` that
|
|
127
|
+
* registered into this group's scope are snapshotted onto the produced service
|
|
128
|
+
* value's `registeredFunctionNames` field, so consumers can verify impl
|
|
129
|
+
* completeness against a `GroupSpec`'s expected functions without having to
|
|
130
|
+
* inspect the `Registry` themselves.
|
|
131
|
+
*/
|
|
132
|
+
export const finalize = (
|
|
133
|
+
group: Layer.Layer<GroupImpl<"Unfinalized">>,
|
|
134
|
+
): Layer.Layer<GroupImpl<"Finalized">> =>
|
|
135
|
+
Layer.flatMap(group, (context): Layer.Layer<GroupImpl<"Finalized">> =>
|
|
136
|
+
findUnfinalizedGroupImpl(context).pipe(
|
|
137
|
+
Option.match({
|
|
138
|
+
onNone: () =>
|
|
139
|
+
Layer.effect(
|
|
140
|
+
GroupImpl<"Finalized">({ finalizationStatus: "Finalized" }),
|
|
141
|
+
Effect.die(
|
|
142
|
+
new Error(
|
|
143
|
+
"GroupImpl.finalize: no Unfinalized GroupImpl service was found in the layer's context.",
|
|
144
|
+
),
|
|
145
|
+
),
|
|
146
|
+
),
|
|
147
|
+
onSome: () =>
|
|
148
|
+
Layer.effect(
|
|
149
|
+
GroupImpl<"Finalized">({ finalizationStatus: "Finalized" }),
|
|
150
|
+
Effect.gen(function* () {
|
|
151
|
+
const registry = yield* Registry.Registry;
|
|
152
|
+
const items = yield* Ref.get(registry);
|
|
153
|
+
return {
|
|
154
|
+
[TypeId]: TypeId,
|
|
155
|
+
finalizationStatus: "Finalized" as const,
|
|
156
|
+
registeredFunctionNames: RegistryItems.functionNames(items),
|
|
157
|
+
registeredMiddlewareKeys: RegistryItems.middlewareKeys(items),
|
|
158
|
+
};
|
|
159
|
+
}),
|
|
160
|
+
),
|
|
161
|
+
}),
|
|
162
|
+
),
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
export type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =
|
|
166
|
+
| FunctionImpl.FromGroupSpec<Group>
|
|
167
|
+
| MiddlewareImpl.FromGroupSpec<Group>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import type * as Layer from "effect/Layer";
|
|
3
|
+
import * as Ref from "effect/Ref";
|
|
4
|
+
import * as Registry from "./Registry";
|
|
5
|
+
import type * as RegistryItems from "./RegistryItems";
|
|
6
|
+
import type * as GroupImpl from "./GroupImpl";
|
|
7
|
+
import * as MiddlewareRegistryItem from "./MiddlewareRegistryItem";
|
|
8
|
+
|
|
9
|
+
export const make = (
|
|
10
|
+
groupLayer: Layer.Layer<GroupImpl.GroupImpl<"Finalized">>,
|
|
11
|
+
) => {
|
|
12
|
+
const registryItems = Effect.gen(function* () {
|
|
13
|
+
const registry = yield* Registry.Registry;
|
|
14
|
+
return yield* Ref.get(registry);
|
|
15
|
+
}).pipe(
|
|
16
|
+
Effect.provide(groupLayer),
|
|
17
|
+
Effect.provideService(
|
|
18
|
+
Registry.Registry,
|
|
19
|
+
Ref.makeUnsafe<RegistryItems.RegistryItems>({}),
|
|
20
|
+
),
|
|
21
|
+
Effect.runSync,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return partitionRegistryItems(registryItems);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const partitionRegistryItems = (registryItems: RegistryItems.RegistryItems) => {
|
|
28
|
+
const middlewareRegistryItems = new Map<
|
|
29
|
+
string,
|
|
30
|
+
MiddlewareRegistryItem.MiddlewareRegistryItem
|
|
31
|
+
>();
|
|
32
|
+
const functionRegistryItems: Record<string, unknown> = {};
|
|
33
|
+
for (const [key, value] of Object.entries(registryItems)) {
|
|
34
|
+
if (MiddlewareRegistryItem.isMiddlewareRegistryItem(value)) {
|
|
35
|
+
middlewareRegistryItems.set(value.middlewareSpec.key, value);
|
|
36
|
+
} else {
|
|
37
|
+
functionRegistryItems[key] = value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return { functionRegistryItems, middlewareRegistryItems };
|
|
41
|
+
};
|
package/src/Handler.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import type { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
2
|
+
import type * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
3
|
+
import type * as NodeServices from "@effect/platform-node/NodeServices";
|
|
4
|
+
import type { Effect } from "effect";
|
|
5
|
+
import type * as ActionCtx from "./ActionCtx";
|
|
6
|
+
import type * as ActionRunner from "./ActionRunner";
|
|
7
|
+
import type * as Auth from "./Auth";
|
|
8
|
+
import type * as DatabaseReader from "./DatabaseReader";
|
|
9
|
+
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
10
|
+
import type * as DatabaseWriter from "./DatabaseWriter";
|
|
11
|
+
import type * as DataModel from "./DataModel";
|
|
12
|
+
import type { ExecutionMetadata } from "./ExecutionMetadata";
|
|
13
|
+
import type { RequestMetadata } from "./RequestMetadata";
|
|
14
|
+
import type { TransactionMetadata } from "./TransactionMetadata";
|
|
15
|
+
import type * as MutationCtx from "./MutationCtx";
|
|
16
|
+
import type * as MutationRunner from "./MutationRunner";
|
|
17
|
+
import type { MutationTransactionContext } from "./MutationTransactionContext";
|
|
18
|
+
import type * as QueryCtx from "./QueryCtx";
|
|
19
|
+
import type * as QueryRunner from "./QueryRunner";
|
|
20
|
+
import type { QueryTransactionContext } from "./QueryTransactionContext";
|
|
21
|
+
import type * as RegisteredFunction from "./RegisteredFunction";
|
|
22
|
+
import type * as Scheduler from "./Scheduler";
|
|
23
|
+
import type { Storage } from "./Storage";
|
|
24
|
+
import type * as StorageActionWriter from "./StorageActionWriter";
|
|
25
|
+
import type * as StorageReader from "./StorageReader";
|
|
26
|
+
import type * as StorageWriter from "./StorageWriter";
|
|
27
|
+
import type * as VectorSearch from "./VectorSearch";
|
|
28
|
+
|
|
29
|
+
export type Handler<
|
|
30
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
31
|
+
FunctionSpec_ extends FunctionSpec.AnyWithProps,
|
|
32
|
+
R = never,
|
|
33
|
+
> =
|
|
34
|
+
FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<
|
|
35
|
+
FunctionSpec_,
|
|
36
|
+
FunctionProvenance.AnyConvex
|
|
37
|
+
>
|
|
38
|
+
? ConvexProvenanceHandler<FunctionSpec_>
|
|
39
|
+
: FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<
|
|
40
|
+
FunctionSpec_,
|
|
41
|
+
FunctionProvenance.AnyConfect
|
|
42
|
+
>
|
|
43
|
+
? ConfectProvenanceHandler<DatabaseSchema_, FunctionSpec_, R>
|
|
44
|
+
: never;
|
|
45
|
+
|
|
46
|
+
type ConvexProvenanceHandler<
|
|
47
|
+
FunctionSpec_ extends
|
|
48
|
+
FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConvex>,
|
|
49
|
+
> = RegisteredFunction.ConvexRegisteredFunction<FunctionSpec_>;
|
|
50
|
+
|
|
51
|
+
type ConfectProvenanceHandler<
|
|
52
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
53
|
+
FunctionSpec_ extends
|
|
54
|
+
FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConfect>,
|
|
55
|
+
R = never,
|
|
56
|
+
> =
|
|
57
|
+
FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "query">
|
|
58
|
+
? ConfectProvenanceQuery<DatabaseSchema_, FunctionSpec_, R>
|
|
59
|
+
: FunctionSpec_ extends FunctionSpec.WithFunctionType<
|
|
60
|
+
FunctionSpec_,
|
|
61
|
+
"mutation"
|
|
62
|
+
>
|
|
63
|
+
? ConfectProvenanceMutation<DatabaseSchema_, FunctionSpec_, R>
|
|
64
|
+
: FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<
|
|
65
|
+
FunctionSpec_,
|
|
66
|
+
RuntimeAndFunctionType.ConvexAction
|
|
67
|
+
>
|
|
68
|
+
? ConvexRuntimeAction<DatabaseSchema_, FunctionSpec_, R>
|
|
69
|
+
: FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<
|
|
70
|
+
FunctionSpec_,
|
|
71
|
+
RuntimeAndFunctionType.NodeAction
|
|
72
|
+
>
|
|
73
|
+
? NodeRuntimeAction<DatabaseSchema_, FunctionSpec_, R>
|
|
74
|
+
: never;
|
|
75
|
+
|
|
76
|
+
export type QueryServices<
|
|
77
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
78
|
+
> =
|
|
79
|
+
| DatabaseReader.DatabaseReader<DatabaseSchema_>
|
|
80
|
+
| (DatabaseSchema_["target"]["kind"] extends "component" ? never : Auth.Auth)
|
|
81
|
+
| StorageReader.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
82
|
+
| ExecutionMetadata
|
|
83
|
+
| TransactionMetadata
|
|
84
|
+
| (DatabaseSchema_["target"]["kind"] extends "component" ? never : Storage)
|
|
85
|
+
| QueryRunner.QueryRunner
|
|
86
|
+
| QueryTransactionContext
|
|
87
|
+
| QueryCtx.QueryCtx<
|
|
88
|
+
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>,
|
|
89
|
+
DatabaseSchema.Scope<DatabaseSchema_>
|
|
90
|
+
>;
|
|
91
|
+
|
|
92
|
+
export type MutationServices<
|
|
93
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
94
|
+
> =
|
|
95
|
+
| DatabaseReader.DatabaseReader<DatabaseSchema_>
|
|
96
|
+
| DatabaseWriter.DatabaseWriter<DatabaseSchema_>
|
|
97
|
+
| (DatabaseSchema_["target"]["kind"] extends "component" ? never : Auth.Auth)
|
|
98
|
+
| Scheduler.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
99
|
+
| StorageReader.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
100
|
+
| StorageWriter.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
101
|
+
| ExecutionMetadata
|
|
102
|
+
| TransactionMetadata
|
|
103
|
+
| RequestMetadata
|
|
104
|
+
| (DatabaseSchema_["target"]["kind"] extends "component" ? never : Storage)
|
|
105
|
+
| QueryRunner.QueryRunner
|
|
106
|
+
| MutationRunner.MutationRunner
|
|
107
|
+
| QueryTransactionContext
|
|
108
|
+
| MutationTransactionContext
|
|
109
|
+
| MutationCtx.MutationCtx<
|
|
110
|
+
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>,
|
|
111
|
+
DatabaseSchema.Scope<DatabaseSchema_>
|
|
112
|
+
>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Shared by both action runtimes.
|
|
116
|
+
*/
|
|
117
|
+
export type ActionServices<
|
|
118
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
119
|
+
> =
|
|
120
|
+
| Scheduler.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
121
|
+
| (DatabaseSchema_["target"]["kind"] extends "component" ? never : Auth.Auth)
|
|
122
|
+
| StorageReader.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
123
|
+
| StorageWriter.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
124
|
+
| StorageActionWriter.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
125
|
+
| ExecutionMetadata
|
|
126
|
+
| RequestMetadata
|
|
127
|
+
| (DatabaseSchema_["target"]["kind"] extends "component" ? never : Storage)
|
|
128
|
+
| QueryRunner.QueryRunner
|
|
129
|
+
| MutationRunner.MutationRunner
|
|
130
|
+
| ActionRunner.ActionRunner
|
|
131
|
+
| VectorSearch.VectorSearch<DataModel.FromSchema<DatabaseSchema_>>
|
|
132
|
+
| ActionCtx.ActionCtx<
|
|
133
|
+
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>,
|
|
134
|
+
DatabaseSchema.Scope<DatabaseSchema_>
|
|
135
|
+
>;
|
|
136
|
+
|
|
137
|
+
export type ConfectProvenanceQuery<
|
|
138
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
139
|
+
FunctionSpec_ extends
|
|
140
|
+
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>,
|
|
141
|
+
R = never,
|
|
142
|
+
> = Base<FunctionSpec_, QueryServices<DatabaseSchema_> | R>;
|
|
143
|
+
|
|
144
|
+
export type ConfectProvenanceMutation<
|
|
145
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
146
|
+
FunctionSpec_ extends
|
|
147
|
+
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>,
|
|
148
|
+
R = never,
|
|
149
|
+
> = Base<FunctionSpec_, MutationServices<DatabaseSchema_> | R>;
|
|
150
|
+
|
|
151
|
+
export type ConvexRuntimeAction<
|
|
152
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
153
|
+
FunctionSpec_ extends
|
|
154
|
+
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>,
|
|
155
|
+
R = never,
|
|
156
|
+
> = Base<FunctionSpec_, ActionServices<DatabaseSchema_> | R>;
|
|
157
|
+
|
|
158
|
+
export type NodeRuntimeAction<
|
|
159
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
160
|
+
FunctionSpec_ extends
|
|
161
|
+
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>,
|
|
162
|
+
R = never,
|
|
163
|
+
> = Base<
|
|
164
|
+
FunctionSpec_,
|
|
165
|
+
ActionServices<DatabaseSchema_> | NodeServices.NodeServices | R
|
|
166
|
+
>;
|
|
167
|
+
|
|
168
|
+
type Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (
|
|
169
|
+
args: FunctionSpec.Args<FunctionSpec_>,
|
|
170
|
+
) => Effect.Effect<
|
|
171
|
+
FunctionSpec.Returns<FunctionSpec_>,
|
|
172
|
+
FunctionSpec.Error<FunctionSpec_>,
|
|
173
|
+
R
|
|
174
|
+
>;
|
|
175
|
+
|
|
176
|
+
export type Any = AnyConfectProvenance | AnyConvexProvenance;
|
|
177
|
+
|
|
178
|
+
export type AnyConfectProvenance = Base<FunctionSpec.AnyConfect, any>;
|
|
179
|
+
|
|
180
|
+
export type AnyConvexProvenance = RegisteredFunction.Any;
|
|
181
|
+
|
|
182
|
+
export type WithName<
|
|
183
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
184
|
+
FunctionSpec_ extends FunctionSpec.AnyWithProps,
|
|
185
|
+
FunctionName extends string,
|
|
186
|
+
R = never,
|
|
187
|
+
> = Handler<
|
|
188
|
+
DatabaseSchema_,
|
|
189
|
+
FunctionSpec.WithName<FunctionSpec_, FunctionName>,
|
|
190
|
+
R
|
|
191
|
+
>;
|