@gaganref/confect-server 10.3.1-fork.4 → 10.3.1-fork.40
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/ActionCtx.d.ts +1 -1
- package/dist/ActionCtx.d.ts.map +1 -1
- package/dist/ActionCtx.js.map +1 -1
- package/dist/ActionRunner.js +2 -2
- package/dist/AiGatewayDecisionClient.d.ts +2 -2
- package/dist/AiGatewayDecisionClient.d.ts.map +1 -1
- package/dist/AiGatewayDecisionClient.js +1 -1
- package/dist/AiGatewayDecisionClient.js.map +1 -1
- package/dist/AiGatewayLanguageClient.d.ts +2 -2
- package/dist/AiGatewayLanguageClient.d.ts.map +1 -1
- package/dist/AiGatewayLanguageClient.js +1 -1
- package/dist/AiGatewayLanguageClient.js.map +1 -1
- package/dist/Auth.d.ts +14 -2
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +13 -3
- package/dist/Auth.js.map +1 -1
- package/dist/Callback.js +3 -3
- package/dist/ComponentCtx.d.ts +1 -1
- package/dist/ComponentCtx.d.ts.map +1 -1
- package/dist/ConvexConfigProvider.js +2 -2
- package/dist/ConvexFunctionDefinitions.d.ts +4 -4
- package/dist/ConvexFunctionDefinitions.d.ts.map +1 -1
- package/dist/ConvexFunctionDefinitions.js +4 -4
- package/dist/ConvexFunctionDefinitions.js.map +1 -1
- package/dist/ConvexLogger.js +1 -1
- package/dist/CronJobs.d.ts +1 -1
- package/dist/CronJobs.d.ts.map +1 -1
- package/dist/CronJobs.js +6 -6
- package/dist/CronJobs.js.map +1 -1
- package/dist/DataModel.d.ts +3 -3
- package/dist/DataModel.d.ts.map +1 -1
- package/dist/DataModel.js.map +1 -1
- package/dist/DatabaseReader.d.ts +4 -4
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseReader.js.map +1 -1
- package/dist/DatabaseSchema.d.ts +1 -1
- package/dist/DatabaseSchema.d.ts.map +1 -1
- package/dist/DatabaseSchema.js +2 -2
- package/dist/DatabaseSchema.js.map +1 -1
- package/dist/DatabaseWriter.d.ts +41 -7
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +55 -8
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/Document.d.ts +4 -4
- package/dist/Document.d.ts.map +1 -1
- package/dist/Document.js.map +1 -1
- package/dist/ExecutionMetadata.js +1 -1
- package/dist/FunctionImpl.d.ts +2 -2
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/FunctionImpl.js +2 -2
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/FunctionRegistryItem.d.ts +1 -1
- package/dist/FunctionRegistryItem.d.ts.map +1 -1
- package/dist/FunctionRegistryItem.js +1 -1
- package/dist/FunctionRegistryItem.js.map +1 -1
- package/dist/GroupImpl.d.ts +24 -5
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/GroupImpl.js +21 -22
- package/dist/GroupImpl.js.map +1 -1
- package/dist/GroupRegistry.d.ts +3 -2
- package/dist/GroupRegistry.d.ts.map +1 -1
- package/dist/GroupRegistry.js +10 -3
- package/dist/GroupRegistry.js.map +1 -1
- package/dist/Handler.d.ts +31 -27
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js.map +1 -1
- package/dist/HttpRouter.d.ts +15 -13
- package/dist/HttpRouter.d.ts.map +1 -1
- package/dist/HttpRouter.js +16 -7
- package/dist/HttpRouter.js.map +1 -1
- package/dist/MiddlewareImpl.d.ts +14 -14
- package/dist/MiddlewareImpl.d.ts.map +1 -1
- package/dist/MiddlewareImpl.js +1 -1
- package/dist/MiddlewareImpl.js.map +1 -1
- package/dist/MutationCtx.d.ts +1 -1
- package/dist/MutationCtx.d.ts.map +1 -1
- package/dist/MutationCtx.js.map +1 -1
- package/dist/MutationRunner.d.ts +1 -1
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +2 -2
- package/dist/MutationRunner.js.map +1 -1
- package/dist/MutationTransactionContext.d.ts +2 -2
- package/dist/MutationTransactionContext.d.ts.map +1 -1
- package/dist/MutationTransactionContext.js +2 -2
- package/dist/MutationTransactionContext.js.map +1 -1
- package/dist/OfficialComponent.d.ts +50 -0
- package/dist/OfficialComponent.d.ts.map +1 -0
- package/dist/OfficialComponent.js +70 -0
- package/dist/OfficialComponent.js.map +1 -0
- package/dist/OrderedQuery.d.ts +4 -4
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/OrderedQuery.js.map +1 -1
- package/dist/QueryCtx.d.ts +1 -1
- package/dist/QueryCtx.d.ts.map +1 -1
- package/dist/QueryCtx.js.map +1 -1
- package/dist/QueryInitializer.d.ts +10 -10
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryInitializer.js +2 -2
- package/dist/QueryInitializer.js.map +1 -1
- package/dist/QueryRunner.d.ts +2 -2
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +2 -2
- package/dist/QueryRunner.js.map +1 -1
- package/dist/QueryStream.d.ts +131 -23
- package/dist/QueryStream.d.ts.map +1 -1
- package/dist/QueryStream.js +142 -40
- package/dist/QueryStream.js.map +1 -1
- package/dist/QueryStreamCursor.d.ts +2 -2
- package/dist/QueryStreamCursor.d.ts.map +1 -1
- package/dist/QueryStreamCursor.js +1 -1
- package/dist/QueryStreamCursor.js.map +1 -1
- package/dist/QueryStreamIndexPrefix.d.ts +2 -2
- package/dist/QueryStreamIndexPrefix.d.ts.map +1 -1
- package/dist/QueryStreamIndexPrefix.js +1 -1
- package/dist/QueryStreamIndexPrefix.js.map +1 -1
- package/dist/QueryStreamIndexRange.d.ts +4 -4
- package/dist/QueryStreamIndexRange.d.ts.map +1 -1
- package/dist/QueryStreamIndexRange.js +2 -2
- package/dist/QueryStreamIndexRange.js.map +1 -1
- package/dist/QueryStreamKey.d.ts +2 -2
- package/dist/QueryStreamKey.d.ts.map +1 -1
- package/dist/QueryStreamKey.js +1 -1
- package/dist/QueryStreamKey.js.map +1 -1
- package/dist/QueryStreamKeyBounds.d.ts +3 -3
- package/dist/QueryStreamKeyBounds.d.ts.map +1 -1
- package/dist/QueryStreamKeyBounds.js +2 -2
- package/dist/QueryStreamKeyBounds.js.map +1 -1
- package/dist/QueryStreamKeyLayout.d.ts +1 -1
- package/dist/QueryStreamKeyLayout.d.ts.map +1 -1
- package/dist/QueryStreamKeyLayout.js +2 -2
- package/dist/QueryStreamKeyLayout.js.map +1 -1
- package/dist/QueryStreamKeyValues.d.ts +1 -1
- package/dist/QueryStreamKeyValues.d.ts.map +1 -1
- package/dist/QueryStreamKeyValues.js +1 -1
- package/dist/QueryStreamKeyValues.js.map +1 -1
- package/dist/QueryStreamPagination.d.ts +1 -1
- package/dist/QueryStreamPagination.d.ts.map +1 -1
- package/dist/QueryStreamPagination.js +1 -1
- package/dist/QueryStreamPagination.js.map +1 -1
- package/dist/QueryStreamReadBudget.d.ts +3 -2
- package/dist/QueryStreamReadBudget.d.ts.map +1 -1
- package/dist/QueryStreamReadBudget.js +7 -4
- package/dist/QueryStreamReadBudget.js.map +1 -1
- package/dist/QueryTransactionContext.js +2 -2
- package/dist/RegisteredConvexFunction.d.ts +27 -24
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +39 -26
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +51 -47
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +117 -37
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +3 -3
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +7 -7
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +8 -6
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/Registry.d.ts +1 -1
- package/dist/Registry.d.ts.map +1 -1
- package/dist/Registry.js.map +1 -1
- package/dist/RegistryItems.d.ts +7 -0
- package/dist/RegistryItems.d.ts.map +1 -1
- package/dist/RegistryItems.js +8 -3
- package/dist/RegistryItems.js.map +1 -1
- package/dist/RequestMetadata.js +1 -1
- package/dist/ResolvedMiddleware.d.ts +2 -2
- package/dist/ResolvedMiddleware.d.ts.map +1 -1
- package/dist/ResolvedMiddleware.js.map +1 -1
- package/dist/Scheduler.js +2 -2
- package/dist/Storage.d.ts +6 -6
- package/dist/Storage.d.ts.map +1 -1
- package/dist/Storage.js +1 -1
- package/dist/Storage.js.map +1 -1
- package/dist/StorageActionWriter.d.ts +1 -1
- package/dist/StorageActionWriter.d.ts.map +1 -1
- package/dist/StorageActionWriter.js +1 -1
- package/dist/StorageActionWriter.js.map +1 -1
- package/dist/StorageReader.d.ts +1 -1
- package/dist/StorageReader.d.ts.map +1 -1
- package/dist/StorageReader.js +1 -1
- package/dist/StorageReader.js.map +1 -1
- package/dist/StorageWriter.d.ts +1 -1
- package/dist/StorageWriter.d.ts.map +1 -1
- package/dist/StorageWriter.js +1 -1
- package/dist/StorageWriter.js.map +1 -1
- package/dist/TableInfo.d.ts +2 -2
- package/dist/TableInfo.d.ts.map +1 -1
- package/dist/TableInfo.js.map +1 -1
- package/dist/TransactionMetadata.js +1 -1
- package/dist/VectorSearch.d.ts +1 -1
- package/dist/VectorSearch.d.ts.map +1 -1
- package/dist/VectorSearch.js +1 -1
- package/dist/VectorSearch.js.map +1 -1
- package/dist/index.d.ts +62 -60
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -18
- package/dist/internal/AiGatewayDecisionClient.d.ts +1 -1
- package/dist/internal/AiGatewayDecisionClient.d.ts.map +1 -1
- package/dist/internal/AiGatewayDecisionClient.js +1 -1
- package/dist/internal/AiGatewayDecisionClient.js.map +1 -1
- package/dist/internal/AiGatewayLanguageClient.d.ts +1 -1
- package/dist/internal/AiGatewayLanguageClient.d.ts.map +1 -1
- package/dist/internal/AiGatewayLanguageClient.js +1 -1
- package/dist/internal/AiGatewayLanguageClient.js.map +1 -1
- package/dist/internal/AiGatewayServiceToken.js +1 -1
- package/dist/internal/DocumentPatch.d.ts +16 -0
- package/dist/internal/DocumentPatch.d.ts.map +1 -0
- package/dist/internal/DocumentPatch.js +36 -0
- package/dist/internal/DocumentPatch.js.map +1 -0
- package/dist/internal/observability.d.ts +5 -0
- package/dist/internal/observability.d.ts.map +1 -0
- package/dist/internal/observability.js +21 -0
- package/dist/internal/observability.js.map +1 -0
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/ActionCall.ts +82 -0
- package/src/ActionCtx.ts +1 -1
- package/src/AiGatewayDecisionClient.ts +3 -3
- package/src/AiGatewayLanguageClient.ts +3 -3
- package/src/Auth.ts +24 -2
- package/src/ComponentCtx.ts +1 -1
- package/src/ConvexFunctionDefinitions.ts +10 -9
- package/src/CronJobs.ts +1 -1
- package/src/DataModel.ts +3 -3
- package/src/DatabaseReader.ts +4 -4
- package/src/DatabaseSchema.ts +1 -1
- package/src/DatabaseWriter.ts +189 -31
- package/src/Document.ts +4 -4
- package/src/FunctionImpl.ts +5 -5
- package/src/FunctionRegistryItem.ts +1 -1
- package/src/GroupImpl.ts +66 -13
- package/src/GroupRegistry.ts +11 -7
- package/src/Handler.ts +44 -28
- package/src/HttpRouter.ts +71 -21
- package/src/MiddlewareImpl.ts +17 -17
- package/src/MutationCtx.ts +1 -1
- package/src/MutationRunner.ts +1 -1
- package/src/MutationTransactionContext.ts +2 -2
- package/src/OfficialComponent.ts +151 -0
- package/src/OrderedQuery.ts +4 -4
- package/src/QueryCtx.ts +1 -1
- package/src/QueryInitializer.ts +9 -9
- package/src/QueryRunner.ts +2 -2
- package/src/QueryStream.ts +406 -76
- package/src/QueryStreamCursor.ts +3 -3
- package/src/QueryStreamIndexPrefix.ts +2 -2
- package/src/QueryStreamIndexRange.ts +4 -4
- package/src/QueryStreamKey.ts +2 -2
- package/src/QueryStreamKeyBounds.ts +3 -3
- package/src/QueryStreamKeyLayout.ts +1 -1
- package/src/QueryStreamKeyValues.ts +1 -1
- package/src/QueryStreamPagination.ts +2 -2
- package/src/QueryStreamReadBudget.ts +19 -6
- package/src/RegisteredConvexFunction.ts +38 -21
- package/src/RegisteredFunction.ts +190 -60
- package/src/RegisteredFunctions.ts +4 -4
- package/src/RegisteredNodeFunction.ts +15 -9
- package/src/Registry.ts +1 -1
- package/src/RegistryItems.ts +33 -2
- package/src/ResolvedMiddleware.ts +2 -2
- package/src/Storage.ts +3 -3
- package/src/StorageActionWriter.ts +1 -1
- package/src/StorageReader.ts +1 -1
- package/src/StorageWriter.ts +1 -1
- package/src/TableInfo.ts +2 -2
- package/src/VectorSearch.ts +1 -1
- package/src/index.ts +62 -60
- package/src/internal/AiGatewayDecisionClient.ts +2 -2
- package/src/internal/AiGatewayLanguageClient.ts +2 -2
- package/src/internal/DocumentPatch.ts +87 -0
- package/src/internal/observability.ts +27 -0
- package/src/node.ts +1 -1
|
@@ -9,21 +9,21 @@ import type { Effect } from "effect";
|
|
|
9
9
|
import type { Schema } from "effect";
|
|
10
10
|
import * as Layer from "effect/Layer";
|
|
11
11
|
import * as Match from "effect/Match";
|
|
12
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
13
|
-
import * as RegisteredFunction from "./RegisteredFunction";
|
|
14
|
-
import * as FunctionRegistryItem from "./FunctionRegistryItem";
|
|
15
|
-
import * as ResolvedMiddleware from "./ResolvedMiddleware";
|
|
16
|
-
import * as GroupRegistry from "./GroupRegistry";
|
|
12
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
13
|
+
import * as RegisteredFunction from "./RegisteredFunction.js";
|
|
14
|
+
import * as FunctionRegistryItem from "./FunctionRegistryItem.js";
|
|
15
|
+
import * as ResolvedMiddleware from "./ResolvedMiddleware.js";
|
|
16
|
+
import * as GroupRegistry from "./GroupRegistry.js";
|
|
17
17
|
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
18
|
-
import type * as GroupImpl from "./GroupImpl";
|
|
19
|
-
import type * as RegisteredFunctions from "./RegisteredFunctions";
|
|
20
|
-
import { mapLeaves } from "./internal/utils";
|
|
18
|
+
import type * as GroupImpl from "./GroupImpl.js";
|
|
19
|
+
import type * as RegisteredFunctions from "./RegisteredFunctions.js";
|
|
20
|
+
import { mapLeaves } from "./internal/utils.js";
|
|
21
21
|
|
|
22
22
|
export const buildForGroup = <Group extends GroupSpec.AnyWithProps>(
|
|
23
23
|
databaseSchema: DatabaseSchema.AnyWithProps,
|
|
24
24
|
groupLayer: Layer.Layer<GroupImpl.GroupImpl<"Finalized">>,
|
|
25
25
|
): RegisteredFunctions.RegisteredFunctionsForGroupSpec<Group> => {
|
|
26
|
-
const { functionRegistryItems, middlewareRegistryItems } =
|
|
26
|
+
const { functionRegistryItems, middlewareRegistryItems, observability } =
|
|
27
27
|
GroupRegistry.make(groupLayer);
|
|
28
28
|
return mapLeaves<FunctionRegistryItem.AnyWithProps, RegisteredFunction.Any>(
|
|
29
29
|
functionRegistryItems as {
|
|
@@ -38,6 +38,7 @@ export const buildForGroup = <Group extends GroupSpec.AnyWithProps>(
|
|
|
38
38
|
databaseSchema,
|
|
39
39
|
confect,
|
|
40
40
|
ResolvedMiddleware.resolve(confect, middlewareRegistryItems),
|
|
41
|
+
observability,
|
|
41
42
|
),
|
|
42
43
|
),
|
|
43
44
|
Match.exhaustive,
|
|
@@ -49,6 +50,7 @@ export const make = (
|
|
|
49
50
|
databaseSchema: DatabaseSchema.AnyWithProps,
|
|
50
51
|
item: FunctionRegistryItem.ConfectFunctionRegistryItem,
|
|
51
52
|
resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware> = [],
|
|
53
|
+
observability?: Layer.Layer<never>,
|
|
52
54
|
): RegisteredFunction.Any => {
|
|
53
55
|
const genericFunction = Match.value(item.functionVisibility).pipe(
|
|
54
56
|
Match.when("public", () => actionGeneric),
|
|
@@ -59,6 +61,7 @@ export const make = (
|
|
|
59
61
|
return genericFunction(
|
|
60
62
|
nodeActionFunction(databaseSchema, {
|
|
61
63
|
name: item.name,
|
|
64
|
+
observability,
|
|
62
65
|
functionVisibility: item.functionVisibility,
|
|
63
66
|
args: item.args,
|
|
64
67
|
returns: item.returns,
|
|
@@ -86,6 +89,7 @@ const nodeActionFunction = <
|
|
|
86
89
|
error,
|
|
87
90
|
handler,
|
|
88
91
|
resolvedMiddlewares,
|
|
92
|
+
observability,
|
|
89
93
|
}: {
|
|
90
94
|
name: string;
|
|
91
95
|
functionVisibility: FunctionVisibility;
|
|
@@ -101,6 +105,7 @@ const nodeActionFunction = <
|
|
|
101
105
|
| NodeServices.NodeServices
|
|
102
106
|
>;
|
|
103
107
|
resolvedMiddlewares: ReadonlyArray<ResolvedMiddleware.ResolvedMiddleware>;
|
|
108
|
+
observability?: Layer.Layer<never> | undefined;
|
|
104
109
|
},
|
|
105
110
|
) =>
|
|
106
111
|
RegisteredFunction.actionFunctionBase({
|
|
@@ -112,6 +117,7 @@ const nodeActionFunction = <
|
|
|
112
117
|
error,
|
|
113
118
|
handler,
|
|
114
119
|
resolvedMiddlewares,
|
|
120
|
+
observability,
|
|
115
121
|
createLayer: (ctx) =>
|
|
116
122
|
Layer.mergeAll(
|
|
117
123
|
RegisteredFunction.actionLayer(databaseSchema, ctx),
|
package/src/Registry.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Context from "effect/Context";
|
|
2
2
|
import * as Ref from "effect/Ref";
|
|
3
|
-
import type { RegistryItems } from "./RegistryItems";
|
|
3
|
+
import type { RegistryItems } from "./RegistryItems.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Effect `Context.Reference` shared by everything that touches a group's
|
package/src/RegistryItems.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as Array from "effect/Array";
|
|
2
2
|
import { pipe } from "effect/Function";
|
|
3
3
|
import * as Record from "effect/Record";
|
|
4
|
-
import * as FunctionRegistryItem from "./FunctionRegistryItem";
|
|
5
|
-
import * as MiddlewareRegistryItem from "./MiddlewareRegistryItem";
|
|
4
|
+
import * as FunctionRegistryItem from "./FunctionRegistryItem.js";
|
|
5
|
+
import * as MiddlewareRegistryItem from "./MiddlewareRegistryItem.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Runtime tree that mirrors a `Spec`'s group structure. Values remain unknown
|
|
@@ -38,3 +38,34 @@ export const middlewareKeys = (items: RegistryItems): ReadonlyArray<string> =>
|
|
|
38
38
|
Array.filter(MiddlewareRegistryItem.isMiddlewareRegistryItem),
|
|
39
39
|
Array.map((item) => item.middlewareSpec.key),
|
|
40
40
|
);
|
|
41
|
+
|
|
42
|
+
export interface MissingMiddleware {
|
|
43
|
+
readonly functionName: string;
|
|
44
|
+
readonly middlewareKey: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const missingRequired = (
|
|
48
|
+
items: RegistryItems,
|
|
49
|
+
required: ReadonlyArray<{ readonly key: string }>,
|
|
50
|
+
groupPath = "",
|
|
51
|
+
): ReadonlyArray<MissingMiddleware> =>
|
|
52
|
+
Object.entries(items)
|
|
53
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
54
|
+
.flatMap(([functionName, value]) =>
|
|
55
|
+
FunctionRegistryItem.isFunctionRegistryItem(value)
|
|
56
|
+
? required.flatMap(({ key }) =>
|
|
57
|
+
value._tag === "Confect" &&
|
|
58
|
+
value.middlewareAttachments.some(({ spec }) => spec.key === key)
|
|
59
|
+
? []
|
|
60
|
+
: [
|
|
61
|
+
{
|
|
62
|
+
functionName:
|
|
63
|
+
groupPath === ""
|
|
64
|
+
? functionName
|
|
65
|
+
: `${groupPath}.${functionName}`,
|
|
66
|
+
middlewareKey: key,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
)
|
|
70
|
+
: [],
|
|
71
|
+
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as MiddlewareAttachment from "@confect/core/MiddlewareAttachment";
|
|
2
2
|
import type * as MiddlewareSpec from "@confect/core/MiddlewareSpec";
|
|
3
3
|
import * as Result from "effect/Result";
|
|
4
|
-
import type * as FunctionRegistryItem from "./FunctionRegistryItem";
|
|
5
|
-
import type * as MiddlewareRegistryItem from "./MiddlewareRegistryItem";
|
|
4
|
+
import type * as FunctionRegistryItem from "./FunctionRegistryItem.js";
|
|
5
|
+
import type * as MiddlewareRegistryItem from "./MiddlewareRegistryItem.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A middleware spec paired with its implementation for one function's type—the
|
package/src/Storage.ts
CHANGED
|
@@ -3,9 +3,9 @@ import type { GenericId } from "convex/values";
|
|
|
3
3
|
import * as Context from "effect/Context";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Layer from "effect/Layer";
|
|
6
|
-
import { StorageActionWriter } from "./StorageActionWriter";
|
|
7
|
-
import { StorageReader } from "./StorageReader";
|
|
8
|
-
import { StorageWriter } from "./StorageWriter";
|
|
6
|
+
import { StorageActionWriter } from "./StorageActionWriter.js";
|
|
7
|
+
import { StorageReader } from "./StorageReader.js";
|
|
8
|
+
import { StorageWriter } from "./StorageWriter.js";
|
|
9
9
|
|
|
10
10
|
const make = Effect.gen(function* () {
|
|
11
11
|
const reader = yield* StorageReader;
|
|
@@ -6,7 +6,7 @@ import { flow } from "effect/Function";
|
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
8
|
import * as Option from "effect/Option";
|
|
9
|
-
import { BlobNotFoundError } from "./BlobNotFoundError";
|
|
9
|
+
import { BlobNotFoundError } from "./BlobNotFoundError.js";
|
|
10
10
|
import type * as ScopedId from "@confect/core/GenericId";
|
|
11
11
|
|
|
12
12
|
export type Service<Scope extends IdScope.IdScope = IdScope.App> = {
|
package/src/StorageReader.ts
CHANGED
|
@@ -7,7 +7,7 @@ import * as Effect from "effect/Effect";
|
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
8
|
import * as Option from "effect/Option";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
|
-
import { BlobNotFoundError } from "./BlobNotFoundError";
|
|
10
|
+
import { BlobNotFoundError } from "./BlobNotFoundError.js";
|
|
11
11
|
import type * as ScopedId from "@confect/core/GenericId";
|
|
12
12
|
|
|
13
13
|
export type Service<Scope extends IdScope.IdScope = IdScope.App> = {
|
package/src/StorageWriter.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { pipe } from "effect/Function";
|
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
|
-
import { BlobNotFoundError } from "./BlobNotFoundError";
|
|
9
|
+
import { BlobNotFoundError } from "./BlobNotFoundError.js";
|
|
10
10
|
import type * as ScopedId from "@confect/core/GenericId";
|
|
11
11
|
|
|
12
12
|
export type Service<Scope extends IdScope.IdScope = IdScope.App> = {
|
package/src/TableInfo.ts
CHANGED
|
@@ -12,8 +12,8 @@ import type {
|
|
|
12
12
|
import type { GenericValidator } from "convex/values";
|
|
13
13
|
import type { Schema, Types } from "effect";
|
|
14
14
|
import type { WithSystemFields } from "@confect/core/SystemFields";
|
|
15
|
-
import type * as Document_ from "./Document";
|
|
16
|
-
import type * as Table from "./Table";
|
|
15
|
+
import type * as Document_ from "./Document.js";
|
|
16
|
+
import type * as Table from "./Table.js";
|
|
17
17
|
|
|
18
18
|
export declare const TypeId: "~@confect/server/TableInfo";
|
|
19
19
|
export type TypeId = typeof TypeId;
|
package/src/VectorSearch.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
import * as Context from "effect/Context";
|
|
9
9
|
import * as Effect from "effect/Effect";
|
|
10
10
|
import * as Layer from "effect/Layer";
|
|
11
|
-
import type * as DataModel from "./DataModel";
|
|
11
|
+
import type * as DataModel from "./DataModel.js";
|
|
12
12
|
|
|
13
13
|
type ConvexVectorSearch<DataModel_ extends DataModel.AnyWithProps> =
|
|
14
14
|
GenericActionCtx<DataModel.ToConvex<DataModel_>>["vectorSearch"];
|
package/src/index.ts
CHANGED
|
@@ -1,87 +1,89 @@
|
|
|
1
|
-
export * as
|
|
2
|
-
export * as
|
|
3
|
-
export * as
|
|
4
|
-
export * as
|
|
5
|
-
export * as
|
|
6
|
-
export * as
|
|
7
|
-
export * as
|
|
8
|
-
export * as
|
|
9
|
-
export * as
|
|
10
|
-
export * as
|
|
11
|
-
export * as
|
|
12
|
-
export * as
|
|
13
|
-
export * as
|
|
14
|
-
export * as
|
|
15
|
-
export * as
|
|
16
|
-
export * as
|
|
17
|
-
export * as
|
|
18
|
-
export * as
|
|
19
|
-
export * as
|
|
20
|
-
export * as
|
|
21
|
-
export * as
|
|
22
|
-
export * as
|
|
23
|
-
export * as
|
|
24
|
-
export * as
|
|
25
|
-
export * as
|
|
26
|
-
export * as
|
|
27
|
-
export * as
|
|
28
|
-
export * as
|
|
29
|
-
export * as
|
|
30
|
-
export * as
|
|
31
|
-
export * as
|
|
32
|
-
export * as
|
|
33
|
-
export * as
|
|
34
|
-
export * as
|
|
35
|
-
export * as
|
|
1
|
+
export * as ActionCall from "./ActionCall.js";
|
|
2
|
+
export * as AiGatewayDecisionClient from "./AiGatewayDecisionClient.js";
|
|
3
|
+
export * as AiGatewayDecisionModel from "./AiGatewayDecisionModel.js";
|
|
4
|
+
export * as AiGatewayLanguageClient from "./AiGatewayLanguageClient.js";
|
|
5
|
+
export * as AiGatewayLanguageModel from "./AiGatewayLanguageModel.js";
|
|
6
|
+
export * as ActionCtx from "./ActionCtx.js";
|
|
7
|
+
export * as ActionRunner from "./ActionRunner.js";
|
|
8
|
+
export * as Auth from "./Auth.js";
|
|
9
|
+
export * as BlobNotFoundError from "./BlobNotFoundError.js";
|
|
10
|
+
export * as Callback from "./Callback.js";
|
|
11
|
+
export * as ConvexConfigProvider from "./ConvexConfigProvider.js";
|
|
12
|
+
export * as ConvexFunctionDefinitions from "./ConvexFunctionDefinitions.js";
|
|
13
|
+
export * as ConvexLogger from "./ConvexLogger.js";
|
|
14
|
+
export * as CronJob from "./CronJob.js";
|
|
15
|
+
export * as CronJobs from "./CronJobs.js";
|
|
16
|
+
export * as DatabaseReader from "./DatabaseReader.js";
|
|
17
|
+
export * as DatabaseSchema from "./DatabaseSchema.js";
|
|
18
|
+
export * as DatabaseWriter from "./DatabaseWriter.js";
|
|
19
|
+
export * as DataModel from "./DataModel.js";
|
|
20
|
+
export * as Document from "./Document.js";
|
|
21
|
+
export * as ExecutionMetadata from "./ExecutionMetadata.js";
|
|
22
|
+
export * as FunctionImpl from "./FunctionImpl.js";
|
|
23
|
+
export * as FunctionRegistryItem from "./FunctionRegistryItem.js";
|
|
24
|
+
export * as GroupImpl from "./GroupImpl.js";
|
|
25
|
+
export * as Handler from "./Handler.js";
|
|
26
|
+
export * as HttpRouter from "./HttpRouter.js";
|
|
27
|
+
export * as MiddlewareImpl from "./MiddlewareImpl.js";
|
|
28
|
+
export * as MiddlewareRegistryItem from "./MiddlewareRegistryItem.js";
|
|
29
|
+
export * as MutationCtx from "./MutationCtx.js";
|
|
30
|
+
export * as MutationRunner from "./MutationRunner.js";
|
|
31
|
+
export * as MutationTransactionContext from "./MutationTransactionContext.js";
|
|
32
|
+
export * as OfficialComponent from "./OfficialComponent.js";
|
|
33
|
+
export * as OrderedQuery from "./OrderedQuery.js";
|
|
34
|
+
export * as QueryCtx from "./QueryCtx.js";
|
|
35
|
+
export * as QueryInitializer from "./QueryInitializer.js";
|
|
36
|
+
export * as QueryRunner from "./QueryRunner.js";
|
|
37
|
+
export * as QueryTransactionContext from "./QueryTransactionContext.js";
|
|
36
38
|
/**
|
|
37
39
|
* @experimental
|
|
38
40
|
*/
|
|
39
|
-
export * as QueryStream from "./QueryStream";
|
|
41
|
+
export * as QueryStream from "./QueryStream.js";
|
|
40
42
|
/**
|
|
41
43
|
* @experimental
|
|
42
44
|
*/
|
|
43
|
-
export * as QueryStreamCursor from "./QueryStreamCursor";
|
|
45
|
+
export * as QueryStreamCursor from "./QueryStreamCursor.js";
|
|
44
46
|
/**
|
|
45
47
|
* @experimental
|
|
46
48
|
*/
|
|
47
|
-
export * as QueryStreamKeyLabels from "./QueryStreamKeyLabels";
|
|
49
|
+
export * as QueryStreamKeyLabels from "./QueryStreamKeyLabels.js";
|
|
48
50
|
/**
|
|
49
51
|
* @experimental
|
|
50
52
|
*/
|
|
51
|
-
export * as QueryStreamKeyLayout from "./QueryStreamKeyLayout";
|
|
53
|
+
export * as QueryStreamKeyLayout from "./QueryStreamKeyLayout.js";
|
|
52
54
|
/**
|
|
53
55
|
* @experimental
|
|
54
56
|
*/
|
|
55
|
-
export * as QueryStreamOrderDirection from "./QueryStreamOrderDirection";
|
|
57
|
+
export * as QueryStreamOrderDirection from "./QueryStreamOrderDirection.js";
|
|
56
58
|
/**
|
|
57
59
|
* @experimental
|
|
58
60
|
*/
|
|
59
|
-
export * as QueryStreamKeyValues from "./QueryStreamKeyValues";
|
|
61
|
+
export * as QueryStreamKeyValues from "./QueryStreamKeyValues.js";
|
|
60
62
|
/**
|
|
61
63
|
* @experimental
|
|
62
64
|
*/
|
|
63
|
-
export * as QueryStreamKeyBounds from "./QueryStreamKeyBounds";
|
|
65
|
+
export * as QueryStreamKeyBounds from "./QueryStreamKeyBounds.js";
|
|
64
66
|
/**
|
|
65
67
|
* @experimental
|
|
66
68
|
*/
|
|
67
|
-
export * as QueryStreamIndexRange from "./QueryStreamIndexRange";
|
|
69
|
+
export * as QueryStreamIndexRange from "./QueryStreamIndexRange.js";
|
|
68
70
|
/**
|
|
69
71
|
* @experimental
|
|
70
72
|
*/
|
|
71
|
-
export * as QueryStreamReadBudget from "./QueryStreamReadBudget";
|
|
72
|
-
export * as RegisteredConvexFunction from "./RegisteredConvexFunction";
|
|
73
|
-
export * as RegisteredFunction from "./RegisteredFunction";
|
|
74
|
-
export * as RegisteredFunctions from "./RegisteredFunctions";
|
|
75
|
-
export * as Registry from "./Registry";
|
|
76
|
-
export * as RegistryItems from "./RegistryItems";
|
|
77
|
-
export * as ResolvedMiddleware from "./ResolvedMiddleware";
|
|
78
|
-
export * as RequestMetadata from "./RequestMetadata";
|
|
79
|
-
export * as Scheduler from "./Scheduler";
|
|
80
|
-
export * as Storage from "./Storage";
|
|
81
|
-
export * as StorageActionWriter from "./StorageActionWriter";
|
|
82
|
-
export * as StorageReader from "./StorageReader";
|
|
83
|
-
export * as StorageWriter from "./StorageWriter";
|
|
84
|
-
export * as Table from "./Table";
|
|
85
|
-
export * as TableInfo from "./TableInfo";
|
|
86
|
-
export * as TransactionMetadata from "./TransactionMetadata";
|
|
87
|
-
export * as VectorSearch from "./VectorSearch";
|
|
73
|
+
export * as QueryStreamReadBudget from "./QueryStreamReadBudget.js";
|
|
74
|
+
export * as RegisteredConvexFunction from "./RegisteredConvexFunction.js";
|
|
75
|
+
export * as RegisteredFunction from "./RegisteredFunction.js";
|
|
76
|
+
export * as RegisteredFunctions from "./RegisteredFunctions.js";
|
|
77
|
+
export * as Registry from "./Registry.js";
|
|
78
|
+
export * as RegistryItems from "./RegistryItems.js";
|
|
79
|
+
export * as ResolvedMiddleware from "./ResolvedMiddleware.js";
|
|
80
|
+
export * as RequestMetadata from "./RequestMetadata.js";
|
|
81
|
+
export * as Scheduler from "./Scheduler.js";
|
|
82
|
+
export * as Storage from "./Storage.js";
|
|
83
|
+
export * as StorageActionWriter from "./StorageActionWriter.js";
|
|
84
|
+
export * as StorageReader from "./StorageReader.js";
|
|
85
|
+
export * as StorageWriter from "./StorageWriter.js";
|
|
86
|
+
export * as Table from "./Table.js";
|
|
87
|
+
export * as TableInfo from "./TableInfo.js";
|
|
88
|
+
export * as TransactionMetadata from "./TransactionMetadata.js";
|
|
89
|
+
export * as VectorSearch from "./VectorSearch.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as OpenRouterClient from "@effect/ai-openrouter/OpenRouterClient";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import * as AiGatewayServiceToken from "./AiGatewayServiceToken";
|
|
5
|
-
import { AI_GATEWAY_API_URL } from "./constants";
|
|
4
|
+
import * as AiGatewayServiceToken from "./AiGatewayServiceToken.js";
|
|
5
|
+
import { AI_GATEWAY_API_URL } from "./constants.js";
|
|
6
6
|
|
|
7
7
|
export const make = Effect.gen(function* () {
|
|
8
8
|
const serviceToken = yield* AiGatewayServiceToken.AiGatewayServiceToken;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as OpenAiClient from "@effect/ai-openai-compat/OpenAiClient";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
3
|
import * as Layer from "effect/Layer";
|
|
4
|
-
import * as AiGatewayServiceToken from "./AiGatewayServiceToken";
|
|
5
|
-
import { AI_GATEWAY_API_URL } from "./constants";
|
|
4
|
+
import * as AiGatewayServiceToken from "./AiGatewayServiceToken.js";
|
|
5
|
+
import { AI_GATEWAY_API_URL } from "./constants.js";
|
|
6
6
|
|
|
7
7
|
export const make = Effect.gen(function* () {
|
|
8
8
|
const serviceToken = yield* AiGatewayServiceToken.AiGatewayServiceToken;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ReadonlyValue } from "@confect/core/SchemaToValidator";
|
|
2
|
+
import { pipe } from "effect/Function";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Record from "effect/Record";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
7
|
+
import type * as Table from "../Table.js";
|
|
8
|
+
|
|
9
|
+
export type EncodedPatch = Record.ReadonlyRecord<
|
|
10
|
+
string,
|
|
11
|
+
ReadonlyValue | undefined
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
export type PatchEncoder = (
|
|
15
|
+
patch: Record.ReadonlyRecord<string, unknown>,
|
|
16
|
+
) => Effect.Effect<EncodedPatch, Schema.SchemaError>;
|
|
17
|
+
|
|
18
|
+
const patchEncoders = new WeakMap<Table.AnyWithProps, PatchEncoder | null>();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Returns the encoder for patches to the table's documents, or `undefined` when
|
|
22
|
+
* the table's codec does not encode each field independently. The encoder maps
|
|
23
|
+
* every patched field of the table to its encoded value, or to `undefined` when
|
|
24
|
+
* the patch unsets the field or the field's codec encodes the value as an
|
|
25
|
+
* absent key. Keys outside the table's fields are left out.
|
|
26
|
+
*/
|
|
27
|
+
export const encoder = (
|
|
28
|
+
table: Table.AnyWithProps,
|
|
29
|
+
): PatchEncoder | undefined => {
|
|
30
|
+
let cached = patchEncoders.get(table);
|
|
31
|
+
if (cached === undefined) {
|
|
32
|
+
cached = makePatchEncoder(table);
|
|
33
|
+
patchEncoders.set(table, cached);
|
|
34
|
+
}
|
|
35
|
+
return cached ?? undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// A struct with no encoding of its own encodes each field through that field's
|
|
39
|
+
// codec alone, so a patch encodes field by field. A union or a transformation
|
|
40
|
+
// over the whole struct can make one field's encoding depend on another field.
|
|
41
|
+
// A struct-level check must see the decoded fields before they are encoded,
|
|
42
|
+
// and keys under an index signature have no field codec of their own.
|
|
43
|
+
const makePatchEncoder = (table: Table.AnyWithProps): PatchEncoder | null => {
|
|
44
|
+
const ast = table.Fields.ast;
|
|
45
|
+
if (
|
|
46
|
+
!SchemaAST.isObjects(ast) ||
|
|
47
|
+
ast.encoding !== undefined ||
|
|
48
|
+
ast.checks !== undefined ||
|
|
49
|
+
ast.indexSignatures.length > 0
|
|
50
|
+
) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
// A field's codec runs only when the patch gives the field a value, since a
|
|
54
|
+
// codec can handle a missing key. Each comes from the table, whose codecs
|
|
55
|
+
// need no services.
|
|
56
|
+
const fieldEncoders: Record.ReadonlyRecord<
|
|
57
|
+
string,
|
|
58
|
+
(
|
|
59
|
+
value: unknown,
|
|
60
|
+
) => Effect.Effect<ReadonlyValue | undefined, Schema.SchemaError>
|
|
61
|
+
> = Object.fromEntries(
|
|
62
|
+
ast.propertySignatures.map(({ name, type }) => {
|
|
63
|
+
const key = String(name);
|
|
64
|
+
const encode = Schema.encodeUnknownEffect(
|
|
65
|
+
Schema.Struct({
|
|
66
|
+
[key]: Schema.optionalKey(
|
|
67
|
+
Schema.make<Schema.Codec<unknown, ReadonlyValue>>(type),
|
|
68
|
+
),
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
return [
|
|
72
|
+
key,
|
|
73
|
+
(value: unknown) =>
|
|
74
|
+
Effect.map(encode({ [key]: value }), (encoded) => encoded[key]),
|
|
75
|
+
];
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
78
|
+
return (patch) =>
|
|
79
|
+
pipe(
|
|
80
|
+
fieldEncoders,
|
|
81
|
+
Record.filter((_, name) => Object.hasOwn(patch, name)),
|
|
82
|
+
Record.map((encode, name) =>
|
|
83
|
+
patch[name] === undefined ? Effect.undefined : encode(patch[name]),
|
|
84
|
+
),
|
|
85
|
+
Effect.all,
|
|
86
|
+
);
|
|
87
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as Duration from "effect/Duration";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Exit from "effect/Exit";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as Scope from "effect/Scope";
|
|
6
|
+
import * as ConvexConfigProvider from "../ConvexConfigProvider.js";
|
|
7
|
+
|
|
8
|
+
const memoMap = Layer.makeMemoMapUnsafe();
|
|
9
|
+
export const scope = Scope.makeUnsafe();
|
|
10
|
+
const layers = new WeakMap<Layer.Layer<never>, Layer.Layer<never>>();
|
|
11
|
+
|
|
12
|
+
export const memoized = (layer: Layer.Layer<never>): Layer.Layer<never> => {
|
|
13
|
+
const cached = layers.get(layer);
|
|
14
|
+
if (cached !== undefined) return cached;
|
|
15
|
+
const built = Layer.buildWithMemoMap(layer, memoMap, scope).pipe(
|
|
16
|
+
Effect.provide(ConvexConfigProvider.layer),
|
|
17
|
+
// A failed first build is retried on the next invocation instead of failing every later one.
|
|
18
|
+
Effect.cachedWithTTL((exit) =>
|
|
19
|
+
Exit.isSuccess(exit) ? Duration.infinity : Duration.zero,
|
|
20
|
+
),
|
|
21
|
+
Effect.runSync,
|
|
22
|
+
Effect.uninterruptible,
|
|
23
|
+
Layer.effectContext,
|
|
24
|
+
);
|
|
25
|
+
layers.set(layer, built);
|
|
26
|
+
return built;
|
|
27
|
+
};
|
package/src/node.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as RegisteredNodeFunction from "./RegisteredNodeFunction";
|
|
1
|
+
export * as RegisteredNodeFunction from "./RegisteredNodeFunction.js";
|