@gaganref/confect-server 10.3.1-fork.25 → 10.3.1-fork.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActionCall.d.ts +30 -0
- package/dist/ActionCall.d.ts.map +1 -0
- package/dist/ActionCall.js +41 -0
- package/dist/ActionCall.js.map +1 -0
- package/dist/ActionRunner.js +2 -2
- package/dist/AiGatewayDecisionClient.js +1 -1
- package/dist/AiGatewayLanguageClient.js +1 -1
- package/dist/Auth.js +1 -1
- package/dist/Callback.js +3 -3
- package/dist/ConvexConfigProvider.js +2 -2
- package/dist/ConvexFunctionDefinitions.js +2 -2
- package/dist/ConvexLogger.js +1 -1
- package/dist/CronJobs.js +6 -6
- package/dist/DatabaseSchema.js +2 -2
- package/dist/DatabaseWriter.d.ts +36 -2
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +33 -6
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/ExecutionMetadata.js +1 -1
- package/dist/FunctionImpl.js +2 -2
- package/dist/FunctionRegistryItem.js +1 -1
- package/dist/GroupImpl.js +5 -5
- package/dist/Handler.d.ts +7 -3
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js.map +1 -1
- package/dist/HttpRouter.js +2 -2
- package/dist/MiddlewareImpl.js +1 -1
- package/dist/MutationRunner.js +2 -2
- package/dist/MutationTransactionContext.js +2 -2
- package/dist/QueryInitializer.js +2 -2
- package/dist/QueryRunner.js +2 -2
- package/dist/QueryStream.js +3 -3
- package/dist/QueryStreamCursor.js +1 -1
- package/dist/QueryStreamIndexPrefix.js +1 -1
- package/dist/QueryStreamIndexRange.js +2 -2
- package/dist/QueryStreamKey.js +1 -1
- package/dist/QueryStreamKeyBounds.js +2 -2
- package/dist/QueryStreamKeyLayout.js +2 -2
- package/dist/QueryStreamKeyValues.js +1 -1
- package/dist/QueryStreamPagination.js +1 -1
- package/dist/QueryStreamReadBudget.js +2 -2
- package/dist/QueryTransactionContext.js +2 -2
- package/dist/RegisteredConvexFunction.js +19 -19
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +55 -13
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredNodeFunction.js +1 -1
- package/dist/RegistryItems.js +1 -1
- package/dist/RequestMetadata.js +1 -1
- package/dist/Scheduler.js +2 -2
- package/dist/Storage.js +1 -1
- package/dist/StorageActionWriter.js +1 -1
- package/dist/StorageReader.js +1 -1
- package/dist/StorageWriter.js +1 -1
- package/dist/TransactionMetadata.js +1 -1
- package/dist/VectorSearch.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/internal/AiGatewayDecisionClient.js +1 -1
- package/dist/internal/AiGatewayLanguageClient.js +1 -1
- package/dist/internal/AiGatewayServiceToken.js +1 -1
- package/dist/internal/DocumentPatch.js +1 -1
- package/package.json +2 -2
- package/src/ActionCall.ts +82 -0
- package/src/DatabaseWriter.ts +90 -5
- package/src/Handler.ts +20 -5
- package/src/RegisteredFunction.ts +54 -1
- package/src/index.ts +1 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as ActionCallSpec from "@confect/core/ActionCall";
|
|
2
|
+
import * as ActionCall from "./ActionCall.js";
|
|
1
3
|
import type { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
2
4
|
import * as IdScope from "@confect/core/IdScope";
|
|
3
5
|
import type * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
@@ -299,6 +301,12 @@ export const actionFunctionBase = <
|
|
|
299
301
|
Schema.decodeUnknownEffect(args),
|
|
300
302
|
Effect.catchTag("SchemaError", Effect.die),
|
|
301
303
|
);
|
|
304
|
+
const restricted = resolvedMiddlewares.some(
|
|
305
|
+
({ middlewareSpec }) =>
|
|
306
|
+
middlewareSpec.key === ActionCallSpec.Middleware.key,
|
|
307
|
+
)
|
|
308
|
+
? restrict(ctx)
|
|
309
|
+
: undefined;
|
|
302
310
|
// 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.
|
|
303
311
|
const decodedReturns = yield* applyMiddleware(
|
|
304
312
|
handler(decodedArgs),
|
|
@@ -309,7 +317,8 @@ export const actionFunctionBase = <
|
|
|
309
317
|
functionVisibility,
|
|
310
318
|
args: decodedArgs,
|
|
311
319
|
},
|
|
312
|
-
).pipe(Effect.provide(createLayer(ctx)));
|
|
320
|
+
).pipe(Effect.provide(createLayer(restricted?.ctx ?? ctx)));
|
|
321
|
+
if (restricted !== undefined) yield* restricted.check;
|
|
313
322
|
return yield* pipe(
|
|
314
323
|
decodedReturns,
|
|
315
324
|
Schema.encodeEffect(returns),
|
|
@@ -389,3 +398,47 @@ export const storageLayer = <Scope extends IdScope.IdScope>(
|
|
|
389
398
|
Storage.layer(reader) as Layer.Layer<
|
|
390
399
|
Storage.Storage | StorageReader.ForScope<Scope>
|
|
391
400
|
>;
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Shares one dispatch budget across the entire middleware chain.
|
|
404
|
+
*/
|
|
405
|
+
const restrict = <Model extends GenericDataModel>(
|
|
406
|
+
ctx: GenericActionCtx<Model>,
|
|
407
|
+
) => {
|
|
408
|
+
let dispatched = false;
|
|
409
|
+
const claim = () => {
|
|
410
|
+
if (dispatched) throw new ActionCall.ActionCallAlreadyUsed();
|
|
411
|
+
dispatched = true;
|
|
412
|
+
};
|
|
413
|
+
const restricted: GenericActionCtx<Model> = {
|
|
414
|
+
...ctx,
|
|
415
|
+
scheduler: {
|
|
416
|
+
runAfter: () => {
|
|
417
|
+
throw new ActionCall.SchedulingNotAllowed();
|
|
418
|
+
},
|
|
419
|
+
runAt: () => {
|
|
420
|
+
throw new ActionCall.SchedulingNotAllowed();
|
|
421
|
+
},
|
|
422
|
+
cancel: () => {
|
|
423
|
+
throw new ActionCall.SchedulingNotAllowed();
|
|
424
|
+
},
|
|
425
|
+
},
|
|
426
|
+
runQuery: (...args) => {
|
|
427
|
+
claim();
|
|
428
|
+
return ctx.runQuery(...args);
|
|
429
|
+
},
|
|
430
|
+
runMutation: (...args) => {
|
|
431
|
+
claim();
|
|
432
|
+
return ctx.runMutation(...args);
|
|
433
|
+
},
|
|
434
|
+
runAction: () => {
|
|
435
|
+
throw new ActionCall.NestedActionNotAllowed();
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
return {
|
|
439
|
+
ctx: restricted,
|
|
440
|
+
check: Effect.suspend(() =>
|
|
441
|
+
dispatched ? Effect.void : Effect.die(new ActionCall.ActionCallNotUsed()),
|
|
442
|
+
),
|
|
443
|
+
};
|
|
444
|
+
};
|
package/src/index.ts
CHANGED