@confect/server 2.0.0 → 4.0.0
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 +33 -0
- package/dist/ActionRunner.d.ts +2 -2
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/ActionRunner.js +9 -7
- package/dist/ActionRunner.js.map +1 -1
- package/dist/BlobNotFoundError.d.ts +17 -0
- package/dist/BlobNotFoundError.d.ts.map +1 -0
- package/dist/BlobNotFoundError.js +14 -0
- package/dist/BlobNotFoundError.js.map +1 -0
- package/dist/CronJob.d.ts +22 -0
- package/dist/CronJob.d.ts.map +1 -0
- package/dist/CronJob.js +23 -0
- package/dist/CronJob.js.map +1 -0
- package/dist/CronJobs.d.ts +28 -0
- package/dist/CronJobs.d.ts.map +1 -0
- package/dist/CronJobs.js +75 -0
- package/dist/CronJobs.js.map +1 -0
- package/dist/DatabaseWriter.d.ts +4 -4
- package/dist/FunctionImpl.js +2 -2
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/Handler.d.ts +22 -14
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js.map +1 -1
- package/dist/HttpApi.d.ts +3 -1
- package/dist/HttpApi.d.ts.map +1 -1
- package/dist/HttpApi.js +3 -1
- package/dist/HttpApi.js.map +1 -1
- package/dist/MutationRunner.d.ts +2 -2
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +9 -7
- package/dist/MutationRunner.js.map +1 -1
- package/dist/OrderedQuery.d.ts +2 -2
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/OrderedQuery.js +3 -2
- package/dist/OrderedQuery.js.map +1 -1
- package/dist/QueryInitializer.d.ts +1 -1
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryRunner.d.ts +2 -2
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +7 -5
- package/dist/QueryRunner.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +11 -10
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +23 -19
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +20 -7
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +3 -1
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +4 -4
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +3 -3
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +6 -5
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/RegistryItem.d.ts +9 -9
- package/dist/RegistryItem.d.ts.map +1 -1
- package/dist/RegistryItem.js +2 -2
- package/dist/RegistryItem.js.map +1 -1
- package/dist/StorageActionWriter.d.ts +35 -0
- package/dist/StorageActionWriter.d.ts.map +1 -0
- package/dist/StorageActionWriter.js +20 -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 +17 -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 +20 -0
- package/dist/StorageWriter.js.map +1 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.js +7 -2
- package/package.json +4 -4
- package/src/ActionRunner.ts +27 -13
- package/src/BlobNotFoundError.ts +12 -0
- package/src/CronJob.ts +45 -0
- package/src/CronJobs.ts +161 -0
- package/src/FunctionImpl.ts +3 -3
- package/src/Handler.ts +42 -19
- package/src/HttpApi.ts +3 -1
- package/src/MutationRunner.ts +27 -13
- package/src/OrderedQuery.ts +15 -6
- package/src/QueryRunner.ts +22 -8
- package/src/RegisteredConvexFunction.ts +54 -42
- package/src/RegisteredFunction.ts +89 -2
- package/src/RegisteredFunctions.ts +10 -11
- package/src/RegisteredNodeFunction.ts +23 -13
- package/src/RegistryItem.ts +9 -12
- package/src/StorageActionWriter.ts +28 -0
- package/src/StorageReader.ts +27 -0
- package/src/StorageWriter.ts +26 -0
- package/src/index.ts +7 -2
- package/dist/Storage.d.ts +0 -69
- package/dist/Storage.d.ts.map +0 -1
- package/dist/Storage.js +0 -46
- package/dist/Storage.js.map +0 -1
- package/src/Storage.ts +0 -87
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @confect/server
|
|
2
2
|
|
|
3
|
+
## 4.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 60be7e6: Add Effect-native cron job support via new `CronJob` and `CronJobs` modules.
|
|
8
|
+
|
|
9
|
+
Cron jobs are now defined using Effect's `Cron` (cron expressions) or `Duration` (fixed intervals) types instead of the vanilla Convex `cronJobs()` API. `CronJob.make` creates individual jobs with a unique identifier, schedule, and ref to an internal mutation or action. `CronJobs.make()` creates an empty collection with a chainable `.add()` method.
|
|
10
|
+
|
|
11
|
+
Interval schedules are represented in the largest whole unit possible (hours > minutes > seconds) to avoid floating-point precision issues with large durations.
|
|
12
|
+
|
|
13
|
+
- 8ae4d51: Standardize all Effect service tags to a consistent `@confect/{package}/{ServiceName}` format.
|
|
14
|
+
|
|
15
|
+
The `Storage` namespace export has been removed from `@confect/server`. `StorageReader`, `StorageWriter`, `StorageActionWriter`, and `BlobNotFoundError` are now exported as individual top-level namespaces. Replace `Storage.StorageReader` with `StorageReader.StorageReader`, etc. After upgrading, rerun `confect codegen` to regenerate the `services.ts` file.
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 641fd99: Add optional `filter` parameter to `OrderedQuery.paginate`. This allows applying a Convex filter directly at the pagination level — the one scenario where `.filter()` is recommended over index-based filtering. The filter callback receives a `FilterBuilder` and is applied to the underlying query before paginating.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- @confect/core@4.0.0
|
|
24
|
+
|
|
25
|
+
## 3.0.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- 5fb6a61: Add support for plain Convex functions. Plain Convex queries, mutations, and actions can now be included in your Confect spec and impl tree using new `FunctionSpec.convexPublic*` and `FunctionSpec.convexInternal*` constructors. This enables interop with Convex components and libraries (such as Workpool, Workflow, Migrations, and Better Auth) that require user-defined or -provided Convex functions.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [5fb6a61]
|
|
34
|
+
- @confect/core@3.0.0
|
|
35
|
+
|
|
3
36
|
## 2.0.0
|
|
4
37
|
|
|
5
38
|
### Minor Changes
|
package/dist/ActionRunner.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ import { GenericActionCtx } from "convex/server";
|
|
|
6
6
|
declare namespace ActionRunner_d_exports {
|
|
7
7
|
export { ActionRunner, layer };
|
|
8
8
|
}
|
|
9
|
-
declare const ActionRunner: Context.Tag<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>
|
|
9
|
+
declare const ActionRunner: Context.Tag<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) => Effect.Effect<Ref$1.Returns<Action>, ParseResult.ParseError>), <Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) => Effect.Effect<Ref$1.Returns<Action>, ParseResult.ParseError>>;
|
|
10
10
|
type ActionRunner = typeof ActionRunner.Identifier;
|
|
11
|
-
declare const layer: (runAction: GenericActionCtx<any>["runAction"]) => Layer.Layer<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>
|
|
11
|
+
declare const layer: (runAction: GenericActionCtx<any>["runAction"]) => Layer.Layer<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) => Effect.Effect<Ref$1.Returns<Action>, ParseResult.ParseError>), never, never>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { ActionRunner, ActionRunner_d_exports, layer };
|
|
14
14
|
//# sourceMappingURL=ActionRunner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionRunner.d.ts","names":[],"sources":["../src/ActionRunner.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"ActionRunner.d.ts","names":[],"sources":["../src/ActionRunner.ts"],"mappings":";;;;;;;;cAoCa,YAAA,EAAY,OAAA,CAAA,GAAA,kBA7BP,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,EAAM,IAAA,EACR,KAAA,CAAI,IAAA,CAAK,MAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,MAAA,GAAS,WAAA,CAAY,UAAA,oBAHlC,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,EAAM,IAAA,EACR,KAAA,CAAI,IAAA,CAAK,MAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,MAAA,GAAS,WAAA,CAAY,UAAA;AAAA,KA6BxC,YAAA,UAAsB,YAAA,CAAa,UAAA;AAAA,cAElC,KAAA,GAAS,SAAA,EAAW,gBAAA,uBAAkC,KAAA,CAAA,KAAA,kBAlCjD,KAAA,CAAI,SAAA,EAAS,MAAA,EACnB,MAAA,EAAM,IAAA,EACR,KAAA,CAAI,IAAA,CAAK,MAAA,MACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,MAAA,GAAS,WAAA,CAAY,UAAA"}
|
package/dist/ActionRunner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Context, Effect, Layer, Schema } from "effect";
|
|
2
|
+
import { Context, Effect, Layer, Match, Schema } from "effect";
|
|
3
3
|
import * as Ref$1 from "@confect/core/Ref";
|
|
4
4
|
import "convex/server";
|
|
5
5
|
|
|
@@ -8,15 +8,17 @@ var ActionRunner_exports = /* @__PURE__ */ __exportAll({
|
|
|
8
8
|
ActionRunner: () => ActionRunner,
|
|
9
9
|
layer: () => layer
|
|
10
10
|
});
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const make = (runAction) => (action, args) => Effect.gen(function* () {
|
|
12
|
+
const functionSpec = Ref$1.getFunctionSpec(action);
|
|
13
13
|
const functionName = Ref$1.getConvexFunctionName(action);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
return yield* Match.value(functionSpec.functionProvenance).pipe(Match.tag("Confect", (confectFunctionSpec) => Effect.gen(function* () {
|
|
15
|
+
const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(args);
|
|
16
|
+
const encodedReturns = yield* Effect.promise(() => runAction(functionName, encodedArgs));
|
|
17
|
+
return yield* Schema.decode(confectFunctionSpec.returns)(encodedReturns);
|
|
18
|
+
})), Match.tag("Convex", () => Effect.promise(() => runAction(functionName, args))), Match.exhaustive);
|
|
17
19
|
});
|
|
18
20
|
const ActionRunner = Context.GenericTag("@confect/server/ActionRunner");
|
|
19
|
-
const layer = (runAction) => Layer.succeed(ActionRunner,
|
|
21
|
+
const layer = (runAction) => Layer.succeed(ActionRunner, make(runAction));
|
|
20
22
|
|
|
21
23
|
//#endregion
|
|
22
24
|
export { ActionRunner, ActionRunner_exports, layer };
|
package/dist/ActionRunner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionRunner.js","names":["Ref"],"sources":["../src/ActionRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericActionCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Schema } from \"effect\";\n\nconst
|
|
1
|
+
{"version":3,"file":"ActionRunner.js","names":["Ref"],"sources":["../src/ActionRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport { type GenericActionCtx } from \"convex/server\";\nimport type { ParseResult } from \"effect\";\nimport { Context, Effect, Layer, Match, Schema } from \"effect\";\n\nconst make =\n (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n <Action extends Ref.AnyAction>(\n action: Action,\n args: Ref.Args<Action>,\n ): Effect.Effect<Ref.Returns<Action>, ParseResult.ParseError> =>\n Effect.gen(function* () {\n const functionSpec = Ref.getFunctionSpec(action);\n const functionName = Ref.getConvexFunctionName(action);\n\n return yield* Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confectFunctionSpec) =>\n Effect.gen(function* () {\n const encodedArgs = yield* Schema.encode(confectFunctionSpec.args)(\n args,\n );\n const encodedReturns = yield* Effect.promise(() =>\n runAction(functionName as any, encodedArgs),\n );\n return yield* Schema.decode(confectFunctionSpec.returns)(\n encodedReturns,\n );\n }),\n ),\n Match.tag(\"Convex\", () =>\n Effect.promise(() => runAction(functionName as any, args as any)),\n ),\n Match.exhaustive,\n );\n });\n\nexport const ActionRunner = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/ActionRunner\",\n);\nexport type ActionRunner = typeof ActionRunner.Identifier;\n\nexport const layer = (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n Layer.succeed(ActionRunner, make(runAction));\n"],"mappings":";;;;;;;;;;AAKA,MAAM,QACH,eAEC,QACA,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,eAAeA,MAAI,gBAAgB,OAAO;CAChD,MAAM,eAAeA,MAAI,sBAAsB,OAAO;AAEtD,QAAO,OAAO,MAAM,MAAM,aAAa,mBAAmB,CAAC,KACzD,MAAM,IAAI,YAAY,wBACpB,OAAO,IAAI,aAAa;EACtB,MAAM,cAAc,OAAO,OAAO,OAAO,oBAAoB,KAAK,CAChE,KACD;EACD,MAAM,iBAAiB,OAAO,OAAO,cACnC,UAAU,cAAqB,YAAY,CAC5C;AACD,SAAO,OAAO,OAAO,OAAO,oBAAoB,QAAQ,CACtD,eACD;GACD,CACH,EACD,MAAM,IAAI,gBACR,OAAO,cAAc,UAAU,cAAqB,KAAY,CAAC,CAClE,EACD,MAAM,WACP;EACD;AAEN,MAAa,eAAe,QAAQ,WAClC,+BACD;AAGD,MAAa,SAAS,cACpB,MAAM,QAAQ,cAAc,KAAK,UAAU,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/BlobNotFoundError.d.ts
|
|
4
|
+
declare namespace BlobNotFoundError_d_exports {
|
|
5
|
+
export { BlobNotFoundError };
|
|
6
|
+
}
|
|
7
|
+
declare const BlobNotFoundError_base: Schema.TaggedErrorClass<BlobNotFoundError, "BlobNotFoundError", {
|
|
8
|
+
readonly _tag: Schema.tag<"BlobNotFoundError">;
|
|
9
|
+
} & {
|
|
10
|
+
id: typeof Schema.String;
|
|
11
|
+
}>;
|
|
12
|
+
declare class BlobNotFoundError extends BlobNotFoundError_base {
|
|
13
|
+
get message(): string;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { BlobNotFoundError, BlobNotFoundError_d_exports };
|
|
17
|
+
//# sourceMappingURL=BlobNotFoundError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlobNotFoundError.d.ts","names":[],"sources":["../src/BlobNotFoundError.ts"],"mappings":";;;;;;cAAgC,sBAAA;;;;;cAEnB,iBAAA,SAA0B,sBAAA;EAAA,IAMxB,OAAA,CAAA;AAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Schema } from "effect";
|
|
3
|
+
|
|
4
|
+
//#region src/BlobNotFoundError.ts
|
|
5
|
+
var BlobNotFoundError_exports = /* @__PURE__ */ __exportAll({ BlobNotFoundError: () => BlobNotFoundError });
|
|
6
|
+
var BlobNotFoundError = class extends Schema.TaggedError()("BlobNotFoundError", { id: Schema.String }) {
|
|
7
|
+
get message() {
|
|
8
|
+
return `File with ID '${this.id}' not found`;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { BlobNotFoundError, BlobNotFoundError_exports };
|
|
14
|
+
//# sourceMappingURL=BlobNotFoundError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlobNotFoundError.js","names":[],"sources":["../src/BlobNotFoundError.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nexport class BlobNotFoundError extends Schema.TaggedError<BlobNotFoundError>()(\n \"BlobNotFoundError\",\n {\n id: Schema.String,\n },\n) {\n override get message(): string {\n return `File with ID '${this.id}' not found`;\n }\n}\n"],"mappings":";;;;;AAEA,IAAa,oBAAb,cAAuC,OAAO,aAAgC,CAC5E,qBACA,EACE,IAAI,OAAO,QACZ,CACF,CAAC;CACA,IAAa,UAAkB;AAC7B,SAAO,iBAAiB,KAAK,GAAG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Cron, Duration } from "effect";
|
|
2
|
+
import { Ref as Ref$1 } from "@confect/core";
|
|
3
|
+
|
|
4
|
+
//#region src/CronJob.d.ts
|
|
5
|
+
declare namespace CronJob_d_exports {
|
|
6
|
+
export { CronJob, TypeId, isCronJob, make };
|
|
7
|
+
}
|
|
8
|
+
declare const TypeId = "@confect/server/CronJob";
|
|
9
|
+
type TypeId = typeof TypeId;
|
|
10
|
+
interface CronJob {
|
|
11
|
+
readonly [TypeId]: TypeId;
|
|
12
|
+
readonly identifier: string;
|
|
13
|
+
readonly schedule: Cron.Cron | Duration.Duration;
|
|
14
|
+
readonly ref: Ref$1.AnyMutation | Ref$1.AnyAction;
|
|
15
|
+
readonly args: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
declare const isCronJob: (u: unknown) => u is CronJob;
|
|
18
|
+
type OptionalArgs<R extends Ref$1.AnyMutation | Ref$1.AnyAction> = keyof Ref$1.Args<R> extends never ? [args?: Ref$1.Args<R>] : [args: Ref$1.Args<R>];
|
|
19
|
+
declare const make: <R extends Ref$1.AnyMutation | Ref$1.AnyAction>(identifier: string, schedule: Cron.Cron | Duration.Duration, ref: R, ...args: OptionalArgs<R>) => CronJob;
|
|
20
|
+
//#endregion
|
|
21
|
+
export { CronJob, CronJob_d_exports, TypeId, isCronJob, make };
|
|
22
|
+
//# sourceMappingURL=CronJob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CronJob.d.ts","names":[],"sources":["../src/CronJob.ts"],"mappings":";;;;;;;cAIa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,UAEX,OAAA;EAAA,UACL,MAAA,GAAS,MAAA;EAAA,SAEV,UAAA;EAAA,SACA,QAAA,EAAU,IAAA,CAAK,IAAA,GAAO,QAAA,CAAS,QAAA;EAAA,SAC/B,GAAA,EAAK,KAAA,CAAI,WAAA,GAAc,KAAA,CAAI,SAAA;EAAA,SAC3B,IAAA,EAAM,MAAA;AAAA;AAAA,cAGJ,SAAA,GAAa,CAAA,cAAa,CAAA,IAAK,OAAA;AAAA,KAGvC,YAAA,WAAuB,KAAA,CAAI,WAAA,GAAc,KAAA,CAAI,SAAA,UAC1C,KAAA,CAAI,IAAA,CAAK,CAAA,mBAAoB,IAAA,GAAO,KAAA,CAAI,IAAA,CAAK,CAAA,MAAO,IAAA,EAAM,KAAA,CAAI,IAAA,CAAK,CAAA;AAAA,cAmB9D,IAAA,aAAkB,KAAA,CAAI,WAAA,GAAc,KAAA,CAAI,SAAA,EACnD,UAAA,UACA,QAAA,EAAU,IAAA,CAAK,IAAA,GAAO,QAAA,CAAS,QAAA,EAC/B,GAAA,EAAK,CAAA,KACF,IAAA,EAAM,YAAA,CAAa,CAAA,MACrB,OAAA"}
|
package/dist/CronJob.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Predicate } from "effect";
|
|
3
|
+
|
|
4
|
+
//#region src/CronJob.ts
|
|
5
|
+
var CronJob_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
TypeId: () => TypeId,
|
|
7
|
+
isCronJob: () => isCronJob,
|
|
8
|
+
make: () => make
|
|
9
|
+
});
|
|
10
|
+
const TypeId = "@confect/server/CronJob";
|
|
11
|
+
const isCronJob = (u) => Predicate.hasProperty(u, TypeId);
|
|
12
|
+
const Proto = { [TypeId]: TypeId };
|
|
13
|
+
const makeProto = (identifier, schedule, ref, args) => Object.assign(Object.create(Proto), {
|
|
14
|
+
identifier,
|
|
15
|
+
schedule,
|
|
16
|
+
ref,
|
|
17
|
+
args
|
|
18
|
+
});
|
|
19
|
+
const make = (identifier, schedule, ref, ...args) => makeProto(identifier, schedule, ref, args[0] ?? {});
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { CronJob_exports, TypeId, isCronJob, make };
|
|
23
|
+
//# sourceMappingURL=CronJob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CronJob.js","names":[],"sources":["../src/CronJob.ts"],"sourcesContent":["import type { Ref } from \"@confect/core\";\nimport type { Cron, Duration } from \"effect\";\nimport { Predicate } from \"effect\";\n\nexport const TypeId = \"@confect/server/CronJob\";\nexport type TypeId = typeof TypeId;\n\nexport interface CronJob {\n readonly [TypeId]: TypeId;\n\n readonly identifier: string;\n readonly schedule: Cron.Cron | Duration.Duration;\n readonly ref: Ref.AnyMutation | Ref.AnyAction;\n readonly args: Record<string, unknown>;\n}\n\nexport const isCronJob = (u: unknown): u is CronJob =>\n Predicate.hasProperty(u, TypeId);\n\ntype OptionalArgs<R extends Ref.AnyMutation | Ref.AnyAction> =\n keyof Ref.Args<R> extends never ? [args?: Ref.Args<R>] : [args: Ref.Args<R>];\n\nconst Proto = {\n [TypeId]: TypeId,\n};\n\nconst makeProto = (\n identifier: string,\n schedule: Cron.Cron | Duration.Duration,\n ref: Ref.AnyMutation | Ref.AnyAction,\n args: Record<string, unknown>,\n): CronJob =>\n Object.assign(Object.create(Proto), {\n identifier,\n schedule,\n ref,\n args,\n });\n\nexport const make = <R extends Ref.AnyMutation | Ref.AnyAction>(\n identifier: string,\n schedule: Cron.Cron | Duration.Duration,\n ref: R,\n ...args: OptionalArgs<R>\n): CronJob => makeProto(identifier, schedule, ref, args[0] ?? {});\n"],"mappings":";;;;;;;;;AAIA,MAAa,SAAS;AAYtB,MAAa,aAAa,MACxB,UAAU,YAAY,GAAG,OAAO;AAKlC,MAAM,QAAQ,GACX,SAAS,QACX;AAED,MAAM,aACJ,YACA,UACA,KACA,SAEA,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE;CAClC;CACA;CACA;CACA;CACD,CAAC;AAEJ,MAAa,QACX,YACA,UACA,KACA,GAAG,SACS,UAAU,YAAY,UAAU,KAAK,KAAK,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CronJob as CronJob$1 } from "./CronJob.js";
|
|
2
|
+
import { Cron, Duration } from "effect";
|
|
3
|
+
import { CronJob, Crons } from "convex/server";
|
|
4
|
+
|
|
5
|
+
//#region src/CronJobs.d.ts
|
|
6
|
+
declare namespace CronJobs_d_exports {
|
|
7
|
+
export { CronJobs, TypeId, cronToConvexCronString, durationToConvexIntervalSchedule, isCronJobs, make };
|
|
8
|
+
}
|
|
9
|
+
declare const TypeId = "@confect/server/CronJobs";
|
|
10
|
+
type TypeId = typeof TypeId;
|
|
11
|
+
interface CronJobs {
|
|
12
|
+
readonly [TypeId]: TypeId;
|
|
13
|
+
readonly cronJobs: Record<string, CronJob$1>;
|
|
14
|
+
readonly convexCronJobs: Crons;
|
|
15
|
+
add(cron: CronJob$1): CronJobs;
|
|
16
|
+
}
|
|
17
|
+
declare const isCronJobs: (u: unknown) => u is CronJobs;
|
|
18
|
+
declare const make: () => CronJobs;
|
|
19
|
+
/** @internal */
|
|
20
|
+
declare const cronToConvexCronString: (cron: Cron.Cron) => string;
|
|
21
|
+
/** @internal */
|
|
22
|
+
declare const durationToConvexIntervalSchedule: (duration: Duration.Duration) => IntervalSchedule;
|
|
23
|
+
type IntervalSchedule = Extract<CronJob["schedule"], {
|
|
24
|
+
type: "interval";
|
|
25
|
+
}>;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { CronJobs, CronJobs_d_exports, TypeId, cronToConvexCronString, durationToConvexIntervalSchedule, isCronJobs, make };
|
|
28
|
+
//# sourceMappingURL=CronJobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CronJobs.d.ts","names":[],"sources":["../src/CronJobs.ts"],"mappings":";;;;;;;;cAmBa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,UAEX,QAAA;EAAA,UACL,MAAA,GAAS,MAAA;EAAA,SACV,QAAA,EAAU,MAAA,SAAe,SAAA;EAAA,SACzB,cAAA,EAAgB,KAAA;EAEzB,GAAA,CAAI,IAAA,EAAM,SAAA,GAAkB,QAAA;AAAA;AAAA,cAGjB,UAAA,GAAc,CAAA,cAAa,CAAA,IAAK,QAAA;AAAA,cA4DhC,IAAA,QAAW,QAAA;AAvExB;AAAA,cA0Ea,sBAAA,GAA0B,IAAA,EAAM,IAAA,CAAK,IAAA;;cAiCrC,gCAAA,GACX,QAAA,EAAU,QAAA,CAAS,QAAA,KAClB,gBAAA;AAAA,KA6BE,gBAAA,GAAmB,OAAA,CACtB,OAAA;EACE,IAAA;AAAA"}
|
package/dist/CronJobs.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Array, Cron, Duration, Match, Order, Predicate, Record, Schema, pipe } from "effect";
|
|
3
|
+
import { cronJobs } from "convex/server";
|
|
4
|
+
import { Ref as Ref$1 } from "@confect/core";
|
|
5
|
+
|
|
6
|
+
//#region src/CronJobs.ts
|
|
7
|
+
var CronJobs_exports = /* @__PURE__ */ __exportAll({
|
|
8
|
+
TypeId: () => TypeId,
|
|
9
|
+
cronToConvexCronString: () => cronToConvexCronString,
|
|
10
|
+
durationToConvexIntervalSchedule: () => durationToConvexIntervalSchedule,
|
|
11
|
+
isCronJobs: () => isCronJobs,
|
|
12
|
+
make: () => make
|
|
13
|
+
});
|
|
14
|
+
const TypeId = "@confect/server/CronJobs";
|
|
15
|
+
const isCronJobs = (u) => Predicate.hasProperty(u, TypeId);
|
|
16
|
+
const Proto = {
|
|
17
|
+
[TypeId]: TypeId,
|
|
18
|
+
add(cronJob) {
|
|
19
|
+
const newConvexCrons = Object.assign(cronJobs(), { crons: { ...this.convexCronJobs.crons } });
|
|
20
|
+
const schedulableFunctionReference = Ref$1.getConvexFunctionName(cronJob.ref);
|
|
21
|
+
const functionSpec = Ref$1.getFunctionSpec(cronJob.ref);
|
|
22
|
+
const encodedArgs = Match.value(functionSpec.functionProvenance).pipe(Match.tag("Confect", (confect) => Schema.encodeSync(confect.args)(cronJob.args)), Match.tag("Convex", () => cronJob.args), Match.exhaustive);
|
|
23
|
+
Match.value(cronJob.schedule).pipe(Match.when(Cron.isCron, (cron) => {
|
|
24
|
+
newConvexCrons.cron(cronJob.identifier, cronToConvexCronString(cron), schedulableFunctionReference, encodedArgs);
|
|
25
|
+
}), Match.when(Duration.isDuration, (duration) => {
|
|
26
|
+
newConvexCrons.interval(cronJob.identifier, durationToConvexIntervalSchedule(duration), schedulableFunctionReference, encodedArgs);
|
|
27
|
+
}), Match.exhaustive);
|
|
28
|
+
return makeProto(Record.set(this.cronJobs, cronJob.identifier, cronJob), newConvexCrons);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const makeProto = (cronJobs, convexCronJobs) => Object.assign(Object.create(Proto), {
|
|
32
|
+
cronJobs,
|
|
33
|
+
convexCronJobs
|
|
34
|
+
});
|
|
35
|
+
const make = () => makeProto({}, cronJobs());
|
|
36
|
+
/** @internal */
|
|
37
|
+
const cronToConvexCronString = (cron) => {
|
|
38
|
+
if (cron.seconds.size !== 1 || !cron.seconds.has(0)) throw new Error("Convex cron expressions do not support a seconds field. The seconds field must be the default {0}. Sub-minute scheduling is supported only by interval schedules defined using a Duration.");
|
|
39
|
+
return Array.join([
|
|
40
|
+
setToField(cron.minutes),
|
|
41
|
+
setToField(cron.hours),
|
|
42
|
+
setToField(cron.days),
|
|
43
|
+
setToField(cron.months),
|
|
44
|
+
setToField(cron.weekdays)
|
|
45
|
+
], " ");
|
|
46
|
+
};
|
|
47
|
+
const setToField = (set) => {
|
|
48
|
+
if (set.size === 0) return "*";
|
|
49
|
+
return pipe(set, Array.sort(Order.number), Array.map((n) => n.toString()), Array.join(","));
|
|
50
|
+
};
|
|
51
|
+
/** @internal */
|
|
52
|
+
const durationToConvexIntervalSchedule = (duration) => {
|
|
53
|
+
const millis = Duration.toMillis(duration);
|
|
54
|
+
if (millis <= 0) throw new Error("Interval must be a positive duration.");
|
|
55
|
+
const hours = millis / Duration.hours(1).pipe(Duration.toMillis);
|
|
56
|
+
if (Number.isInteger(hours)) return {
|
|
57
|
+
type: "interval",
|
|
58
|
+
hours
|
|
59
|
+
};
|
|
60
|
+
const minutes = millis / Duration.minutes(1).pipe(Duration.toMillis);
|
|
61
|
+
if (Number.isInteger(minutes)) return {
|
|
62
|
+
type: "interval",
|
|
63
|
+
minutes
|
|
64
|
+
};
|
|
65
|
+
const seconds = millis / Duration.seconds(1).pipe(Duration.toMillis);
|
|
66
|
+
if (Number.isInteger(seconds)) return {
|
|
67
|
+
type: "interval",
|
|
68
|
+
seconds
|
|
69
|
+
};
|
|
70
|
+
throw new Error("Interval must be a whole number of seconds, minutes, or hours.");
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
export { CronJobs_exports, TypeId, cronToConvexCronString, durationToConvexIntervalSchedule, isCronJobs, make };
|
|
75
|
+
//# sourceMappingURL=CronJobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CronJobs.js","names":["makeConvexCrons","Ref"],"sources":["../src/CronJobs.ts"],"sourcesContent":["import { Ref } from \"@confect/core\";\nimport type {\n CronJob as ConvexCronJob,\n SchedulableFunctionReference,\n} from \"convex/server\";\nimport { cronJobs as makeConvexCrons, type Crons } from \"convex/server\";\nimport {\n Array,\n Cron,\n Duration,\n Match,\n Order,\n pipe,\n Predicate,\n Record,\n Schema,\n} from \"effect\";\nimport type * as CronJob from \"./CronJob\";\n\nexport const TypeId = \"@confect/server/CronJobs\";\nexport type TypeId = typeof TypeId;\n\nexport interface CronJobs {\n readonly [TypeId]: TypeId;\n readonly cronJobs: Record<string, CronJob.CronJob>;\n readonly convexCronJobs: Crons;\n\n add(cron: CronJob.CronJob): CronJobs;\n}\n\nexport const isCronJobs = (u: unknown): u is CronJobs =>\n Predicate.hasProperty(u, TypeId);\n\nconst Proto = {\n [TypeId]: TypeId,\n\n add(this: CronJobs, cronJob: CronJob.CronJob) {\n const newConvexCrons = Object.assign(makeConvexCrons(), {\n crons: { ...this.convexCronJobs.crons },\n });\n\n const schedulableFunctionReference = Ref.getConvexFunctionName(\n cronJob.ref,\n ) as unknown as SchedulableFunctionReference;\n\n const functionSpec = Ref.getFunctionSpec(cronJob.ref);\n const encodedArgs = Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Confect\", (confect) =>\n Schema.encodeSync(confect.args)(cronJob.args),\n ),\n Match.tag(\"Convex\", () => cronJob.args),\n Match.exhaustive,\n );\n\n Match.value(cronJob.schedule).pipe(\n Match.when(Cron.isCron, (cron) => {\n newConvexCrons.cron(\n cronJob.identifier,\n cronToConvexCronString(cron),\n schedulableFunctionReference,\n encodedArgs,\n );\n }),\n Match.when(Duration.isDuration, (duration) => {\n newConvexCrons.interval(\n cronJob.identifier,\n durationToConvexIntervalSchedule(duration),\n schedulableFunctionReference,\n encodedArgs,\n );\n }),\n Match.exhaustive,\n );\n\n return makeProto(\n Record.set(this.cronJobs, cronJob.identifier, cronJob),\n newConvexCrons,\n );\n },\n};\n\nconst makeProto = (\n cronJobs: Record<string, CronJob.CronJob>,\n convexCronJobs: Crons,\n): CronJobs =>\n Object.assign(Object.create(Proto), {\n cronJobs,\n convexCronJobs,\n });\n\nexport const make = (): CronJobs => makeProto({}, makeConvexCrons());\n\n/** @internal */\nexport const cronToConvexCronString = (cron: Cron.Cron): string => {\n const hasNonDefaultSeconds = cron.seconds.size !== 1 || !cron.seconds.has(0);\n if (hasNonDefaultSeconds) {\n throw new Error(\n \"Convex cron expressions do not support a seconds field. \" +\n \"The seconds field must be the default {0}. \" +\n \"Sub-minute scheduling is supported only by interval schedules defined using a Duration.\",\n );\n }\n\n return Array.join(\n [\n setToField(cron.minutes),\n setToField(cron.hours),\n setToField(cron.days),\n setToField(cron.months),\n setToField(cron.weekdays),\n ],\n \" \",\n );\n};\n\nconst setToField = (set: ReadonlySet<number>): string => {\n if (set.size === 0) return \"*\";\n return pipe(\n set,\n Array.sort(Order.number),\n Array.map((n) => n.toString()),\n Array.join(\",\"),\n );\n};\n\n/** @internal */\nexport const durationToConvexIntervalSchedule = (\n duration: Duration.Duration,\n): IntervalSchedule => {\n const millis = Duration.toMillis(duration);\n if (millis <= 0) {\n throw new Error(\"Interval must be a positive duration.\");\n }\n\n const oneHourInMillis = Duration.hours(1).pipe(Duration.toMillis);\n const hours = millis / oneHourInMillis;\n if (Number.isInteger(hours)) {\n return { type: \"interval\", hours };\n }\n\n const oneMinuteInMillis = Duration.minutes(1).pipe(Duration.toMillis);\n const minutes = millis / oneMinuteInMillis;\n if (Number.isInteger(minutes)) {\n return { type: \"interval\", minutes };\n }\n\n const oneSecondInMillis = Duration.seconds(1).pipe(Duration.toMillis);\n const seconds = millis / oneSecondInMillis;\n if (Number.isInteger(seconds)) {\n return { type: \"interval\", seconds };\n }\n\n throw new Error(\n \"Interval must be a whole number of seconds, minutes, or hours.\",\n );\n};\n\ntype IntervalSchedule = Extract<\n ConvexCronJob[\"schedule\"],\n { type: \"interval\" }\n>;\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAa,SAAS;AAWtB,MAAa,cAAc,MACzB,UAAU,YAAY,GAAG,OAAO;AAElC,MAAM,QAAQ;EACX,SAAS;CAEV,IAAoB,SAA0B;EAC5C,MAAM,iBAAiB,OAAO,OAAOA,UAAiB,EAAE,EACtD,OAAO,EAAE,GAAG,KAAK,eAAe,OAAO,EACxC,CAAC;EAEF,MAAM,+BAA+BC,MAAI,sBACvC,QAAQ,IACT;EAED,MAAM,eAAeA,MAAI,gBAAgB,QAAQ,IAAI;EACrD,MAAM,cAAc,MAAM,MAAM,aAAa,mBAAmB,CAAC,KAC/D,MAAM,IAAI,YAAY,YACpB,OAAO,WAAW,QAAQ,KAAK,CAAC,QAAQ,KAAK,CAC9C,EACD,MAAM,IAAI,gBAAgB,QAAQ,KAAK,EACvC,MAAM,WACP;AAED,QAAM,MAAM,QAAQ,SAAS,CAAC,KAC5B,MAAM,KAAK,KAAK,SAAS,SAAS;AAChC,kBAAe,KACb,QAAQ,YACR,uBAAuB,KAAK,EAC5B,8BACA,YACD;IACD,EACF,MAAM,KAAK,SAAS,aAAa,aAAa;AAC5C,kBAAe,SACb,QAAQ,YACR,iCAAiC,SAAS,EAC1C,8BACA,YACD;IACD,EACF,MAAM,WACP;AAED,SAAO,UACL,OAAO,IAAI,KAAK,UAAU,QAAQ,YAAY,QAAQ,EACtD,eACD;;CAEJ;AAED,MAAM,aACJ,UACA,mBAEA,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE;CAClC;CACA;CACD,CAAC;AAEJ,MAAa,aAAuB,UAAU,EAAE,EAAED,UAAiB,CAAC;;AAGpE,MAAa,0BAA0B,SAA4B;AAEjE,KAD6B,KAAK,QAAQ,SAAS,KAAK,CAAC,KAAK,QAAQ,IAAI,EAAE,CAE1E,OAAM,IAAI,MACR,6LAGD;AAGH,QAAO,MAAM,KACX;EACE,WAAW,KAAK,QAAQ;EACxB,WAAW,KAAK,MAAM;EACtB,WAAW,KAAK,KAAK;EACrB,WAAW,KAAK,OAAO;EACvB,WAAW,KAAK,SAAS;EAC1B,EACD,IACD;;AAGH,MAAM,cAAc,QAAqC;AACvD,KAAI,IAAI,SAAS,EAAG,QAAO;AAC3B,QAAO,KACL,KACA,MAAM,KAAK,MAAM,OAAO,EACxB,MAAM,KAAK,MAAM,EAAE,UAAU,CAAC,EAC9B,MAAM,KAAK,IAAI,CAChB;;;AAIH,MAAa,oCACX,aACqB;CACrB,MAAM,SAAS,SAAS,SAAS,SAAS;AAC1C,KAAI,UAAU,EACZ,OAAM,IAAI,MAAM,wCAAwC;CAI1D,MAAM,QAAQ,SADU,SAAS,MAAM,EAAE,CAAC,KAAK,SAAS,SAAS;AAEjE,KAAI,OAAO,UAAU,MAAM,CACzB,QAAO;EAAE,MAAM;EAAY;EAAO;CAIpC,MAAM,UAAU,SADU,SAAS,QAAQ,EAAE,CAAC,KAAK,SAAS,SAAS;AAErE,KAAI,OAAO,UAAU,QAAQ,CAC3B,QAAO;EAAE,MAAM;EAAY;EAAS;CAItC,MAAM,UAAU,SADU,SAAS,QAAQ,EAAE,CAAC,KAAK,SAAS,SAAS;AAErE,KAAI,OAAO,UAAU,QAAQ,CAC3B,QAAO;EAAE,MAAM;EAAY;EAAS;AAGtC,OAAM,IAAI,MACR,iEACD"}
|
package/dist/DatabaseWriter.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare namespace DatabaseWriter_d_exports {
|
|
|
13
13
|
declare const make: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseWriter: GenericDatabaseWriter<ToConvex<FromSchema<DatabaseSchema_>>>) => {
|
|
14
14
|
table: <const TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName) => {
|
|
15
15
|
insert: (document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
|
|
16
|
-
patch: (id: GenericId<TableName>, patchedValues: Partial<WithoutSystemFields<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>>) => Effect.Effect<void,
|
|
16
|
+
patch: (id: GenericId<TableName>, patchedValues: Partial<WithoutSystemFields<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>>) => Effect.Effect<void, DocumentEncodeError | GetByIdFailure | DocumentDecodeError, never>;
|
|
17
17
|
replace: (id: GenericId<TableName>, value: WithoutSystemFields<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
18
18
|
delete: (id: GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
19
19
|
};
|
|
@@ -21,14 +21,14 @@ declare const make: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: Datab
|
|
|
21
21
|
declare const DatabaseWriter: <DatabaseSchema_ extends AnyWithProps>() => Context.Tag<{
|
|
22
22
|
table: <const TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName) => {
|
|
23
23
|
insert: (document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
|
|
24
|
-
patch: (id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void,
|
|
24
|
+
patch: (id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentEncodeError | GetByIdFailure | DocumentDecodeError, never>;
|
|
25
25
|
replace: (id: GenericId<TableName>, value: Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
26
26
|
delete: (id: GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
27
27
|
};
|
|
28
28
|
}, {
|
|
29
29
|
table: <const TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName) => {
|
|
30
30
|
insert: (document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
|
|
31
|
-
patch: (id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void,
|
|
31
|
+
patch: (id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentEncodeError | GetByIdFailure | DocumentDecodeError, never>;
|
|
32
32
|
replace: (id: GenericId<TableName>, value: Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
33
33
|
delete: (id: GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
34
34
|
};
|
|
@@ -37,7 +37,7 @@ type DatabaseWriter<DatabaseSchema_ extends AnyWithProps> = ReturnType<typeof Da
|
|
|
37
37
|
declare const layer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseWriter: GenericDatabaseWriter<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<{
|
|
38
38
|
table: <const TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName) => {
|
|
39
39
|
insert: (document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
|
|
40
|
-
patch: (id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void,
|
|
40
|
+
patch: (id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentEncodeError | GetByIdFailure | DocumentDecodeError, never>;
|
|
41
41
|
replace: (id: GenericId<TableName>, value: Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
42
42
|
delete: (id: GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
43
43
|
};
|
package/dist/FunctionImpl.js
CHANGED
|
@@ -13,14 +13,14 @@ const FunctionImpl = ({ groupPath, functionName }) => Context.GenericTag(`@confe
|
|
|
13
13
|
const make = (api, groupPath, functionName, handler) => {
|
|
14
14
|
const groupPathParts = String.split(groupPath, ".");
|
|
15
15
|
const [firstGroupPathPart, ...restGroupPathParts] = groupPathParts;
|
|
16
|
-
const
|
|
16
|
+
const functionSpec = Array.reduce(restGroupPathParts, api.spec.groups[firstGroupPathPart], (currentGroup, groupPathPart) => currentGroup.groups[groupPathPart]).functions[functionName];
|
|
17
17
|
return Layer.effect(FunctionImpl({
|
|
18
18
|
groupPath,
|
|
19
19
|
functionName
|
|
20
20
|
}), Effect.gen(function* () {
|
|
21
21
|
const registry = yield* Registry;
|
|
22
22
|
yield* Ref.update(registry, (registryItems) => setNestedProperty(registryItems, [...groupPathParts, functionName], make$1({
|
|
23
|
-
|
|
23
|
+
functionSpec,
|
|
24
24
|
handler
|
|
25
25
|
})));
|
|
26
26
|
return {
|
package/dist/FunctionImpl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionImpl.js","names":["Registry.Registry","RegistryItem.make"],"sources":["../src/FunctionImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupPath from \"@confect/core/GroupPath\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { Array, Context, Effect, Layer, Ref, String } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as Handler from \"./Handler\";\nimport { setNestedProperty } from \"./internal/utils\";\nimport * as Registry from \"./Registry\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport interface FunctionImpl<\n GroupPath_ extends string,\n FunctionName extends string,\n> {\n readonly groupPath: GroupPath_;\n readonly functionName: FunctionName;\n}\n\nexport const FunctionImpl = <\n GroupPath_ extends string,\n FunctionName extends string,\n>({\n groupPath,\n functionName,\n}: {\n groupPath: GroupPath_;\n functionName: FunctionName;\n}) =>\n Context.GenericTag<FunctionImpl<GroupPath_, FunctionName>>(\n `@confect/server/FunctionImpl/${groupPath}/${functionName}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n const GroupPath_ extends GroupPath.All<Api.Groups<Api_>>,\n const FunctionName extends FunctionSpec.Name<\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>\n >,\n>(\n api: Api_,\n groupPath: GroupPath_,\n functionName: FunctionName,\n handler: Handler.WithName<\n Api.Schema<Api_>,\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>,\n FunctionName\n >,\n): Layer.Layer<FunctionImpl<GroupPath_, FunctionName>> => {\n const groupPathParts = String.split(groupPath, \".\");\n const [firstGroupPathPart, ...restGroupPathParts] = groupPathParts;\n\n const group_: GroupSpec.AnyWithProps = Array.reduce(\n restGroupPathParts,\n (api as any).spec.groups[firstGroupPathPart as any]!,\n (currentGroup: any, groupPathPart: any) =>\n currentGroup.groups[groupPathPart],\n );\n\n const
|
|
1
|
+
{"version":3,"file":"FunctionImpl.js","names":["Registry.Registry","RegistryItem.make"],"sources":["../src/FunctionImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupPath from \"@confect/core/GroupPath\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport { Array, Context, Effect, Layer, Ref, String } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type * as Handler from \"./Handler\";\nimport { setNestedProperty } from \"./internal/utils\";\nimport * as Registry from \"./Registry\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport interface FunctionImpl<\n GroupPath_ extends string,\n FunctionName extends string,\n> {\n readonly groupPath: GroupPath_;\n readonly functionName: FunctionName;\n}\n\nexport const FunctionImpl = <\n GroupPath_ extends string,\n FunctionName extends string,\n>({\n groupPath,\n functionName,\n}: {\n groupPath: GroupPath_;\n functionName: FunctionName;\n}) =>\n Context.GenericTag<FunctionImpl<GroupPath_, FunctionName>>(\n `@confect/server/FunctionImpl/${groupPath}/${functionName}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n const GroupPath_ extends GroupPath.All<Api.Groups<Api_>>,\n const FunctionName extends FunctionSpec.Name<\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>\n >,\n>(\n api: Api_,\n groupPath: GroupPath_,\n functionName: FunctionName,\n handler: Handler.WithName<\n Api.Schema<Api_>,\n GroupSpec.Functions<GroupPath.GroupAt<Api.Groups<Api_>, GroupPath_>>,\n FunctionName\n >,\n): Layer.Layer<FunctionImpl<GroupPath_, FunctionName>> => {\n const groupPathParts = String.split(groupPath, \".\");\n const [firstGroupPathPart, ...restGroupPathParts] = groupPathParts;\n\n const group_: GroupSpec.AnyWithProps = Array.reduce(\n restGroupPathParts,\n (api as any).spec.groups[firstGroupPathPart as any]!,\n (currentGroup: any, groupPathPart: any) =>\n currentGroup.groups[groupPathPart],\n );\n\n const functionSpec = group_.functions[functionName]!;\n\n return Layer.effect(\n FunctionImpl<GroupPath_, FunctionName>({\n groupPath,\n functionName,\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n\n yield* Ref.update(registry, (registryItems) =>\n setNestedProperty(\n registryItems,\n [...groupPathParts, functionName],\n RegistryItem.make({\n functionSpec,\n handler,\n }),\n ),\n );\n\n return {\n groupPath,\n functionName,\n };\n }),\n );\n};\n\n/**\n * Get the function implementation service type for a specific group path and function name.\n */\nexport type ForGroupPathAndFunction<\n GroupPath_ extends string,\n FunctionName extends string,\n> = FunctionImpl<GroupPath_, FunctionName>;\n\n/**\n * Get all function implementation services required for a group at a given path.\n */\nexport type FromGroupAtPath<\n GroupPath_ extends string,\n Group extends GroupSpec.AnyWithProps,\n> =\n GroupPath.GroupAt<Group, GroupPath_> extends infer GroupAtPath extends\n GroupSpec.AnyWithProps\n ? FunctionSpec.Name<\n GroupSpec.Functions<GroupAtPath>\n > extends infer FunctionNames extends string\n ? FunctionNames extends string\n ? FunctionImpl<GroupPath_, FunctionNames>\n : never\n : never\n : never;\n"],"mappings":";;;;;;;;;;;AAkBA,MAAa,gBAGX,EACA,WACA,mBAKA,QAAQ,WACN,gCAAgC,UAAU,GAAG,eAC9C;AAEH,MAAa,QAOX,KACA,WACA,cACA,YAKwD;CACxD,MAAM,iBAAiB,OAAO,MAAM,WAAW,IAAI;CACnD,MAAM,CAAC,oBAAoB,GAAG,sBAAsB;CASpD,MAAM,eAPiC,MAAM,OAC3C,oBACC,IAAY,KAAK,OAAO,sBACxB,cAAmB,kBAClB,aAAa,OAAO,eACvB,CAE2B,UAAU;AAEtC,QAAO,MAAM,OACX,aAAuC;EACrC;EACA;EACD,CAAC,EACF,OAAO,IAAI,aAAa;EACtB,MAAM,WAAW,OAAOA;AAExB,SAAO,IAAI,OAAO,WAAW,kBAC3B,kBACE,eACA,CAAC,GAAG,gBAAgB,aAAa,EACjCC,OAAkB;GAChB;GACA;GACD,CAAC,CACH,CACF;AAED,SAAO;GACL;GACA;GACD;GACD,CACH"}
|
package/dist/Handler.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ActionCtx } from "./ActionCtx.js";
|
|
2
2
|
import { ActionRunner } from "./ActionRunner.js";
|
|
3
|
-
import { AnyWithProps
|
|
3
|
+
import { AnyWithProps } from "./DatabaseSchema.js";
|
|
4
4
|
import { Auth } from "./Auth.js";
|
|
5
5
|
import { FromSchema, ToConvex } from "./DataModel.js";
|
|
6
6
|
import { DatabaseReader } from "./DatabaseReader.js";
|
|
@@ -10,25 +10,33 @@ import { MutationRunner } from "./MutationRunner.js";
|
|
|
10
10
|
import { QueryCtx } from "./QueryCtx.js";
|
|
11
11
|
import { QueryRunner } from "./QueryRunner.js";
|
|
12
12
|
import { Scheduler } from "./Scheduler.js";
|
|
13
|
-
import { StorageActionWriter
|
|
13
|
+
import { StorageActionWriter } from "./StorageActionWriter.js";
|
|
14
|
+
import { StorageReader } from "./StorageReader.js";
|
|
15
|
+
import { StorageWriter } from "./StorageWriter.js";
|
|
14
16
|
import { VectorSearch } from "./VectorSearch.js";
|
|
17
|
+
import { Any as Any$1, ConvexRegisteredFunction } from "./RegisteredFunction.js";
|
|
15
18
|
import { Effect } from "effect";
|
|
16
|
-
import { NodeContext } from "@effect/platform-node";
|
|
17
19
|
import { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
20
|
+
import { NodeContext } from "@effect/platform-node";
|
|
21
|
+
import * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
18
22
|
|
|
19
23
|
//#region src/Handler.d.ts
|
|
20
24
|
declare namespace Handler_d_exports {
|
|
21
|
-
export {
|
|
25
|
+
export { Any, AnyConfectProvenance, AnyConvexProvenance, ConfectProvenanceMutation, ConfectProvenanceQuery, ConvexRuntimeAction, Handler, NodeRuntimeAction, WithName };
|
|
22
26
|
}
|
|
23
|
-
type Handler<DatabaseSchema_ extends AnyWithProps
|
|
24
|
-
type
|
|
25
|
-
type
|
|
26
|
-
type
|
|
27
|
-
type
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type AnyWithProps =
|
|
31
|
-
type
|
|
27
|
+
type Handler<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConvex> ? ConvexProvenanceHandler<FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConfect> ? ConfectProvenanceHandler<DatabaseSchema_, FunctionSpec_> : never;
|
|
28
|
+
type ConvexProvenanceHandler<FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConvex>> = ConvexRegisteredFunction<FunctionSpec_>;
|
|
29
|
+
type ConfectProvenanceHandler<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConfect>> = FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "query"> ? ConfectProvenanceQuery<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, "mutation"> ? ConfectProvenanceMutation<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<FunctionSpec_, RuntimeAndFunctionType.ConvexAction> ? ConvexRuntimeAction<DatabaseSchema_, FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<FunctionSpec_, RuntimeAndFunctionType.NodeAction> ? NodeRuntimeAction<DatabaseSchema_, FunctionSpec_> : never;
|
|
30
|
+
type ConfectProvenanceQuery<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | Auth | StorageReader | QueryRunner | QueryCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
|
|
31
|
+
type ConfectProvenanceMutation<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>> = Base<FunctionSpec_, DatabaseReader<DatabaseSchema_> | DatabaseWriter<DatabaseSchema_> | Auth | Scheduler | StorageReader | StorageWriter | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<DatabaseSchema_>>>>;
|
|
32
|
+
type ActionServices<DatabaseSchema_ extends AnyWithProps> = Scheduler | Auth | StorageReader | StorageWriter | StorageActionWriter | QueryRunner | MutationRunner | ActionRunner | VectorSearch<FromSchema<DatabaseSchema_>> | ActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>;
|
|
33
|
+
type ConvexRuntimeAction<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>> = Base<FunctionSpec_, ActionServices<DatabaseSchema_>>;
|
|
34
|
+
type NodeRuntimeAction<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>> = Base<FunctionSpec_, ActionServices<DatabaseSchema_> | NodeContext.NodeContext>;
|
|
35
|
+
type Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (args: FunctionSpec.Args<FunctionSpec_>) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>, never, R>;
|
|
36
|
+
type Any = AnyConfectProvenance | AnyConvexProvenance;
|
|
37
|
+
type AnyConfectProvenance = Base<FunctionSpec.AnyConfect, any>;
|
|
38
|
+
type AnyConvexProvenance = Any$1;
|
|
39
|
+
type WithName<DatabaseSchema_ extends AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithProps, FunctionName extends string> = Handler<DatabaseSchema_, FunctionSpec.WithName<FunctionSpec_, FunctionName>>;
|
|
32
40
|
//#endregion
|
|
33
|
-
export {
|
|
41
|
+
export { Any, AnyConfectProvenance, AnyConvexProvenance, ConfectProvenanceMutation, ConfectProvenanceQuery, ConvexRuntimeAction, Handler, Handler_d_exports, NodeRuntimeAction, WithName };
|
|
34
42
|
//# sourceMappingURL=Handler.d.ts.map
|
package/dist/Handler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.d.ts","names":[],"sources":["../src/Handler.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Handler.d.ts","names":[],"sources":["../src/Handler.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;KAsBY,OAAA,yBACc,YAAA,wBACF,YAAA,CAAa,YAAA,IAEnC,aAAA,SAAsB,YAAA,CAAa,sBAAA,CACjC,aAAA,EACA,kBAAA,CAAmB,SAAA,IAEjB,uBAAA,CAAwB,aAAA,IACxB,aAAA,SAAsB,YAAA,CAAa,sBAAA,CAC/B,aAAA,EACA,kBAAA,CAAmB,UAAA,IAErB,wBAAA,CAAyB,eAAA,EAAiB,aAAA;AAAA,KAG7C,uBAAA,uBAED,YAAA,CAAa,kCAAA,CAAmC,kBAAA,CAAmB,SAAA,KACnE,wBAAA,CAA4C,aAAA;AAAA,KAE3C,wBAAA,yBACqB,YAAA,wBAEtB,YAAA,CAAa,kCAAA,CAAmC,kBAAA,CAAmB,UAAA,KAErE,aAAA,SAAsB,YAAA,CAAa,gBAAA,CAAiB,aAAA,aAChD,sBAAA,CAAuB,eAAA,EAAiB,aAAA,IACxC,aAAA,SAAsB,YAAA,CAAa,gBAAA,CAC/B,aAAA,gBAGF,yBAAA,CAA0B,eAAA,EAAiB,aAAA,IAC3C,aAAA,SAAsB,YAAA,CAAa,0BAAA,CAC/B,aAAA,EACA,sBAAA,CAAuB,YAAA,IAEzB,mBAAA,CAAoB,eAAA,EAAiB,aAAA,IACrC,aAAA,SAAsB,YAAA,CAAa,0BAAA,CAC/B,aAAA,EACA,sBAAA,CAAuB,UAAA,IAEzB,iBAAA,CAAkB,eAAA,EAAiB,aAAA;AAAA,KAGnC,sBAAA,yBACc,YAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,QAAA,KACjE,IAAA,CACF,aAAA,EACE,cAAA,CAA8B,eAAA,IAC9B,IAAA,GACA,aAAA,GACA,WAAA,GACA,QAAA,CAAkB,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAGlD,yBAAA,yBACc,YAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,WAAA,KACjE,IAAA,CACF,aAAA,EACE,cAAA,CAA8B,eAAA,IAC9B,cAAA,CAA8B,eAAA,IAC9B,IAAA,GACA,SAAA,GACA,aAAA,GACA,aAAA,GACA,WAAA,GACA,cAAA,GACA,WAAA,CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAIzC,cAAA,yBAAuC,YAAA,IACxC,SAAA,GACA,IAAA,GACA,aAAA,GACA,aAAA,GACA,mBAAA,GACA,WAAA,GACA,cAAA,GACA,YAAA,GACA,YAAA,CAA0B,UAAA,CAAqB,eAAA,KAC/C,SAAA,CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAGlC,mBAAA,yBACc,YAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,SAAA,KACjE,IAAA,CAAK,aAAA,EAAe,cAAA,CAAe,eAAA;AAAA,KAE3B,iBAAA,yBACc,YAAA,wBAEtB,YAAA,CAAa,4BAAA,CAA6B,sBAAA,CAAuB,UAAA,KACjE,IAAA,CACF,aAAA,EACA,cAAA,CAAe,eAAA,IAAmB,WAAA,CAAY,WAAA;AAAA,KAG3C,IAAA,uBAA2B,YAAA,CAAa,YAAA,QAC3C,IAAA,EAAM,YAAA,CAAa,IAAA,CAAK,aAAA,MACrB,MAAA,CAAO,MAAA,CAAO,YAAA,CAAa,OAAA,CAAQ,aAAA,UAAuB,CAAA;AAAA,KAEnD,GAAA,GAAM,oBAAA,GAAuB,mBAAA;AAAA,KAE7B,oBAAA,GAAuB,IAAA,CAAK,YAAA,CAAa,UAAA;AAAA,KAEzC,mBAAA,GAAsB,KAAA;AAAA,KAEtB,QAAA,yBACc,YAAA,wBACF,YAAA,CAAa,YAAA,iCAEjC,OAAA,CACF,eAAA,EACA,YAAA,CAAa,QAAA,CAAS,aAAA,EAAe,YAAA"}
|
package/dist/Handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.js","names":[],"sources":["../src/Handler.ts"],"sourcesContent":["import type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport type { NodeContext } from \"@effect/platform-node\";\nimport type { Effect } from \"effect\";\nimport type * as ActionCtx from \"./ActionCtx\";\nimport type * as ActionRunner from \"./ActionRunner\";\nimport type * as Auth from \"./Auth\";\nimport type * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as MutationCtx from \"./MutationCtx\";\nimport type * as MutationRunner from \"./MutationRunner\";\nimport type * as QueryCtx from \"./QueryCtx\";\nimport type * as QueryRunner from \"./QueryRunner\";\nimport type * as Scheduler from \"./Scheduler\";\nimport type {\
|
|
1
|
+
{"version":3,"file":"Handler.js","names":[],"sources":["../src/Handler.ts"],"sourcesContent":["import type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport type * as FunctionProvenance from \"@confect/core/FunctionProvenance\";\nimport type { NodeContext } from \"@effect/platform-node\";\nimport type { Effect } from \"effect\";\nimport type * as ActionCtx from \"./ActionCtx\";\nimport type * as ActionRunner from \"./ActionRunner\";\nimport type * as Auth from \"./Auth\";\nimport type * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as MutationCtx from \"./MutationCtx\";\nimport type * as MutationRunner from \"./MutationRunner\";\nimport type * as QueryCtx from \"./QueryCtx\";\nimport type * as QueryRunner from \"./QueryRunner\";\nimport type * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as Scheduler from \"./Scheduler\";\nimport type { StorageActionWriter } from \"./StorageActionWriter\";\nimport type { StorageReader } from \"./StorageReader\";\nimport type { StorageWriter } from \"./StorageWriter\";\nimport type * as VectorSearch from \"./VectorSearch\";\n\nexport type Handler<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexProvenanceHandler<FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectProvenanceHandler<DatabaseSchema_, FunctionSpec_>\n : never;\n\ntype ConvexProvenanceHandler<\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConvex>,\n> = RegisteredFunction.ConvexRegisteredFunction<FunctionSpec_>;\n\ntype ConfectProvenanceHandler<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionProvenance<FunctionProvenance.AnyConfect>,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionType<FunctionSpec_, \"query\">\n ? ConfectProvenanceQuery<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionType<\n FunctionSpec_,\n \"mutation\"\n >\n ? ConfectProvenanceMutation<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<\n FunctionSpec_,\n RuntimeAndFunctionType.ConvexAction\n >\n ? ConvexRuntimeAction<DatabaseSchema_, FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithRuntimeAndFunctionType<\n FunctionSpec_,\n RuntimeAndFunctionType.NodeAction\n >\n ? NodeRuntimeAction<DatabaseSchema_, FunctionSpec_>\n : never;\n\nexport type ConfectProvenanceQuery<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyQuery>,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>\n>;\n\nexport type ConfectProvenanceMutation<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyMutation>,\n> = Base<\n FunctionSpec_,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | DatabaseWriter.DatabaseWriter<DatabaseSchema_>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n>;\n\ntype ActionServices<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> =\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | VectorSearch.VectorSearch<DataModel.FromSchema<DatabaseSchema_>>\n | ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >;\n\nexport type ConvexRuntimeAction<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.AnyAction>,\n> = Base<FunctionSpec_, ActionServices<DatabaseSchema_>>;\n\nexport type NodeRuntimeAction<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends\n FunctionSpec.AnyWithPropsWithFunctionType<RuntimeAndFunctionType.NodeAction>,\n> = Base<\n FunctionSpec_,\n ActionServices<DatabaseSchema_> | NodeContext.NodeContext\n>;\n\ntype Base<FunctionSpec_ extends FunctionSpec.AnyWithProps, R> = (\n args: FunctionSpec.Args<FunctionSpec_>,\n) => Effect.Effect<FunctionSpec.Returns<FunctionSpec_>, never, R>;\n\nexport type Any = AnyConfectProvenance | AnyConvexProvenance;\n\nexport type AnyConfectProvenance = Base<FunctionSpec.AnyConfect, any>;\n\nexport type AnyConvexProvenance = RegisteredFunction.Any;\n\nexport type WithName<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n FunctionName extends string,\n> = Handler<\n DatabaseSchema_,\n FunctionSpec.WithName<FunctionSpec_, FunctionName>\n>;\n"],"mappings":""}
|
package/dist/HttpApi.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import { Auth as Auth$1 } from "./Auth.js";
|
|
|
3
3
|
import { MutationRunner } from "./MutationRunner.js";
|
|
4
4
|
import { QueryRunner } from "./QueryRunner.js";
|
|
5
5
|
import { Scheduler as Scheduler$1 } from "./Scheduler.js";
|
|
6
|
-
import { StorageActionWriter as StorageActionWriter$1
|
|
6
|
+
import { StorageActionWriter as StorageActionWriter$1 } from "./StorageActionWriter.js";
|
|
7
|
+
import { StorageReader as StorageReader$1 } from "./StorageReader.js";
|
|
8
|
+
import { StorageWriter as StorageWriter$1 } from "./StorageWriter.js";
|
|
7
9
|
import { Layer } from "effect";
|
|
8
10
|
import { HttpRouter } from "convex/server";
|
|
9
11
|
import { HttpApi, HttpApiBuilder, HttpApiScalar, HttpApp, HttpRouter as HttpRouter$1 } from "@effect/platform";
|
package/dist/HttpApi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpApi.d.ts","names":[],"sources":["../src/HttpApi.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"HttpApi.d.ts","names":[],"sources":["../src/HttpApi.ts"],"mappings":";;;;;;;;;;;;;;;;KA6BK,UAAA,IACH,OAAA,EAAS,OAAA,CAAQ,OAAA,KACd,OAAA,CAAQ,OAAA,QAEX,OAAA,CAAQ,GAAA,GAAM,cAAA,CAAe,MAAA,GAAS,YAAA,CAAW,UAAA,CAAW,eAAA;AAAA,KAsGlD,QAAA;EACV,OAAA,EAAS,KAAA,CAAM,KAAA,CACb,OAAA,CAAQ,GAAA,SAEN,WAAA,GACA,cAAA,GACA,YAAA,GACA,WAAA,GACA,MAAA,GACA,eAAA,GACA,eAAA,GACA,qBAAA;EAEJ,UAAA,GAAa,UAAA;EACb,MAAA,GAAS,aAAA,CAAc,YAAA;AAAA;AAAA,KAGb,SAAA;AAAA,KA8CP,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,SAAA,EAAW,QAAA;AAAA,cAE7B,IAAA,GAAQ,QAAA,EAAU,QAAA,KAAW,UAAA"}
|
package/dist/HttpApi.js
CHANGED
|
@@ -6,7 +6,9 @@ import { make as make$1 } from "./ConvexConfigProvider.js";
|
|
|
6
6
|
import { layer as layer$2 } from "./MutationRunner.js";
|
|
7
7
|
import { layer as layer$3 } from "./QueryRunner.js";
|
|
8
8
|
import { layer as layer$4 } from "./Scheduler.js";
|
|
9
|
-
import { StorageActionWriter as StorageActionWriter$1
|
|
9
|
+
import { StorageActionWriter as StorageActionWriter$1 } from "./StorageActionWriter.js";
|
|
10
|
+
import { StorageReader as StorageReader$1 } from "./StorageReader.js";
|
|
11
|
+
import { StorageWriter as StorageWriter$1 } from "./StorageWriter.js";
|
|
10
12
|
import { Array, Layer, Record, pipe } from "effect";
|
|
11
13
|
import { ROUTABLE_HTTP_METHODS, httpActionGeneric, httpRouter } from "convex/server";
|
|
12
14
|
import { HttpApiBuilder, HttpApiScalar, HttpServer } from "@effect/platform";
|