@gaganref/confect-server 10.3.1-fork.3 → 10.3.1-fork.30
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 +1 -1
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +1 -1
- 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 +2 -2
- 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 +2 -2
- package/dist/GroupRegistry.d.ts.map +1 -1
- package/dist/GroupRegistry.js.map +1 -1
- package/dist/Handler.d.ts +30 -26
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js.map +1 -1
- package/dist/HttpRouter.d.ts +13 -13
- package/dist/HttpRouter.d.ts.map +1 -1
- package/dist/HttpRouter.js +2 -2
- 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 +86 -13
- package/dist/QueryStream.d.ts.map +1 -1
- package/dist/QueryStream.js +81 -8
- 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 +6 -3
- package/dist/QueryStreamReadBudget.js.map +1 -1
- package/dist/QueryTransactionContext.js +2 -2
- package/dist/RegisteredConvexFunction.d.ts +20 -20
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +19 -19
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +26 -26
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +55 -13
- 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 +6 -6
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +1 -1
- 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 +11 -9
- 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/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/package.json +2 -2
- 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 +1 -1
- package/src/ComponentCtx.ts +1 -1
- package/src/ConvexFunctionDefinitions.ts +8 -8
- 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 +4 -4
- package/src/Handler.ts +43 -28
- package/src/HttpRouter.ts +17 -17
- 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 +212 -20
- 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 +21 -21
- package/src/RegisteredFunction.ts +72 -19
- package/src/RegisteredFunctions.ts +4 -4
- package/src/RegisteredNodeFunction.ts +8 -8
- 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/node.ts +1 -1
package/src/DatabaseWriter.ts
CHANGED
|
@@ -10,13 +10,16 @@ import { pipe } from "effect/Function";
|
|
|
10
10
|
import * as Context from "effect/Context";
|
|
11
11
|
import * as Effect from "effect/Effect";
|
|
12
12
|
import * as Layer from "effect/Layer";
|
|
13
|
+
import * as Predicate from "effect/Predicate";
|
|
13
14
|
import * as Record from "effect/Record";
|
|
14
|
-
import * as
|
|
15
|
-
import
|
|
16
|
-
import type
|
|
17
|
-
import
|
|
18
|
-
import * as
|
|
19
|
-
import
|
|
15
|
+
import * as Result from "effect/Result";
|
|
16
|
+
import * as DatabaseSchema from "./DatabaseSchema.js";
|
|
17
|
+
import type * as DataModel from "./DataModel.js";
|
|
18
|
+
import type { DocumentByName as DocumentByName_ } from "./DataModel.js";
|
|
19
|
+
import * as Document from "./Document.js";
|
|
20
|
+
import * as DocumentPatch from "./internal/DocumentPatch.js";
|
|
21
|
+
import * as QueryInitializer from "./QueryInitializer.js";
|
|
22
|
+
import type * as Table from "./Table.js";
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* The argument accepted by `patch`: like `Partial<Doc>` without system fields,
|
|
@@ -97,11 +100,54 @@ export type DatabaseWriterTag<
|
|
|
97
100
|
DatabaseWriterService<DatabaseSchema_, Docs>
|
|
98
101
|
>;
|
|
99
102
|
|
|
103
|
+
/**
|
|
104
|
+
* Decoded documents surrounding one successful write.
|
|
105
|
+
*/
|
|
106
|
+
export type Change<S extends DatabaseSchema.AnyWithProps> = {
|
|
107
|
+
[Name in DataModel.TableNames<DataModel.FromSchema<S>>]: {
|
|
108
|
+
readonly tableName: Name;
|
|
109
|
+
} & (
|
|
110
|
+
| {
|
|
111
|
+
readonly operation: "insert";
|
|
112
|
+
readonly oldDoc: null;
|
|
113
|
+
readonly newDoc: DocumentByName_<DataModel.FromSchema<S>, Name>;
|
|
114
|
+
}
|
|
115
|
+
| {
|
|
116
|
+
readonly operation: "update";
|
|
117
|
+
readonly oldDoc: DocumentByName_<DataModel.FromSchema<S>, Name>;
|
|
118
|
+
readonly newDoc: DocumentByName_<DataModel.FromSchema<S>, Name>;
|
|
119
|
+
}
|
|
120
|
+
| {
|
|
121
|
+
readonly operation: "delete";
|
|
122
|
+
readonly oldDoc: DocumentByName_<DataModel.FromSchema<S>, Name>;
|
|
123
|
+
readonly newDoc: null;
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}[DataModel.TableNames<DataModel.FromSchema<S>>];
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Runs after the write, in its transaction. A defect aborts the mutation.
|
|
130
|
+
*
|
|
131
|
+
* Only writes through this writer are observed. Raw `ctx.db`, `MutationCtx`
|
|
132
|
+
* writes and a second `DatabaseWriter.make` bypass the hook, so a host that
|
|
133
|
+
* relies on it keeps raw writers out of its functions. Component writers and
|
|
134
|
+
* nested `runMutation` calls each need their own hook installation.
|
|
135
|
+
*
|
|
136
|
+
* Concurrent writes to one document (for example under `Effect.all`) can
|
|
137
|
+
* interleave the read-write-read steps. Await them sequentially when the hook
|
|
138
|
+
* needs exact per-write snapshots. The writer takes no lock, because a hook
|
|
139
|
+
* that writes through the same writer would deadlock under one.
|
|
140
|
+
*/
|
|
141
|
+
export type Hook<S extends DatabaseSchema.AnyWithProps> = (
|
|
142
|
+
change: Change<S>,
|
|
143
|
+
) => Effect.Effect<void>;
|
|
144
|
+
|
|
100
145
|
export const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
|
|
101
146
|
databaseSchema: DatabaseSchema_,
|
|
102
147
|
convexDatabaseWriter: GenericDatabaseWriter<
|
|
103
148
|
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>
|
|
104
149
|
>,
|
|
150
|
+
hook?: Hook<DatabaseSchema_>,
|
|
105
151
|
): DatabaseWriterService<DatabaseSchema_> => {
|
|
106
152
|
type DataModel_ = DataModel.FromSchema<DatabaseSchema_>;
|
|
107
153
|
|
|
@@ -131,38 +177,108 @@ export const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
|
|
|
131
177
|
return id as unknown as DataModel.Id<DataModel_, TableName>;
|
|
132
178
|
});
|
|
133
179
|
|
|
180
|
+
// A codec whose encoding spans fields cannot encode a patch on its own, so
|
|
181
|
+
// the patch is merged into the decoded document and the result replaces it.
|
|
182
|
+
const replacePatched = (
|
|
183
|
+
id: DataModel.Id<DataModel_, TableName>,
|
|
184
|
+
patchedValues: PatchValue<
|
|
185
|
+
Document.WithoutSystemFields<DocumentByName_<DataModel_, TableName>>
|
|
186
|
+
>,
|
|
187
|
+
) =>
|
|
188
|
+
Effect.gen(function* () {
|
|
189
|
+
const originalDecodedDoc = yield* QueryInitializer.getById<
|
|
190
|
+
Table.AnyWithProps,
|
|
191
|
+
TableName
|
|
192
|
+
>(
|
|
193
|
+
convexDatabaseWriter as any,
|
|
194
|
+
tableDef,
|
|
195
|
+
)(id as unknown as GenericId<TableName>);
|
|
196
|
+
|
|
197
|
+
const updatedEncodedDoc = yield* pipe(
|
|
198
|
+
patchedValues,
|
|
199
|
+
Record.reduce(originalDecodedDoc, (acc, value, key) =>
|
|
200
|
+
value === undefined
|
|
201
|
+
? Record.remove(acc, key)
|
|
202
|
+
: Record.set(acc, key, value),
|
|
203
|
+
),
|
|
204
|
+
Document.encode(tableDef),
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
yield* Effect.promise(() =>
|
|
208
|
+
convexDatabaseWriter.replace(
|
|
209
|
+
id as unknown as GenericId<TableName>,
|
|
210
|
+
updatedEncodedDoc as Expand<
|
|
211
|
+
BetterOmit<
|
|
212
|
+
DocumentByName<DataModel.ToConvex<DataModel_>, TableName>,
|
|
213
|
+
"_creationTime" | "_id"
|
|
214
|
+
>
|
|
215
|
+
>,
|
|
216
|
+
),
|
|
217
|
+
);
|
|
218
|
+
});
|
|
219
|
+
|
|
134
220
|
const patch = Effect.fn("DatabaseWriter.patch")(function* (
|
|
135
221
|
id: DataModel.Id<DataModel_, TableName>,
|
|
136
222
|
patchedValues: PatchValue<
|
|
137
223
|
Document.WithoutSystemFields<DocumentByName_<DataModel_, TableName>>
|
|
138
224
|
>,
|
|
139
225
|
) {
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
convexDatabaseWriter as any,
|
|
145
|
-
tableDef,
|
|
146
|
-
)(id as unknown as GenericId<TableName>);
|
|
226
|
+
const encodePatch = DocumentPatch.encoder(tableDef);
|
|
227
|
+
if (encodePatch === undefined) {
|
|
228
|
+
return yield* replacePatched(id, patchedValues);
|
|
229
|
+
}
|
|
147
230
|
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
231
|
+
const storedDoc = yield* pipe(
|
|
232
|
+
Effect.promise(() =>
|
|
233
|
+
convexDatabaseWriter.get(id as unknown as GenericId<TableName>),
|
|
234
|
+
),
|
|
235
|
+
Effect.andThen((value) =>
|
|
236
|
+
Effect.fromResult(
|
|
237
|
+
Result.fromNullishOr(
|
|
238
|
+
value,
|
|
239
|
+
() =>
|
|
240
|
+
new QueryInitializer.GetByIdFailure({
|
|
241
|
+
tableName,
|
|
242
|
+
id,
|
|
243
|
+
}),
|
|
244
|
+
),
|
|
245
|
+
),
|
|
246
|
+
),
|
|
247
|
+
);
|
|
248
|
+
// The patch must encode and the patched document must decode. When
|
|
249
|
+
// either fails, the stored document decides whose fault that is.
|
|
250
|
+
const encodedPatch = yield* pipe(
|
|
251
|
+
encodePatch(patchedValues),
|
|
252
|
+
Effect.mapError(({ message }) => message),
|
|
253
|
+
Effect.tap((delta) =>
|
|
254
|
+
pipe(
|
|
255
|
+
{ ...storedDoc, ...delta },
|
|
256
|
+
Record.filter(Predicate.isNotUndefined),
|
|
257
|
+
Document.decode(tableDef),
|
|
258
|
+
Effect.mapError(({ parseError }) => parseError),
|
|
259
|
+
),
|
|
260
|
+
),
|
|
261
|
+
Effect.catch((parseError) =>
|
|
262
|
+
pipe(
|
|
263
|
+
Document.decode(storedDoc, tableDef),
|
|
264
|
+
Effect.andThen(
|
|
265
|
+
Effect.fail(
|
|
266
|
+
new Document.DocumentEncodeError({
|
|
267
|
+
tableName,
|
|
268
|
+
id,
|
|
269
|
+
parseError,
|
|
270
|
+
}),
|
|
271
|
+
),
|
|
272
|
+
),
|
|
273
|
+
),
|
|
154
274
|
),
|
|
155
|
-
Document.encode(tableDef),
|
|
156
275
|
);
|
|
157
276
|
|
|
158
277
|
yield* Effect.promise(() =>
|
|
159
|
-
convexDatabaseWriter.
|
|
278
|
+
convexDatabaseWriter.patch(
|
|
160
279
|
id as unknown as GenericId<TableName>,
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
DocumentByName<DataModel.ToConvex<DataModel_>, TableName>,
|
|
164
|
-
"_creationTime" | "_id"
|
|
165
|
-
>
|
|
280
|
+
encodedPatch as Partial<
|
|
281
|
+
DocumentByName<DataModel.ToConvex<DataModel_>, TableName>
|
|
166
282
|
>,
|
|
167
283
|
),
|
|
168
284
|
);
|
|
@@ -194,11 +310,52 @@ export const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
|
|
|
194
310
|
convexDatabaseWriter.delete(id as unknown as GenericId<TableName>),
|
|
195
311
|
);
|
|
196
312
|
|
|
313
|
+
const accessor = { insert, patch, replace, delete: delete_ };
|
|
314
|
+
if (hook === undefined) return accessor;
|
|
315
|
+
|
|
316
|
+
const read = (id: DataModel.Id<DataModel_, TableName>) =>
|
|
317
|
+
QueryInitializer.getById<Table.AnyWithProps, TableName>(
|
|
318
|
+
convexDatabaseWriter as any,
|
|
319
|
+
tableDef,
|
|
320
|
+
)(id as unknown as GenericId<TableName>);
|
|
321
|
+
const notify = (
|
|
322
|
+
operation: "insert" | "update" | "delete",
|
|
323
|
+
oldDoc: unknown,
|
|
324
|
+
newDoc: unknown,
|
|
325
|
+
) =>
|
|
326
|
+
hook({ tableName, operation, oldDoc, newDoc } as Change<DatabaseSchema_>);
|
|
327
|
+
const update =
|
|
328
|
+
<A extends ReadonlyArray<unknown>, E, BeforeError>(
|
|
329
|
+
before: (
|
|
330
|
+
id: DataModel.Id<DataModel_, TableName>,
|
|
331
|
+
) => Effect.Effect<unknown, BeforeError>,
|
|
332
|
+
write: (
|
|
333
|
+
id: DataModel.Id<DataModel_, TableName>,
|
|
334
|
+
...args: A
|
|
335
|
+
) => Effect.Effect<void, E>,
|
|
336
|
+
) =>
|
|
337
|
+
(id: DataModel.Id<DataModel_, TableName>, ...args: A) =>
|
|
338
|
+
Effect.gen(function* () {
|
|
339
|
+
const oldDoc = yield* before(id);
|
|
340
|
+
yield* write(id, ...args);
|
|
341
|
+
yield* notify("update", oldDoc, yield* read(id).pipe(Effect.orDie));
|
|
342
|
+
});
|
|
343
|
+
|
|
197
344
|
return {
|
|
198
|
-
insert
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
345
|
+
insert: (document: Parameters<typeof insert>[0]) =>
|
|
346
|
+
Effect.gen(function* () {
|
|
347
|
+
const id = yield* insert(document);
|
|
348
|
+
yield* notify("insert", null, yield* read(id).pipe(Effect.orDie));
|
|
349
|
+
return id;
|
|
350
|
+
}),
|
|
351
|
+
patch: update(read, patch),
|
|
352
|
+
replace: update((id) => read(id).pipe(Effect.orDie), replace),
|
|
353
|
+
delete: (id: DataModel.Id<DataModel_, TableName>) =>
|
|
354
|
+
Effect.gen(function* () {
|
|
355
|
+
const oldDoc = yield* read(id).pipe(Effect.orDie);
|
|
356
|
+
yield* delete_(id);
|
|
357
|
+
yield* notify("delete", oldDoc, null);
|
|
358
|
+
}),
|
|
202
359
|
};
|
|
203
360
|
};
|
|
204
361
|
|
|
@@ -225,8 +382,9 @@ export const layer = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(
|
|
|
225
382
|
convexDatabaseWriter: GenericDatabaseWriter<
|
|
226
383
|
DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>
|
|
227
384
|
>,
|
|
385
|
+
hook?: Hook<DatabaseSchema_>,
|
|
228
386
|
) =>
|
|
229
387
|
Layer.succeed(
|
|
230
388
|
DatabaseWriter<DatabaseSchema_>(),
|
|
231
|
-
make(databaseSchema, convexDatabaseWriter),
|
|
389
|
+
make(databaseSchema, convexDatabaseWriter, hook),
|
|
232
390
|
);
|
package/src/Document.ts
CHANGED
|
@@ -4,10 +4,10 @@ import * as Effect from "effect/Effect";
|
|
|
4
4
|
import * as Function from "effect/Function";
|
|
5
5
|
import * as Schema from "effect/Schema";
|
|
6
6
|
import type { ReadonlyRecord } from "effect/Record";
|
|
7
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
8
|
-
import type * as DataModel from "./DataModel";
|
|
9
|
-
import type * as TableInfo from "./TableInfo";
|
|
10
|
-
import type * as Table from "./Table";
|
|
7
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
8
|
+
import type * as DataModel from "./DataModel.js";
|
|
9
|
+
import type * as TableInfo from "./TableInfo.js";
|
|
10
|
+
import type * as Table from "./Table.js";
|
|
11
11
|
|
|
12
12
|
export type Document<
|
|
13
13
|
Schema_ extends DatabaseSchema.AnyWithProps,
|
package/src/FunctionImpl.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
2
2
|
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
3
3
|
import type * as MiddlewareSpec from "@confect/core/MiddlewareSpec";
|
|
4
|
-
import * as Registry from "./Registry";
|
|
4
|
+
import * as Registry from "./Registry.js";
|
|
5
5
|
import * as Context from "effect/Context";
|
|
6
6
|
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
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";
|
|
9
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
10
|
+
import type * as Handler from "./Handler.js";
|
|
11
|
+
import { setNestedProperty } from "./internal/utils.js";
|
|
12
|
+
import * as FunctionRegistryItem from "./FunctionRegistryItem.js";
|
|
13
13
|
|
|
14
14
|
export interface FunctionImpl<Name_ extends string> {
|
|
15
15
|
readonly name: Name_;
|
|
@@ -5,7 +5,7 @@ import type { FunctionType, FunctionVisibility } from "convex/server";
|
|
|
5
5
|
import * as Match from "effect/Match";
|
|
6
6
|
import * as Predicate from "effect/Predicate";
|
|
7
7
|
import type * as Schema from "effect/Schema";
|
|
8
|
-
import type * as Handler from "./Handler";
|
|
8
|
+
import type * as Handler from "./Handler.js";
|
|
9
9
|
|
|
10
10
|
export const TypeId = "~@confect/server/FunctionRegistryItem";
|
|
11
11
|
export type TypeId = typeof TypeId;
|
package/src/GroupImpl.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
2
2
|
import type * as MiddlewareSpec from "@confect/core/MiddlewareSpec";
|
|
3
|
-
import * as Registry from "./Registry";
|
|
4
|
-
import * as RegistryItems from "./RegistryItems";
|
|
3
|
+
import * as Registry from "./Registry.js";
|
|
4
|
+
import * as RegistryItems from "./RegistryItems.js";
|
|
5
5
|
import * as Array from "effect/Array";
|
|
6
6
|
import * as Context from "effect/Context";
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Data from "effect/Data";
|
|
8
9
|
import * as Layer from "effect/Layer";
|
|
9
10
|
import * as Option from "effect/Option";
|
|
10
11
|
import * as Predicate from "effect/Predicate";
|
|
11
12
|
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";
|
|
13
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
14
|
+
import type * as FunctionImpl from "./FunctionImpl.js";
|
|
15
|
+
import type * as MiddlewareImpl from "./MiddlewareImpl.js";
|
|
15
16
|
|
|
16
17
|
export const TypeId = "~@confect/server/GroupImpl";
|
|
17
18
|
export type TypeId = typeof TypeId;
|
|
@@ -111,10 +112,20 @@ export const make = <
|
|
|
111
112
|
FunctionImpl.FromGroupSpec<Group> | MiddlewareImpl.FromGroupSpec<Group>
|
|
112
113
|
>;
|
|
113
114
|
|
|
114
|
-
const
|
|
115
|
-
context
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
const findGroupImpl = <S>(context: Context.Context<S>): Option.Option<Any> =>
|
|
116
|
+
Array.findFirst(context.mapUnsafe.values(), isGroupImpl);
|
|
117
|
+
|
|
118
|
+
export class MissingRequiredMiddlewareError extends Data.TaggedError(
|
|
119
|
+
"MissingRequiredMiddlewareError",
|
|
120
|
+
)<{
|
|
121
|
+
readonly missing: ReadonlyArray<RegistryItems.MissingMiddleware>;
|
|
122
|
+
}> {
|
|
123
|
+
override get message(): string {
|
|
124
|
+
return `GroupImpl.finalize: ${this.missing.map(({ functionName, middlewareKey }) => `${functionName} requires middleware "${middlewareKey}"`).join("\n")}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
type Finalizable = Layer.Layer<AnyUnfinalized> | Layer.Layer<AnyFinalized>;
|
|
118
129
|
|
|
119
130
|
/**
|
|
120
131
|
* Mark a `GroupImpl` layer as fully implemented. The parameter type defaults
|
|
@@ -127,20 +138,52 @@ const findUnfinalizedGroupImpl = <S>(
|
|
|
127
138
|
* registered into this group's scope are snapshotted onto the produced service
|
|
128
139
|
* value's `registeredFunctionNames` field, so consumers can verify impl
|
|
129
140
|
* completeness against a `GroupSpec`'s expected functions without having to
|
|
130
|
-
* inspect the `Registry` themselves.
|
|
141
|
+
* inspect the `Registry` themselves. Pass `{ required }` to check every
|
|
142
|
+
* registered function's middleware at layer build, including internal
|
|
143
|
+
* functions. This form also accepts a finalized layer so generated registration
|
|
144
|
+
* can enforce the backend declaration without changing authored impls. Pass
|
|
145
|
+
* `groupPath` to qualify uncovered function names in the diagnostic.
|
|
131
146
|
*/
|
|
132
|
-
export
|
|
147
|
+
export function finalize(options: {
|
|
148
|
+
readonly groupPath?: string;
|
|
149
|
+
readonly required: ReadonlyArray<
|
|
150
|
+
Pick<MiddlewareSpec.AnyMiddlewareSpec, "key">
|
|
151
|
+
>;
|
|
152
|
+
}): (group: Finalizable) => Layer.Layer<GroupImpl<"Finalized">>;
|
|
153
|
+
export function finalize(
|
|
133
154
|
group: Layer.Layer<GroupImpl<"Unfinalized">>,
|
|
155
|
+
): Layer.Layer<GroupImpl<"Finalized">>;
|
|
156
|
+
export function finalize(
|
|
157
|
+
input:
|
|
158
|
+
| Finalizable
|
|
159
|
+
| {
|
|
160
|
+
readonly groupPath?: string;
|
|
161
|
+
readonly required: ReadonlyArray<
|
|
162
|
+
Pick<MiddlewareSpec.AnyMiddlewareSpec, "key">
|
|
163
|
+
>;
|
|
164
|
+
},
|
|
165
|
+
):
|
|
166
|
+
| Layer.Layer<GroupImpl<"Finalized">>
|
|
167
|
+
| ((group: Finalizable) => Layer.Layer<GroupImpl<"Finalized">>) {
|
|
168
|
+
return "required" in input
|
|
169
|
+
? (group) => finalizeWith(group, input.required, input.groupPath)
|
|
170
|
+
: finalizeWith(input, []);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const finalizeWith = (
|
|
174
|
+
group: Layer.Layer<never>,
|
|
175
|
+
required: ReadonlyArray<Pick<MiddlewareSpec.AnyMiddlewareSpec, "key">>,
|
|
176
|
+
groupPath = "",
|
|
134
177
|
): Layer.Layer<GroupImpl<"Finalized">> =>
|
|
135
178
|
Layer.flatMap(group, (context): Layer.Layer<GroupImpl<"Finalized">> =>
|
|
136
|
-
|
|
179
|
+
findGroupImpl(context).pipe(
|
|
137
180
|
Option.match({
|
|
138
181
|
onNone: () =>
|
|
139
182
|
Layer.effect(
|
|
140
183
|
GroupImpl<"Finalized">({ finalizationStatus: "Finalized" }),
|
|
141
184
|
Effect.die(
|
|
142
185
|
new Error(
|
|
143
|
-
"GroupImpl.finalize: no
|
|
186
|
+
"GroupImpl.finalize: no GroupImpl service was found in the layer's context.",
|
|
144
187
|
),
|
|
145
188
|
),
|
|
146
189
|
),
|
|
@@ -150,6 +193,16 @@ export const finalize = (
|
|
|
150
193
|
Effect.gen(function* () {
|
|
151
194
|
const registry = yield* Registry.Registry;
|
|
152
195
|
const items = yield* Ref.get(registry);
|
|
196
|
+
const missing = RegistryItems.missingRequired(
|
|
197
|
+
items,
|
|
198
|
+
required,
|
|
199
|
+
groupPath,
|
|
200
|
+
);
|
|
201
|
+
if (missing.length > 0) {
|
|
202
|
+
return yield* Effect.die(
|
|
203
|
+
new MissingRequiredMiddlewareError({ missing }),
|
|
204
|
+
);
|
|
205
|
+
}
|
|
153
206
|
return {
|
|
154
207
|
[TypeId]: TypeId,
|
|
155
208
|
finalizationStatus: "Finalized" as const,
|
package/src/GroupRegistry.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import type * as Layer from "effect/Layer";
|
|
3
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";
|
|
4
|
+
import * as Registry from "./Registry.js";
|
|
5
|
+
import type * as RegistryItems from "./RegistryItems.js";
|
|
6
|
+
import type * as GroupImpl from "./GroupImpl.js";
|
|
7
|
+
import * as MiddlewareRegistryItem from "./MiddlewareRegistryItem.js";
|
|
8
8
|
|
|
9
9
|
export const make = (
|
|
10
10
|
groupLayer: Layer.Layer<GroupImpl.GroupImpl<"Finalized">>,
|
package/src/Handler.ts
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
+
import type { ActionCall } from "@confect/core/ActionCall";
|
|
1
2
|
import type { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
2
3
|
import type * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
3
4
|
import type * as NodeServices from "@effect/platform-node/NodeServices";
|
|
4
5
|
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";
|
|
6
|
+
import type * as ActionCtx from "./ActionCtx.js";
|
|
7
|
+
import type * as ActionRunner from "./ActionRunner.js";
|
|
8
|
+
import type * as Auth from "./Auth.js";
|
|
9
|
+
import type * as DatabaseReader from "./DatabaseReader.js";
|
|
10
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
11
|
+
import type * as DatabaseWriter from "./DatabaseWriter.js";
|
|
12
|
+
import type * as DataModel from "./DataModel.js";
|
|
13
|
+
import type { ExecutionMetadata } from "./ExecutionMetadata.js";
|
|
14
|
+
import type { RequestMetadata } from "./RequestMetadata.js";
|
|
15
|
+
import type { TransactionMetadata } from "./TransactionMetadata.js";
|
|
16
|
+
import type * as MutationCtx from "./MutationCtx.js";
|
|
17
|
+
import type * as MutationRunner from "./MutationRunner.js";
|
|
18
|
+
import type { MutationTransactionContext } from "./MutationTransactionContext.js";
|
|
19
|
+
import type * as QueryCtx from "./QueryCtx.js";
|
|
20
|
+
import type * as QueryRunner from "./QueryRunner.js";
|
|
21
|
+
import type { QueryTransactionContext } from "./QueryTransactionContext.js";
|
|
22
|
+
import type * as RegisteredFunction from "./RegisteredFunction.js";
|
|
23
|
+
import type * as Scheduler from "./Scheduler.js";
|
|
24
|
+
import type { Storage } from "./Storage.js";
|
|
25
|
+
import type * as StorageActionWriter from "./StorageActionWriter.js";
|
|
26
|
+
import type * as StorageReader from "./StorageReader.js";
|
|
27
|
+
import type * as StorageWriter from "./StorageWriter.js";
|
|
28
|
+
import type * as VectorSearch from "./VectorSearch.js";
|
|
28
29
|
|
|
29
30
|
export type Handler<
|
|
30
31
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
@@ -114,9 +115,7 @@ export type MutationServices<
|
|
|
114
115
|
/**
|
|
115
116
|
* Shared by both action runtimes.
|
|
116
117
|
*/
|
|
117
|
-
|
|
118
|
-
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
119
|
-
> =
|
|
118
|
+
type RawActionServices<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =
|
|
120
119
|
| Scheduler.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
121
120
|
| (DatabaseSchema_["target"]["kind"] extends "component" ? never : Auth.Auth)
|
|
122
121
|
| StorageReader.ForScope<DatabaseSchema.Scope<DatabaseSchema_>>
|
|
@@ -134,6 +133,22 @@ export type ActionServices<
|
|
|
134
133
|
DatabaseSchema.Scope<DatabaseSchema_>
|
|
135
134
|
>;
|
|
136
135
|
|
|
136
|
+
export type ActionServices<S extends DatabaseSchema.AnyWithProps, R = never> = [
|
|
137
|
+
Extract<R, ActionCall>,
|
|
138
|
+
] extends [never]
|
|
139
|
+
? RawActionServices<S>
|
|
140
|
+
: Exclude<
|
|
141
|
+
RawActionServices<S>,
|
|
142
|
+
| Scheduler.ForScope<DatabaseSchema.Scope<S>>
|
|
143
|
+
| QueryRunner.QueryRunner
|
|
144
|
+
| MutationRunner.MutationRunner
|
|
145
|
+
| ActionRunner.ActionRunner
|
|
146
|
+
| ActionCtx.ActionCtx<
|
|
147
|
+
DataModel.ToConvex<DataModel.FromSchema<S>>,
|
|
148
|
+
DatabaseSchema.Scope<S>
|
|
149
|
+
>
|
|
150
|
+
>;
|
|
151
|
+
|
|
137
152
|
export type ConfectProvenanceQuery<
|
|
138
153
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
139
154
|
FunctionSpec_ extends
|
|
@@ -153,7 +168,7 @@ export type ConvexRuntimeAction<
|
|
|
153
168
|
FunctionSpec_ extends
|
|
154
169
|
FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>,
|
|
155
170
|
R = never,
|
|
156
|
-
> = Base<FunctionSpec_, ActionServices<DatabaseSchema_> | R>;
|
|
171
|
+
> = Base<FunctionSpec_, ActionServices<DatabaseSchema_, R> | R>;
|
|
157
172
|
|
|
158
173
|
export type NodeRuntimeAction<
|
|
159
174
|
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
@@ -162,7 +177,7 @@ export type NodeRuntimeAction<
|
|
|
162
177
|
R = never,
|
|
163
178
|
> = Base<
|
|
164
179
|
FunctionSpec_,
|
|
165
|
-
ActionServices<DatabaseSchema_> | NodeServices.NodeServices | R
|
|
180
|
+
ActionServices<DatabaseSchema_, R> | NodeServices.NodeServices | R
|
|
166
181
|
>;
|
|
167
182
|
|
|
168
183
|
type Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (
|
package/src/HttpRouter.ts
CHANGED
|
@@ -25,23 +25,23 @@ import type * as Etag from "effect/http/Etag";
|
|
|
25
25
|
import type * as HttpPlatform from "effect/http/HttpPlatform";
|
|
26
26
|
import * as HttpRouter from "effect/http/HttpRouter";
|
|
27
27
|
import * as HttpServer from "effect/http/HttpServer";
|
|
28
|
-
import type * as ActionRunner from "./ActionRunner";
|
|
29
|
-
import type * as Auth from "./Auth";
|
|
30
|
-
import type { ExecutionMetadata } from "./ExecutionMetadata";
|
|
31
|
-
import type { RequestMetadata } from "./RequestMetadata";
|
|
32
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
33
|
-
import type * as DataModel from "./DataModel";
|
|
34
|
-
import type * as Handler from "./Handler";
|
|
35
|
-
import * as ConvexConfigProvider from "./ConvexConfigProvider";
|
|
36
|
-
import * as ConvexLogger from "./ConvexLogger";
|
|
37
|
-
import type * as MutationRunner from "./MutationRunner";
|
|
38
|
-
import type * as QueryRunner from "./QueryRunner";
|
|
39
|
-
import * as RegisteredFunction from "./RegisteredFunction";
|
|
40
|
-
import type * as Scheduler from "./Scheduler";
|
|
41
|
-
import type { Storage } from "./Storage";
|
|
42
|
-
import type { StorageActionWriter } from "./StorageActionWriter";
|
|
43
|
-
import type { StorageReader } from "./StorageReader";
|
|
44
|
-
import type { StorageWriter } from "./StorageWriter";
|
|
28
|
+
import type * as ActionRunner from "./ActionRunner.js";
|
|
29
|
+
import type * as Auth from "./Auth.js";
|
|
30
|
+
import type { ExecutionMetadata } from "./ExecutionMetadata.js";
|
|
31
|
+
import type { RequestMetadata } from "./RequestMetadata.js";
|
|
32
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
33
|
+
import type * as DataModel from "./DataModel.js";
|
|
34
|
+
import type * as Handler from "./Handler.js";
|
|
35
|
+
import * as ConvexConfigProvider from "./ConvexConfigProvider.js";
|
|
36
|
+
import * as ConvexLogger from "./ConvexLogger.js";
|
|
37
|
+
import type * as MutationRunner from "./MutationRunner.js";
|
|
38
|
+
import type * as QueryRunner from "./QueryRunner.js";
|
|
39
|
+
import * as RegisteredFunction from "./RegisteredFunction.js";
|
|
40
|
+
import type * as Scheduler from "./Scheduler.js";
|
|
41
|
+
import type { Storage } from "./Storage.js";
|
|
42
|
+
import type { StorageActionWriter } from "./StorageActionWriter.js";
|
|
43
|
+
import type { StorageReader } from "./StorageReader.js";
|
|
44
|
+
import type { StorageWriter } from "./StorageWriter.js";
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* The Confect services available to HTTP route handlers and middleware,
|
package/src/MiddlewareImpl.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
2
2
|
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
3
3
|
import * as MiddlewareSpec from "@confect/core/MiddlewareSpec";
|
|
4
|
-
import * as Registry from "./Registry";
|
|
4
|
+
import * as Registry from "./Registry.js";
|
|
5
5
|
import type { FunctionType } from "convex/server";
|
|
6
6
|
import * as Context from "effect/Context";
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
8
|
import * as Layer from "effect/Layer";
|
|
9
9
|
import * as Ref from "effect/Ref";
|
|
10
|
-
import type * as Auth from "./Auth";
|
|
11
|
-
import type * as DatabaseReader from "./DatabaseReader";
|
|
12
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
13
|
-
import type * as Handler from "./Handler";
|
|
14
|
-
import type { ExecutionMetadata } from "./ExecutionMetadata";
|
|
15
|
-
import type { RequestMetadata } from "./RequestMetadata";
|
|
16
|
-
import type { TransactionMetadata } from "./TransactionMetadata";
|
|
17
|
-
import type * as MutationRunner from "./MutationRunner";
|
|
18
|
-
import type * as QueryRunner from "./QueryRunner";
|
|
19
|
-
import type { QueryTransactionContext } from "./QueryTransactionContext";
|
|
20
|
-
import type * as Scheduler from "./Scheduler";
|
|
21
|
-
import type { Storage } from "./Storage";
|
|
22
|
-
import type * as StorageReader from "./StorageReader";
|
|
23
|
-
import type * as StorageWriter from "./StorageWriter";
|
|
24
|
-
import * as MiddlewareRegistryItem from "./MiddlewareRegistryItem";
|
|
25
|
-
import { setNestedProperty } from "./internal/utils";
|
|
10
|
+
import type * as Auth from "./Auth.js";
|
|
11
|
+
import type * as DatabaseReader from "./DatabaseReader.js";
|
|
12
|
+
import type * as DatabaseSchema from "./DatabaseSchema.js";
|
|
13
|
+
import type * as Handler from "./Handler.js";
|
|
14
|
+
import type { ExecutionMetadata } from "./ExecutionMetadata.js";
|
|
15
|
+
import type { RequestMetadata } from "./RequestMetadata.js";
|
|
16
|
+
import type { TransactionMetadata } from "./TransactionMetadata.js";
|
|
17
|
+
import type * as MutationRunner from "./MutationRunner.js";
|
|
18
|
+
import type * as QueryRunner from "./QueryRunner.js";
|
|
19
|
+
import type { QueryTransactionContext } from "./QueryTransactionContext.js";
|
|
20
|
+
import type * as Scheduler from "./Scheduler.js";
|
|
21
|
+
import type { Storage } from "./Storage.js";
|
|
22
|
+
import type * as StorageReader from "./StorageReader.js";
|
|
23
|
+
import type * as StorageWriter from "./StorageWriter.js";
|
|
24
|
+
import * as MiddlewareRegistryItem from "./MiddlewareRegistryItem.js";
|
|
25
|
+
import { setNestedProperty } from "./internal/utils.js";
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Marker service produced by providing a middleware's implementation to a
|