@gaganref/confect-server 0.0.0-stage → 10.3.1-fork.10
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,415 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compileArgsSchema,
|
|
3
|
+
compileReturnsSchema,
|
|
4
|
+
} from "@confect/core/SchemaToValidator";
|
|
5
|
+
import {
|
|
6
|
+
actionGeneric,
|
|
7
|
+
type DefaultFunctionArgs,
|
|
8
|
+
type FunctionVisibility,
|
|
9
|
+
type GenericMutationCtx,
|
|
10
|
+
type GenericQueryCtx,
|
|
11
|
+
internalActionGeneric,
|
|
12
|
+
internalMutationGeneric,
|
|
13
|
+
internalQueryGeneric,
|
|
14
|
+
mutationGeneric,
|
|
15
|
+
queryGeneric,
|
|
16
|
+
} from "convex/server";
|
|
17
|
+
import type { Value } from "convex/values";
|
|
18
|
+
import { pipe } from "effect/Function";
|
|
19
|
+
import * as Clock from "effect/Clock";
|
|
20
|
+
import * as Data from "effect/Data";
|
|
21
|
+
import * as Duration from "effect/Duration";
|
|
22
|
+
import * as Effect from "effect/Effect";
|
|
23
|
+
import * as Layer from "effect/Layer";
|
|
24
|
+
import * as Match from "effect/Match";
|
|
25
|
+
import * as Schema from "effect/Schema";
|
|
26
|
+
import * as EffectScheduler from "effect/Scheduler";
|
|
27
|
+
import * as Auth from "./Auth.js";
|
|
28
|
+
import * as ConvexConfigProvider from "./ConvexConfigProvider.js";
|
|
29
|
+
import * as DatabaseReader from "./DatabaseReader.js";
|
|
30
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
31
|
+
import * as DatabaseWriter from "./DatabaseWriter.js";
|
|
32
|
+
import type * as DataModel from "./DataModel.js";
|
|
33
|
+
import * as ExecutionMetadata from "./ExecutionMetadata.js";
|
|
34
|
+
import * as RequestMetadata from "./RequestMetadata.js";
|
|
35
|
+
import * as TransactionMetadata from "./TransactionMetadata.js";
|
|
36
|
+
import * as MutationCtx from "./MutationCtx.js";
|
|
37
|
+
import * as MutationRunner from "./MutationRunner.js";
|
|
38
|
+
import * as MutationTransactionContext from "./MutationTransactionContext.js";
|
|
39
|
+
import * as QueryCtx from "./QueryCtx.js";
|
|
40
|
+
import * as QueryRunner from "./QueryRunner.js";
|
|
41
|
+
import * as QueryTransactionContext from "./QueryTransactionContext.js";
|
|
42
|
+
import * as RegisteredFunction from "./RegisteredFunction.js";
|
|
43
|
+
import type * as FunctionRegistryItem from "./FunctionRegistryItem.js";
|
|
44
|
+
import type * as ResolvedMiddleware from "./ResolvedMiddleware.js";
|
|
45
|
+
import * as Scheduler from "./Scheduler.js";
|
|
46
|
+
import { StorageWriter } from "./StorageWriter.js";
|
|
47
|
+
import type * as Handler from "./Handler.js";
|
|
48
|
+
|
|
49
|
+
export type Definition = Data.TaggedEnum<{
|
|
50
|
+
PublicQuery: ReturnType<typeof queryFunction>;
|
|
51
|
+
InternalQuery: ReturnType<typeof queryFunction>;
|
|
52
|
+
PublicMutation: ReturnType<typeof mutationFunction>;
|
|
53
|
+
InternalMutation: ReturnType<typeof mutationFunction>;
|
|
54
|
+
PublicAction: ReturnType<typeof convexActionFunction>;
|
|
55
|
+
InternalAction: ReturnType<typeof convexActionFunction>;
|
|
56
|
+
Registered: { readonly handler: RegisteredFunction.Any };
|
|
57
|
+
}>;
|
|
58
|
+
export const Definition = Data.taggedEnum<Definition>();
|
|
59
|
+
|
|
60
|
+
export const prepare = (
|
|
61
|
+
databaseSchema: DatabaseSchema.AnyWithProps,
|
|
62
|
+
item: FunctionRegistryItem.ConfectFunctionRegistryItem,
|
|
63
|
+
resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware> = [],
|
|
64
|
+
) =>
|
|
65
|
+
Match.value(item.functionType).pipe(
|
|
66
|
+
Match.when("query", () => {
|
|
67
|
+
const definition = queryFunction({
|
|
68
|
+
databaseSchema,
|
|
69
|
+
name: item.name,
|
|
70
|
+
functionVisibility: item.functionVisibility,
|
|
71
|
+
args: item.args,
|
|
72
|
+
returns: item.returns,
|
|
73
|
+
error: item.error,
|
|
74
|
+
handler: item.handler,
|
|
75
|
+
resolvedMiddlewares,
|
|
76
|
+
});
|
|
77
|
+
return Match.value(item.functionVisibility).pipe(
|
|
78
|
+
Match.when("public", () => Definition.PublicQuery(definition)),
|
|
79
|
+
Match.when("internal", () => Definition.InternalQuery(definition)),
|
|
80
|
+
Match.exhaustive,
|
|
81
|
+
);
|
|
82
|
+
}),
|
|
83
|
+
Match.when("mutation", () => {
|
|
84
|
+
const definition = mutationFunction({
|
|
85
|
+
databaseSchema,
|
|
86
|
+
name: item.name,
|
|
87
|
+
functionVisibility: item.functionVisibility,
|
|
88
|
+
args: item.args,
|
|
89
|
+
returns: item.returns,
|
|
90
|
+
error: item.error,
|
|
91
|
+
handler: item.handler,
|
|
92
|
+
resolvedMiddlewares,
|
|
93
|
+
});
|
|
94
|
+
return Match.value(item.functionVisibility).pipe(
|
|
95
|
+
Match.when("public", () => Definition.PublicMutation(definition)),
|
|
96
|
+
Match.when("internal", () => Definition.InternalMutation(definition)),
|
|
97
|
+
Match.exhaustive,
|
|
98
|
+
);
|
|
99
|
+
}),
|
|
100
|
+
Match.when("action", () => {
|
|
101
|
+
const definition = convexActionFunction(databaseSchema, {
|
|
102
|
+
name: item.name,
|
|
103
|
+
functionVisibility: item.functionVisibility,
|
|
104
|
+
args: item.args,
|
|
105
|
+
returns: item.returns,
|
|
106
|
+
error: item.error,
|
|
107
|
+
handler: item.handler,
|
|
108
|
+
resolvedMiddlewares,
|
|
109
|
+
});
|
|
110
|
+
return Match.value(item.functionVisibility).pipe(
|
|
111
|
+
Match.when("public", () => Definition.PublicAction(definition)),
|
|
112
|
+
Match.when("internal", () => Definition.InternalAction(definition)),
|
|
113
|
+
Match.exhaustive,
|
|
114
|
+
);
|
|
115
|
+
}),
|
|
116
|
+
Match.exhaustive,
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
export const make = (
|
|
120
|
+
databaseSchema: DatabaseSchema.AnyWithProps,
|
|
121
|
+
item: FunctionRegistryItem.ConfectFunctionRegistryItem,
|
|
122
|
+
resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware> = [],
|
|
123
|
+
): RegisteredFunction.Any =>
|
|
124
|
+
register(prepare(databaseSchema, item, resolvedMiddlewares));
|
|
125
|
+
|
|
126
|
+
export const register = (self: Definition): RegisteredFunction.Any =>
|
|
127
|
+
Definition.$match(self, {
|
|
128
|
+
PublicQuery: (definition) => queryGeneric(definition),
|
|
129
|
+
InternalQuery: (definition) => internalQueryGeneric(definition),
|
|
130
|
+
PublicMutation: (definition) => mutationGeneric(definition),
|
|
131
|
+
InternalMutation: (definition) => internalMutationGeneric(definition),
|
|
132
|
+
PublicAction: (definition) => actionGeneric(definition),
|
|
133
|
+
InternalAction: (definition) => internalActionGeneric(definition),
|
|
134
|
+
Registered: ({ handler }) => handler,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Convex evicts a query from its cache once the execution observes the current
|
|
139
|
+
* time (every `Date.now()` read is tracked). Effect's logging, span, and
|
|
140
|
+
* elapsed-time machinery reads timestamps through the ambient `Clock`'s unsafe
|
|
141
|
+
* accessors, which would silently opt any logging or timing query out of the
|
|
142
|
+
* cache—and there is no untracked time source in the isolate to serve them
|
|
143
|
+
* from, since Effect's own live clock falls back to `Date.now()` for monotonic
|
|
144
|
+
* time when neither `process.hrtime` nor `performance.now` exists. Queries
|
|
145
|
+
* therefore run with a `Clock` whose unsafe accessors all return constants, so
|
|
146
|
+
* logging and spans never touch the tracker and `Effect.timed` and duration
|
|
147
|
+
* metrics report a zero elapsed time, while the effectful accessors
|
|
148
|
+
* (`Clock.currentTimeMillis`/`currentTimeNanos`/`monotonicTimeNanos`) read the
|
|
149
|
+
* real time, making them an explicit opt-in to cache eviction. Raw `Date.now()`
|
|
150
|
+
* calls in handler code likewise opt out honestly.
|
|
151
|
+
*/
|
|
152
|
+
const queryClock: Clock.Clock = {
|
|
153
|
+
currentTimeMillisUnsafe: () => 0,
|
|
154
|
+
currentTimeNanosUnsafe: () => 0n,
|
|
155
|
+
monotonicTimeNanosUnsafe: () => 0n,
|
|
156
|
+
// oxlint-disable-next-line effecttsgo/global-date-in-effect -- This access intentionally notifies Convex's query-cache tracker.
|
|
157
|
+
currentTimeMillis: Effect.sync(() => Date.now()),
|
|
158
|
+
// oxlint-disable-next-line effecttsgo/global-date-in-effect -- This access intentionally notifies Convex's query-cache tracker.
|
|
159
|
+
currentTimeNanos: Effect.sync(() => BigInt(Date.now()) * 1_000_000n),
|
|
160
|
+
// oxlint-disable-next-line effecttsgo/global-date-in-effect -- This access intentionally notifies Convex's query-cache tracker.
|
|
161
|
+
monotonicTimeNanos: Effect.sync(() => BigInt(Date.now()) * 1_000_000n),
|
|
162
|
+
// `Effect.sleep` resolves the ambient clock, so it cannot be used here—it
|
|
163
|
+
// would recurse straight back into this `sleep`.
|
|
164
|
+
sleep: (duration) =>
|
|
165
|
+
Effect.callback<void>((resume) => {
|
|
166
|
+
// oxlint-disable-next-line effecttsgo/global-timers-in-effect -- Effect.sleep would resolve this Clock and recurse.
|
|
167
|
+
const handle = setTimeout(
|
|
168
|
+
() => resume(Effect.void),
|
|
169
|
+
Duration.toMillis(duration),
|
|
170
|
+
);
|
|
171
|
+
return Effect.sync(() => clearTimeout(handle));
|
|
172
|
+
}),
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
const queryFunction = <
|
|
176
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
177
|
+
Args,
|
|
178
|
+
ConvexArgs extends DefaultFunctionArgs,
|
|
179
|
+
Returns,
|
|
180
|
+
ConvexReturns,
|
|
181
|
+
E,
|
|
182
|
+
>({
|
|
183
|
+
databaseSchema,
|
|
184
|
+
name,
|
|
185
|
+
functionVisibility,
|
|
186
|
+
args,
|
|
187
|
+
returns,
|
|
188
|
+
error,
|
|
189
|
+
handler,
|
|
190
|
+
resolvedMiddlewares,
|
|
191
|
+
}: {
|
|
192
|
+
databaseSchema: DatabaseSchema_;
|
|
193
|
+
name: string;
|
|
194
|
+
functionVisibility: FunctionVisibility;
|
|
195
|
+
args: Schema.Codec<Args, ConvexArgs>;
|
|
196
|
+
returns: Schema.Codec<Returns, ConvexReturns>;
|
|
197
|
+
error: Schema.Codec<Error, Value> | undefined;
|
|
198
|
+
handler: (
|
|
199
|
+
a: Args,
|
|
200
|
+
) => Effect.Effect<Returns, E, Handler.QueryServices<DatabaseSchema_>>;
|
|
201
|
+
resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>;
|
|
202
|
+
}) => ({
|
|
203
|
+
args: compileArgsSchema(args, databaseSchema.target.scope),
|
|
204
|
+
returns: compileReturnsSchema(returns, databaseSchema.target.scope),
|
|
205
|
+
handler: (
|
|
206
|
+
ctx: GenericQueryCtx<
|
|
207
|
+
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>
|
|
208
|
+
>,
|
|
209
|
+
actualArgs: ConvexArgs,
|
|
210
|
+
): Promise<ConvexReturns> =>
|
|
211
|
+
Effect.gen(function* () {
|
|
212
|
+
const decodedArgs = yield* pipe(
|
|
213
|
+
actualArgs,
|
|
214
|
+
Schema.decodeUnknownEffect(args),
|
|
215
|
+
Effect.catchTag("SchemaError", Effect.die),
|
|
216
|
+
);
|
|
217
|
+
// 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.
|
|
218
|
+
const decodedReturns = yield* RegisteredFunction.applyMiddleware(
|
|
219
|
+
handler(decodedArgs),
|
|
220
|
+
resolvedMiddlewares,
|
|
221
|
+
{
|
|
222
|
+
name,
|
|
223
|
+
functionType: "query",
|
|
224
|
+
functionVisibility,
|
|
225
|
+
args: decodedArgs,
|
|
226
|
+
},
|
|
227
|
+
).pipe(
|
|
228
|
+
Effect.provide(
|
|
229
|
+
Layer.mergeAll(
|
|
230
|
+
DatabaseReader.layer(databaseSchema, ctx.db),
|
|
231
|
+
ExecutionMetadata.layer(ctx.meta),
|
|
232
|
+
TransactionMetadata.layer(ctx.meta),
|
|
233
|
+
QueryTransactionContext.layer(ctx),
|
|
234
|
+
Auth.layerForTarget<DatabaseSchema_["target"]>(
|
|
235
|
+
databaseSchema.target,
|
|
236
|
+
ctx.auth,
|
|
237
|
+
),
|
|
238
|
+
RegisteredFunction.storageLayer<
|
|
239
|
+
DatabaseSchema.Scope<DatabaseSchema_>
|
|
240
|
+
>(ctx.storage),
|
|
241
|
+
QueryRunner.layer(ctx.runQuery),
|
|
242
|
+
QueryCtx.layer<
|
|
243
|
+
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>,
|
|
244
|
+
DatabaseSchema.Scope<DatabaseSchema_>
|
|
245
|
+
>(ctx, databaseSchema.target.scope),
|
|
246
|
+
ConvexConfigProvider.layer,
|
|
247
|
+
),
|
|
248
|
+
),
|
|
249
|
+
);
|
|
250
|
+
return yield* pipe(
|
|
251
|
+
decodedReturns,
|
|
252
|
+
Schema.encodeEffect(returns),
|
|
253
|
+
Effect.catchTag("SchemaError", Effect.die),
|
|
254
|
+
);
|
|
255
|
+
}).pipe(
|
|
256
|
+
Effect.provideService(Clock.Clock, queryClock),
|
|
257
|
+
RegisteredFunction.runHandlerPromise(
|
|
258
|
+
RegisteredFunction.combineErrorSchemas(error, resolvedMiddlewares),
|
|
259
|
+
{
|
|
260
|
+
scheduler: new EffectScheduler.MixedScheduler("sync"),
|
|
261
|
+
},
|
|
262
|
+
),
|
|
263
|
+
),
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
export const mutationLayer = <Schema extends DatabaseSchema.AnyWithProps>(
|
|
267
|
+
schema: Schema,
|
|
268
|
+
ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,
|
|
269
|
+
) =>
|
|
270
|
+
Layer.mergeAll(
|
|
271
|
+
DatabaseReader.layer(schema, ctx.db),
|
|
272
|
+
DatabaseWriter.layer(schema, ctx.db),
|
|
273
|
+
ExecutionMetadata.layer(ctx.meta),
|
|
274
|
+
RequestMetadata.layer(ctx.meta),
|
|
275
|
+
TransactionMetadata.layer(ctx.meta),
|
|
276
|
+
Auth.layerForTarget<Schema["target"]>(schema.target, ctx.auth),
|
|
277
|
+
Scheduler.layer<DatabaseSchema.Scope<Schema>>(
|
|
278
|
+
ctx.scheduler,
|
|
279
|
+
schema.target.scope,
|
|
280
|
+
),
|
|
281
|
+
RegisteredFunction.storageLayer<DatabaseSchema.Scope<Schema>>(ctx.storage),
|
|
282
|
+
StorageWriter.layer<DatabaseSchema.Scope<Schema>>(
|
|
283
|
+
ctx.storage,
|
|
284
|
+
schema.target.scope,
|
|
285
|
+
),
|
|
286
|
+
QueryRunner.layer(ctx.runQuery),
|
|
287
|
+
MutationRunner.layer(ctx.runMutation),
|
|
288
|
+
QueryTransactionContext.layer(ctx),
|
|
289
|
+
MutationTransactionContext.layer(ctx),
|
|
290
|
+
MutationCtx.layer<
|
|
291
|
+
DataModel.ToConvex<DataModel.FromSchema<Schema>>,
|
|
292
|
+
DatabaseSchema.Scope<Schema>
|
|
293
|
+
>(ctx, schema.target.scope),
|
|
294
|
+
ConvexConfigProvider.layer,
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
export type MutationServices<Schema extends DatabaseSchema.AnyWithProps> =
|
|
298
|
+
Handler.MutationServices<Schema>;
|
|
299
|
+
|
|
300
|
+
const mutationFunction = <
|
|
301
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
302
|
+
Args,
|
|
303
|
+
ConvexArgs extends DefaultFunctionArgs,
|
|
304
|
+
Returns,
|
|
305
|
+
ConvexReturns,
|
|
306
|
+
E,
|
|
307
|
+
>({
|
|
308
|
+
databaseSchema,
|
|
309
|
+
name,
|
|
310
|
+
functionVisibility,
|
|
311
|
+
args,
|
|
312
|
+
returns,
|
|
313
|
+
error,
|
|
314
|
+
handler,
|
|
315
|
+
resolvedMiddlewares,
|
|
316
|
+
}: {
|
|
317
|
+
databaseSchema: DatabaseSchema_;
|
|
318
|
+
name: string;
|
|
319
|
+
functionVisibility: FunctionVisibility;
|
|
320
|
+
args: Schema.Codec<Args, ConvexArgs>;
|
|
321
|
+
returns: Schema.Codec<Returns, ConvexReturns>;
|
|
322
|
+
error: Schema.Codec<Error, Value> | undefined;
|
|
323
|
+
handler: (
|
|
324
|
+
a: Args,
|
|
325
|
+
) => Effect.Effect<Returns, E, MutationServices<DatabaseSchema_>>;
|
|
326
|
+
resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>;
|
|
327
|
+
}) => ({
|
|
328
|
+
args: compileArgsSchema(args, databaseSchema.target.scope),
|
|
329
|
+
returns: compileReturnsSchema(returns, databaseSchema.target.scope),
|
|
330
|
+
handler: (
|
|
331
|
+
ctx: GenericMutationCtx<
|
|
332
|
+
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>
|
|
333
|
+
>,
|
|
334
|
+
actualArgs: ConvexArgs,
|
|
335
|
+
): Promise<ConvexReturns> =>
|
|
336
|
+
Effect.gen(function* () {
|
|
337
|
+
const decodedArgs = yield* pipe(
|
|
338
|
+
actualArgs,
|
|
339
|
+
Schema.decodeUnknownEffect(args),
|
|
340
|
+
Effect.catchTag("SchemaError", Effect.die),
|
|
341
|
+
);
|
|
342
|
+
// 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.
|
|
343
|
+
const decodedReturns = yield* RegisteredFunction.applyMiddleware(
|
|
344
|
+
handler(decodedArgs),
|
|
345
|
+
resolvedMiddlewares,
|
|
346
|
+
{
|
|
347
|
+
name,
|
|
348
|
+
functionType: "mutation",
|
|
349
|
+
functionVisibility,
|
|
350
|
+
args: decodedArgs,
|
|
351
|
+
},
|
|
352
|
+
).pipe(Effect.provide(mutationLayer(databaseSchema, ctx)));
|
|
353
|
+
return yield* pipe(
|
|
354
|
+
decodedReturns,
|
|
355
|
+
Schema.encodeEffect(returns),
|
|
356
|
+
Effect.catchTag("SchemaError", Effect.die),
|
|
357
|
+
);
|
|
358
|
+
}).pipe(
|
|
359
|
+
RegisteredFunction.runHandlerPromise(
|
|
360
|
+
RegisteredFunction.combineErrorSchemas(error, resolvedMiddlewares),
|
|
361
|
+
{
|
|
362
|
+
scheduler: new EffectScheduler.MixedScheduler("sync"),
|
|
363
|
+
},
|
|
364
|
+
),
|
|
365
|
+
),
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
const convexActionFunction = <
|
|
369
|
+
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
370
|
+
Args,
|
|
371
|
+
ConvexArgs extends DefaultFunctionArgs,
|
|
372
|
+
Returns,
|
|
373
|
+
ConvexReturns,
|
|
374
|
+
E,
|
|
375
|
+
>(
|
|
376
|
+
schema: DatabaseSchema_,
|
|
377
|
+
{
|
|
378
|
+
name,
|
|
379
|
+
functionVisibility,
|
|
380
|
+
args,
|
|
381
|
+
returns,
|
|
382
|
+
error,
|
|
383
|
+
handler,
|
|
384
|
+
resolvedMiddlewares,
|
|
385
|
+
}: {
|
|
386
|
+
name: string;
|
|
387
|
+
functionVisibility: FunctionVisibility;
|
|
388
|
+
args: Schema.Codec<Args, ConvexArgs>;
|
|
389
|
+
returns: Schema.Codec<Returns, ConvexReturns>;
|
|
390
|
+
error: Schema.Codec<any, any> | undefined;
|
|
391
|
+
handler: (
|
|
392
|
+
a: Args,
|
|
393
|
+
) => Effect.Effect<
|
|
394
|
+
Returns,
|
|
395
|
+
E,
|
|
396
|
+
RegisteredFunction.ActionServices<DatabaseSchema_>
|
|
397
|
+
>;
|
|
398
|
+
resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>;
|
|
399
|
+
},
|
|
400
|
+
) =>
|
|
401
|
+
RegisteredFunction.actionFunctionBase({
|
|
402
|
+
scope: schema.target.scope,
|
|
403
|
+
name,
|
|
404
|
+
functionVisibility,
|
|
405
|
+
args,
|
|
406
|
+
returns,
|
|
407
|
+
error,
|
|
408
|
+
handler,
|
|
409
|
+
resolvedMiddlewares,
|
|
410
|
+
createLayer: (ctx) =>
|
|
411
|
+
Layer.mergeAll(
|
|
412
|
+
RegisteredFunction.actionLayer(schema, ctx),
|
|
413
|
+
ConvexConfigProvider.layer,
|
|
414
|
+
),
|
|
415
|
+
});
|