@confect/server 3.0.0 → 5.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 +32 -0
- package/dist/ActionRunner.d.ts +5 -3
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/ActionRunner.js +2 -10
- 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 +20 -0
- package/dist/CronJobs.d.ts.map +1 -0
- package/dist/CronJobs.js +74 -0
- package/dist/CronJobs.js.map +1 -0
- package/dist/DatabaseReader.d.ts +5 -5
- package/dist/DatabaseWriter.d.ts +4 -4
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/Handler.d.ts +4 -2
- 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 +5 -3
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +2 -10
- 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 +5 -3
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +2 -10
- package/dist/QueryRunner.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +8 -7
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +2 -1
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +9 -7
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +3 -1
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/Scheduler.d.ts +9 -7
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +9 -4
- package/dist/Scheduler.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 +7 -2
- package/dist/index.js +7 -2
- package/package.json +4 -4
- package/src/ActionRunner.ts +5 -30
- package/src/BlobNotFoundError.ts +12 -0
- package/src/CronJob.ts +45 -0
- package/src/CronJobs.ts +147 -0
- package/src/Handler.ts +3 -5
- package/src/HttpApi.ts +3 -1
- package/src/MutationRunner.ts +5 -27
- package/src/OrderedQuery.ts +15 -6
- package/src/QueryRunner.ts +5 -30
- package/src/RegisteredConvexFunction.ts +2 -1
- package/src/RegisteredFunction.ts +3 -1
- package/src/Scheduler.ts +25 -13
- package/src/StorageActionWriter.ts +28 -0
- package/src/StorageReader.ts +27 -0
- package/src/StorageWriter.ts +26 -0
- package/src/index.ts +6 -1
- 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,37 @@
|
|
|
1
1
|
# @confect/server
|
|
2
2
|
|
|
3
|
+
## 5.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8853cbf: Update `Scheduler` to accept Confect `Ref`s instead of Convex `SchedulableFunctionReference` values. `runAfter` and `runAt` now take a `Ref` to a mutation or action with typed args, aligning the Scheduler API with all other Confect function-calling APIs.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- @confect/core@5.0.0
|
|
12
|
+
|
|
13
|
+
## 4.0.0
|
|
14
|
+
|
|
15
|
+
### Major Changes
|
|
16
|
+
|
|
17
|
+
- 60be7e6: Add Effect-native cron job support via new `CronJob` and `CronJobs` modules.
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
Interval schedules are represented in the largest whole unit possible (hours > minutes > seconds) to avoid floating-point precision issues with large durations.
|
|
22
|
+
|
|
23
|
+
- 8ae4d51: Standardize all Effect service tags to a consistent `@confect/{package}/{ServiceName}` format.
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- 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.
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- @confect/core@4.0.0
|
|
34
|
+
|
|
3
35
|
## 3.0.0
|
|
4
36
|
|
|
5
37
|
### Minor Changes
|
package/dist/ActionRunner.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Context,
|
|
1
|
+
import { Context, Layer } from "effect";
|
|
2
2
|
import * as Ref$1 from "@confect/core/Ref";
|
|
3
3
|
import { GenericActionCtx } from "convex/server";
|
|
4
|
+
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
5
|
+
import * as effect_Effect0 from "effect/Effect";
|
|
4
6
|
|
|
5
7
|
//#region src/ActionRunner.d.ts
|
|
6
8
|
declare namespace ActionRunner_d_exports {
|
|
7
9
|
export { ActionRunner, layer };
|
|
8
10
|
}
|
|
9
|
-
declare const ActionRunner: Context.Tag<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) =>
|
|
11
|
+
declare const ActionRunner: Context.Tag<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) => effect_Effect0.Effect<Ref$1.Ref_d_exports.Returns<Action>, effect_ParseResult0.ParseError, never>), <Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) => effect_Effect0.Effect<Ref$1.Ref_d_exports.Returns<Action>, effect_ParseResult0.ParseError, never>>;
|
|
10
12
|
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>) =>
|
|
13
|
+
declare const layer: (runAction: GenericActionCtx<any>["runAction"]) => Layer.Layer<(<Action extends Ref$1.AnyAction>(action: Action, args: Ref$1.Args<Action>) => effect_Effect0.Effect<Ref$1.Ref_d_exports.Returns<Action>, effect_ParseResult0.ParseError, never>), never, never>;
|
|
12
14
|
//#endregion
|
|
13
15
|
export { ActionRunner, ActionRunner_d_exports, layer };
|
|
14
16
|
//# 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":";;;;;;;;;;cAWa,YAAA,EAAY,OAAA,CAAA,GAAA,kBALP,KAAA,CAAI,SAAA,EAAS,MAAA,EAAU,MAAA,EAAM,IAAA,EAAQ,KAAA,CAAI,IAAA,CAAK,MAAA,MAAO,cAAA,CAAA,MAAA,CAAA,KAAA,CAAA,aAAA,CAAA,OAAA,CAAA,MAAA,GAAA,mBAAA,CAAA,UAAA,2BAArD,KAAA,CAAI,SAAA,EAAS,MAAA,EAAU,MAAA,EAAM,IAAA,EAAQ,KAAA,CAAI,IAAA,CAAK,MAAA,MAAO,cAAA,CAAA,MAAA,CAAA,KAAA,CAAA,aAAA,CAAA,OAAA,CAAA,MAAA,GAAA,mBAAA,CAAA,UAAA;AAAA,KAQ3D,YAAA,UAAsB,YAAA,CAAa,UAAA;AAAA,cAElC,KAAA,GAAS,SAAA,EAAW,gBAAA,uBAAkC,KAAA,CAAA,KAAA,kBAVjD,KAAA,CAAI,SAAA,EAAS,MAAA,EAAU,MAAA,EAAM,IAAA,EAAQ,KAAA,CAAI,IAAA,CAAK,MAAA,MAAO,cAAA,CAAA,MAAA,CAAA,KAAA,CAAA,aAAA,CAAA,OAAA,CAAA,MAAA,GAAA,mBAAA,CAAA,UAAA"}
|
package/dist/ActionRunner.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Context,
|
|
2
|
+
import { Context, Layer } from "effect";
|
|
3
3
|
import * as Ref$1 from "@confect/core/Ref";
|
|
4
4
|
import "convex/server";
|
|
5
5
|
|
|
@@ -8,15 +8,7 @@ var ActionRunner_exports = /* @__PURE__ */ __exportAll({
|
|
|
8
8
|
ActionRunner: () => ActionRunner,
|
|
9
9
|
layer: () => layer
|
|
10
10
|
});
|
|
11
|
-
const make = (runAction) => (action, args) =>
|
|
12
|
-
const functionSpec = Ref$1.getFunctionSpec(action);
|
|
13
|
-
const functionName = Ref$1.getConvexFunctionName(action);
|
|
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);
|
|
19
|
-
});
|
|
11
|
+
const make = (runAction) => (action, args) => Ref$1.runWithCodec(action, args, (functionReference, encodedArgs) => runAction(functionReference, encodedArgs));
|
|
20
12
|
const ActionRunner = Context.GenericTag("@confect/server/ActionRunner");
|
|
21
13
|
const layer = (runAction) => Layer.succeed(ActionRunner, make(runAction));
|
|
22
14
|
|
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
|
|
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 { Context, Layer } from \"effect\";\n\nconst make =\n (runAction: GenericActionCtx<any>[\"runAction\"]) =>\n <Action extends Ref.AnyAction>(action: Action, args: Ref.Args<Action>) =>\n Ref.runWithCodec(action, args, (functionReference, encodedArgs) =>\n runAction(functionReference, encodedArgs),\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":";;;;;;;;;;AAIA,MAAM,QACH,eAC8B,QAAgB,SAC7CA,MAAI,aAAa,QAAQ,OAAO,mBAAmB,gBACjD,UAAU,mBAAmB,YAAY,CAC1C;AAEL,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,20 @@
|
|
|
1
|
+
import { CronJob } from "./CronJob.js";
|
|
2
|
+
import { Crons } from "convex/server";
|
|
3
|
+
|
|
4
|
+
//#region src/CronJobs.d.ts
|
|
5
|
+
declare namespace CronJobs_d_exports {
|
|
6
|
+
export { CronJobs, TypeId, isCronJobs, make };
|
|
7
|
+
}
|
|
8
|
+
declare const TypeId = "@confect/server/CronJobs";
|
|
9
|
+
type TypeId = typeof TypeId;
|
|
10
|
+
interface CronJobs {
|
|
11
|
+
readonly [TypeId]: TypeId;
|
|
12
|
+
readonly cronJobs: Record<string, CronJob>;
|
|
13
|
+
readonly convexCronJobs: Crons;
|
|
14
|
+
add(cron: CronJob): CronJobs;
|
|
15
|
+
}
|
|
16
|
+
declare const isCronJobs: (u: unknown) => u is CronJobs;
|
|
17
|
+
declare const make: () => CronJobs;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { CronJobs, CronJobs_d_exports, TypeId, isCronJobs, make };
|
|
20
|
+
//# sourceMappingURL=CronJobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CronJobs.d.ts","names":[],"sources":["../src/CronJobs.ts"],"mappings":";;;;;;;cAea,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,UAEX,QAAA;EAAA,UACL,MAAA,GAAS,MAAA;EAAA,SACV,QAAA,EAAU,MAAA,SAAe,OAAA;EAAA,SACzB,cAAA,EAAgB,KAAA;EAEzB,GAAA,CAAI,IAAA,EAAM,OAAA,GAAkB,QAAA;AAAA;AAAA,cAGjB,UAAA,GAAc,CAAA,cAAa,CAAA,IAAK,QAAA;AAAA,cAkDhC,IAAA,QAAW,QAAA"}
|
package/dist/CronJobs.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Array, Cron, Duration, Match, Order, Predicate, Record, 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 functionReference = Ref$1.getFunctionReference(cronJob.ref);
|
|
21
|
+
const encodedArgs = Ref$1.encodeArgsSync(cronJob.ref, cronJob.args);
|
|
22
|
+
Match.value(cronJob.schedule).pipe(Match.when(Cron.isCron, (cron) => {
|
|
23
|
+
newConvexCrons.cron(cronJob.identifier, cronToConvexCronString(cron), functionReference, encodedArgs);
|
|
24
|
+
}), Match.when(Duration.isDuration, (duration) => {
|
|
25
|
+
newConvexCrons.interval(cronJob.identifier, durationToConvexIntervalSchedule(duration), functionReference, encodedArgs);
|
|
26
|
+
}), Match.exhaustive);
|
|
27
|
+
return makeProto(Record.set(this.cronJobs, cronJob.identifier, cronJob), newConvexCrons);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const makeProto = (cronJobs, convexCronJobs) => Object.assign(Object.create(Proto), {
|
|
31
|
+
cronJobs,
|
|
32
|
+
convexCronJobs
|
|
33
|
+
});
|
|
34
|
+
const make = () => makeProto({}, cronJobs());
|
|
35
|
+
/** @internal */
|
|
36
|
+
const cronToConvexCronString = (cron) => {
|
|
37
|
+
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.");
|
|
38
|
+
return Array.join([
|
|
39
|
+
setToField(cron.minutes),
|
|
40
|
+
setToField(cron.hours),
|
|
41
|
+
setToField(cron.days),
|
|
42
|
+
setToField(cron.months),
|
|
43
|
+
setToField(cron.weekdays)
|
|
44
|
+
], " ");
|
|
45
|
+
};
|
|
46
|
+
const setToField = (set) => {
|
|
47
|
+
if (set.size === 0) return "*";
|
|
48
|
+
return pipe(set, Array.sort(Order.number), Array.map((n) => n.toString()), Array.join(","));
|
|
49
|
+
};
|
|
50
|
+
/** @internal */
|
|
51
|
+
const durationToConvexIntervalSchedule = (duration) => {
|
|
52
|
+
const millis = Duration.toMillis(duration);
|
|
53
|
+
if (millis <= 0) throw new Error("Interval must be a positive duration.");
|
|
54
|
+
const hours = millis / Duration.hours(1).pipe(Duration.toMillis);
|
|
55
|
+
if (Number.isInteger(hours)) return {
|
|
56
|
+
type: "interval",
|
|
57
|
+
hours
|
|
58
|
+
};
|
|
59
|
+
const minutes = millis / Duration.minutes(1).pipe(Duration.toMillis);
|
|
60
|
+
if (Number.isInteger(minutes)) return {
|
|
61
|
+
type: "interval",
|
|
62
|
+
minutes
|
|
63
|
+
};
|
|
64
|
+
const seconds = millis / Duration.seconds(1).pipe(Duration.toMillis);
|
|
65
|
+
if (Number.isInteger(seconds)) return {
|
|
66
|
+
type: "interval",
|
|
67
|
+
seconds
|
|
68
|
+
};
|
|
69
|
+
throw new Error("Interval must be a whole number of seconds, minutes, or hours.");
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { CronJobs_exports, TypeId, cronToConvexCronString, durationToConvexIntervalSchedule, isCronJobs, make };
|
|
74
|
+
//# 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 { CronJob as ConvexCronJob } 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} 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 functionReference = Ref.getFunctionReference(cronJob.ref);\n const encodedArgs = Ref.encodeArgsSync(cronJob.ref, cronJob.args);\n\n Match.value(cronJob.schedule).pipe(\n Match.when(Cron.isCron, (cron) => {\n newConvexCrons.cron(\n cronJob.identifier,\n cronToConvexCronString(cron),\n functionReference,\n encodedArgs,\n );\n }),\n Match.when(Duration.isDuration, (duration) => {\n newConvexCrons.interval(\n cronJob.identifier,\n durationToConvexIntervalSchedule(duration),\n functionReference,\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":";;;;;;;;;;;;;AAeA,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,oBAAoBC,MAAI,qBAAqB,QAAQ,IAAI;EAC/D,MAAM,cAAcA,MAAI,eAAe,QAAQ,KAAK,QAAQ,KAAK;AAEjE,QAAM,MAAM,QAAQ,SAAS,CAAC,KAC5B,MAAM,KAAK,KAAK,SAAS,SAAS;AAChC,kBAAe,KACb,QAAQ,YACR,uBAAuB,KAAK,EAC5B,mBACA,YACD;IACD,EACF,MAAM,KAAK,SAAS,aAAa,aAAa;AAC5C,kBAAe,SACb,QAAQ,YACR,iCAAiC,SAAS,EAC1C,mBACA,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/DatabaseReader.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { Context, Layer } from "effect";
|
|
|
9
9
|
import * as convex_server0 from "convex/server";
|
|
10
10
|
import { GenericDatabaseReader } from "convex/server";
|
|
11
11
|
import * as convex_values0 from "convex/values";
|
|
12
|
-
import * as _confect_core_Types0 from "@confect/core/Types";
|
|
13
12
|
import * as effect_Effect0 from "effect/Effect";
|
|
13
|
+
import * as _confect_core_Types0 from "@confect/core/Types";
|
|
14
14
|
|
|
15
15
|
//#region src/DatabaseReader.d.ts
|
|
16
16
|
declare namespace DatabaseReader_d_exports {
|
|
@@ -19,7 +19,7 @@ declare namespace DatabaseReader_d_exports {
|
|
|
19
19
|
declare const make: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseReader: GenericDatabaseReader<ToConvex<FromSchema<DatabaseSchema_>>>) => {
|
|
20
20
|
table: <const TableName extends Name<IncludeSystemTables<Tables<DatabaseSchema_>>>>(tableName: TableName) => {
|
|
21
21
|
readonly get: {
|
|
22
|
-
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"],
|
|
22
|
+
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], GetByIdFailure | DocumentDecodeError, never>;
|
|
23
23
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<DatabaseSchema_>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"][IndexName]>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
24
24
|
};
|
|
25
25
|
readonly index: {
|
|
@@ -32,7 +32,7 @@ declare const make: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: Datab
|
|
|
32
32
|
declare const DatabaseReader: <DatabaseSchema_ extends AnyWithProps>() => Context.Tag<{
|
|
33
33
|
table: <const TableName extends Name<IncludeSystemTables<Tables<DatabaseSchema_>>>>(tableName: TableName) => {
|
|
34
34
|
readonly get: {
|
|
35
|
-
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"],
|
|
35
|
+
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], GetByIdFailure | DocumentDecodeError, never>;
|
|
36
36
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<DatabaseSchema_>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"][IndexName]>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
37
37
|
};
|
|
38
38
|
readonly index: {
|
|
@@ -44,7 +44,7 @@ declare const DatabaseReader: <DatabaseSchema_ extends AnyWithProps>() => Contex
|
|
|
44
44
|
}, {
|
|
45
45
|
table: <const TableName extends Name<IncludeSystemTables<Tables<DatabaseSchema_>>>>(tableName: TableName) => {
|
|
46
46
|
readonly get: {
|
|
47
|
-
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"],
|
|
47
|
+
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], GetByIdFailure | DocumentDecodeError, never>;
|
|
48
48
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<DatabaseSchema_>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"][IndexName]>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
49
49
|
};
|
|
50
50
|
readonly index: {
|
|
@@ -58,7 +58,7 @@ type DatabaseReader<DatabaseSchema_ extends AnyWithProps> = ReturnType<typeof Da
|
|
|
58
58
|
declare const layer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseReader: GenericDatabaseReader<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<{
|
|
59
59
|
table: <const TableName extends Name<IncludeSystemTables<Tables<DatabaseSchema_>>>>(tableName: TableName) => {
|
|
60
60
|
readonly get: {
|
|
61
|
-
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"],
|
|
61
|
+
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], GetByIdFailure | DocumentDecodeError, never>;
|
|
62
62
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<DatabaseSchema_>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"][IndexName]>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
63
63
|
};
|
|
64
64
|
readonly index: {
|
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, GetByIdFailure | DocumentDecodeError | DocumentEncodeError, 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, GetByIdFailure | DocumentDecodeError | DocumentEncodeError, 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, GetByIdFailure | DocumentDecodeError | DocumentEncodeError, 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, GetByIdFailure | DocumentDecodeError | DocumentEncodeError, 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
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseWriter.d.ts","names":[],"sources":["../src/DatabaseWriter.ts"],"mappings":";;;;;;;;;;;;cAiBa,IAAA,2BAAgC,YAAA,EAC3C,cAAA,EAAgB,eAAA,EAChB,oBAAA,EAAsB,qBAAA,CACpB,QAAA,CAAmB,UAAA,CAAqB,eAAA;kCAMH,UAAA,CAAoB,UAAA,CAAA,eAAA,IAAY,SAAA,EAC1D,SAAA;uBAQC,qBAAA,CACR,cAAA,CAAe,UAAA,CAAA,eAAA,GAAa,SAAA,OAC7B,MAAA,CAAA,MAAA,CAAA,SAAA,CAAA,SAAA,GAAA,mBAAA;gBAsBG,SAAA,CAAU,SAAA,GAAU,aAAA,EACT,OAAA,CACb,mBAAA,CAAoB,cAAA,CAAe,UAAA,CAAA,eAAA,GAAa,SAAA,QACjD,MAAA,CAAA,MAAA,OAAA,
|
|
1
|
+
{"version":3,"file":"DatabaseWriter.d.ts","names":[],"sources":["../src/DatabaseWriter.ts"],"mappings":";;;;;;;;;;;;cAiBa,IAAA,2BAAgC,YAAA,EAC3C,cAAA,EAAgB,eAAA,EAChB,oBAAA,EAAsB,qBAAA,CACpB,QAAA,CAAmB,UAAA,CAAqB,eAAA;kCAMH,UAAA,CAAoB,UAAA,CAAA,eAAA,IAAY,SAAA,EAC1D,SAAA;uBAQC,qBAAA,CACR,cAAA,CAAe,UAAA,CAAA,eAAA,GAAa,SAAA,OAC7B,MAAA,CAAA,MAAA,CAAA,SAAA,CAAA,SAAA,GAAA,mBAAA;gBAsBG,SAAA,CAAU,SAAA,GAAU,aAAA,EACT,OAAA,CACb,mBAAA,CAAoB,cAAA,CAAe,UAAA,CAAA,eAAA,GAAa,SAAA,QACjD,MAAA,CAAA,MAAA,OAAA,cAAA,GAAA,mBAAA,GAAA,mBAAA;kBAiCG,SAAA,CAAU,SAAA,GAAU,KAAA,EACjB,mBAAA,CAAoB,cAAA,CAAe,UAAA,CAAA,eAAA,GAAa,SAAA,OAAW,MAAA,CAAA,MAAA,OAAA,mBAAA;iBAsB/C,SAAA,CAAU,SAAA,MAAU,MAAA,CAAA,MAAA;EAAA;AAAA;AAAA,cAgBhC,cAAA,2BACa,YAAA,OAA2B,OAAA,CAAA,GAAA;kCA7GrB,UAAA,CAAA,UAAA,CAAA,eAAA,IAAA,SAAA,EAAA,SAAA;;;;;;;kCAAA,UAAA,CAAA,UAAA,CAAA,eAAA,IAAA,SAAA,EAAA,SAAA;;;;;;;KAmHpB,cAAA,yBACc,YAAA,IACtB,UAAA,QAAkB,cAAA,CAAe,eAAA;AAAA,cAExB,KAAA,2BAAiC,YAAA,EAC5C,cAAA,EAAgB,eAAA,EAChB,oBAAA,EAAsB,qBAAA,CACpB,QAAA,CAAmB,UAAA,CAAqB,eAAA,QACzC,KAAA,CAAA,KAAA;kCA3H6B,UAAA,CAAA,UAAA,CAAA,eAAA,IAAA,SAAA,EAAA,SAAA"}
|
package/dist/Handler.d.ts
CHANGED
|
@@ -10,12 +10,14 @@ 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";
|
|
15
17
|
import { Any as Any$1, ConvexRegisteredFunction } from "./RegisteredFunction.js";
|
|
16
18
|
import { Effect } from "effect";
|
|
17
|
-
import { NodeContext } from "@effect/platform-node";
|
|
18
19
|
import { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
20
|
+
import { NodeContext } from "@effect/platform-node";
|
|
19
21
|
import * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
20
22
|
|
|
21
23
|
//#region src/Handler.d.ts
|
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 * 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 {\
|
|
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";
|
package/dist/HttpApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpApi.js","names":["QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","Scheduler.layer","Auth.layer","StorageReader","StorageWriter","StorageActionWriter","ActionCtx.ActionCtx","ConvexConfigProvider.make"],"sources":["../src/HttpApi.ts"],"sourcesContent":["import {\n type HttpApi,\n HttpApiBuilder,\n HttpApiScalar,\n type HttpApp,\n type HttpRouter,\n HttpServer,\n} from \"@effect/platform\";\nimport {\n type HttpRouter as ConvexHttpRouter,\n type GenericActionCtx,\n type GenericDataModel,\n httpActionGeneric,\n httpRouter,\n ROUTABLE_HTTP_METHODS,\n type RouteSpecWithPathPrefix,\n} from \"convex/server\";\nimport { Array, Layer, pipe, Record } from \"effect\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport { StorageActionWriter
|
|
1
|
+
{"version":3,"file":"HttpApi.js","names":["QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","Scheduler.layer","Auth.layer","StorageReader","StorageWriter","StorageActionWriter","ActionCtx.ActionCtx","ConvexConfigProvider.make"],"sources":["../src/HttpApi.ts"],"sourcesContent":["import {\n type HttpApi,\n HttpApiBuilder,\n HttpApiScalar,\n type HttpApp,\n type HttpRouter,\n HttpServer,\n} from \"@effect/platform\";\nimport {\n type HttpRouter as ConvexHttpRouter,\n type GenericActionCtx,\n type GenericDataModel,\n httpActionGeneric,\n httpRouter,\n ROUTABLE_HTTP_METHODS,\n type RouteSpecWithPathPrefix,\n} from \"convex/server\";\nimport { Array, Layer, pipe, Record } from \"effect\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport { StorageActionWriter } from \"./StorageActionWriter\";\nimport { StorageReader } from \"./StorageReader\";\nimport { StorageWriter } from \"./StorageWriter\";\n\ntype Middleware = (\n httpApp: HttpApp.Default,\n) => HttpApp.Default<\n never,\n HttpApi.Api | HttpApiBuilder.Router | HttpRouter.HttpRouter.DefaultServices\n>;\n\nconst makeHandler =\n <DataModel extends GenericDataModel>({\n pathPrefix,\n apiLive,\n middleware,\n scalar,\n }: {\n pathPrefix: RoutePath;\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | GenericActionCtx<DataModel>\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n }) =>\n (ctx: GenericActionCtx<DataModel>, request: Request): Promise<Response> => {\n const ApiLive = apiLive.pipe(\n Layer.provide(\n Layer.mergeAll(\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n ActionRunner.layer(ctx.runAction),\n Scheduler.layer(ctx.scheduler),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n StorageActionWriter.layer(ctx.storage),\n Layer.succeed(ActionCtx.ActionCtx<DataModel>(), ctx),\n ),\n ),\n );\n\n const ApiDocsLive = HttpApiScalar.layer({\n path: `${pathPrefix}docs`,\n scalar: {\n baseServerURL: `${process.env[\"CONVEX_SITE_URL\"]}${pathPrefix}`,\n ...scalar,\n },\n }).pipe(Layer.provide(ApiLive));\n\n const EnvLive = Layer.mergeAll(\n ApiLive,\n ApiDocsLive,\n HttpServer.layerContext,\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n );\n\n const { handler } = HttpApiBuilder.toWebHandler(\n EnvLive,\n middleware ? { middleware } : {},\n );\n\n return handler(request);\n };\n\nconst makeHttpAction = <DataModel extends GenericDataModel>({\n pathPrefix,\n apiLive,\n middleware,\n scalar,\n}: {\n pathPrefix: RoutePath;\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | GenericActionCtx<DataModel>\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n}) =>\n httpActionGeneric(\n makeHandler<DataModel>({\n pathPrefix,\n apiLive,\n ...(middleware ? { middleware } : {}),\n ...(scalar ? { scalar } : {}),\n }) as unknown as (\n ctx: GenericActionCtx<GenericDataModel>,\n request: Request,\n ) => Promise<Response>,\n );\n\nexport type HttpApi_ = {\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n};\n\nexport type RoutePath = \"/\" | `/${string}/`;\n\nconst mountEffectHttpApi =\n <DataModel extends GenericDataModel>({\n pathPrefix,\n apiLive,\n middleware,\n scalar,\n }: {\n pathPrefix: RoutePath;\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | GenericActionCtx<DataModel>\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n }) =>\n (convexHttpRouter: ConvexHttpRouter): ConvexHttpRouter => {\n const handler = makeHttpAction<DataModel>({\n pathPrefix,\n apiLive,\n ...(middleware ? { middleware } : {}),\n ...(scalar ? { scalar } : {}),\n });\n\n Array.forEach(ROUTABLE_HTTP_METHODS, (method) => {\n const routeSpec: RouteSpecWithPathPrefix = {\n pathPrefix,\n method,\n handler,\n };\n convexHttpRouter.route(routeSpec);\n });\n\n return convexHttpRouter;\n };\n\ntype HttpApis = Partial<Record<RoutePath, HttpApi_>>;\n\nexport const make = (httpApis: HttpApis): ConvexHttpRouter => {\n applyMonkeyPatches();\n\n return pipe(\n httpApis as Record<RoutePath, HttpApi_>,\n Record.toEntries,\n Array.reduce(\n httpRouter(),\n (convexHttpRouter, [pathPrefix, { apiLive, middleware, scalar }]) =>\n mountEffectHttpApi({\n pathPrefix: pathPrefix as RoutePath,\n apiLive,\n ...(middleware ? { middleware } : {}),\n ...(scalar ? { scalar } : {}),\n })(convexHttpRouter),\n ),\n );\n};\n\nconst applyMonkeyPatches = () => {\n // These are necessary until the Convex runtime supports these APIs. See https://discord.com/channels/1019350475847499849/1281364098419785760\n\n // eslint-disable-next-line no-global-assign\n URL = class extends URL {\n override get username() {\n return \"\";\n }\n override get password() {\n return \"\";\n }\n };\n\n Object.defineProperty(Request.prototype, \"signal\", {\n get: () => new AbortSignal(),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAoCA,MAAM,eACiC,EACnC,YACA,SACA,YACA,cAmBD,KAAkC,YAAwC;CACzE,MAAM,UAAU,QAAQ,KACtB,MAAM,QACJ,MAAM,SACJA,QAAkB,IAAI,SAAS,EAC/BC,QAAqB,IAAI,YAAY,EACrCC,MAAmB,IAAI,UAAU,EACjCC,QAAgB,IAAI,UAAU,EAC9BC,QAAW,IAAI,KAAK,EACpBC,gBAAc,MAAM,IAAI,QAAQ,EAChCC,gBAAc,MAAM,IAAI,QAAQ,EAChCC,sBAAoB,MAAM,IAAI,QAAQ,EACtC,MAAM,QAAQC,WAAgC,EAAE,IAAI,CACrD,CACF,CACF;CAED,MAAM,cAAc,cAAc,MAAM;EACtC,MAAM,GAAG,WAAW;EACpB,QAAQ;GACN,eAAe,GAAG,QAAQ,IAAI,qBAAqB;GACnD,GAAG;GACJ;EACF,CAAC,CAAC,KAAK,MAAM,QAAQ,QAAQ,CAAC;CAE/B,MAAM,UAAU,MAAM,SACpB,SACA,aACA,WAAW,cACX,MAAM,kBAAkBC,QAA2B,CAAC,CACrD;CAED,MAAM,EAAE,YAAY,eAAe,aACjC,SACA,aAAa,EAAE,YAAY,GAAG,EAAE,CACjC;AAED,QAAO,QAAQ,QAAQ;;AAG3B,MAAM,kBAAsD,EAC1D,YACA,SACA,YACA,aAmBA,kBACE,YAAuB;CACrB;CACA;CACA,GAAI,aAAa,EAAE,YAAY,GAAG,EAAE;CACpC,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;CAC7B,CAAC,CAIH;AAqBH,MAAM,sBACiC,EACnC,YACA,SACA,YACA,cAmBD,qBAAyD;CACxD,MAAM,UAAU,eAA0B;EACxC;EACA;EACA,GAAI,aAAa,EAAE,YAAY,GAAG,EAAE;EACpC,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;EAC7B,CAAC;AAEF,OAAM,QAAQ,wBAAwB,WAAW;EAC/C,MAAM,YAAqC;GACzC;GACA;GACA;GACD;AACD,mBAAiB,MAAM,UAAU;GACjC;AAEF,QAAO;;AAKX,MAAa,QAAQ,aAAyC;AAC5D,qBAAoB;AAEpB,QAAO,KACL,UACA,OAAO,WACP,MAAM,OACJ,YAAY,GACX,kBAAkB,CAAC,YAAY,EAAE,SAAS,YAAY,cACrD,mBAAmB;EACL;EACZ;EACA,GAAI,aAAa,EAAE,YAAY,GAAG,EAAE;EACpC,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;EAC7B,CAAC,CAAC,iBAAiB,CACvB,CACF;;AAGH,MAAM,2BAA2B;AAI/B,OAAM,cAAc,IAAI;EACtB,IAAa,WAAW;AACtB,UAAO;;EAET,IAAa,WAAW;AACtB,UAAO;;;AAIX,QAAO,eAAe,QAAQ,WAAW,UAAU,EACjD,WAAW,IAAI,aAAa,EAC7B,CAAC"}
|
package/dist/MutationRunner.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { Context,
|
|
1
|
+
import { Context, Layer, Schema } from "effect";
|
|
2
2
|
import * as Ref$1 from "@confect/core/Ref";
|
|
3
3
|
import { GenericMutationCtx } from "convex/server";
|
|
4
|
+
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
5
|
+
import * as effect_Effect0 from "effect/Effect";
|
|
4
6
|
|
|
5
7
|
//#region src/MutationRunner.d.ts
|
|
6
8
|
declare namespace MutationRunner_d_exports {
|
|
7
9
|
export { MutationRollback, MutationRunner, layer };
|
|
8
10
|
}
|
|
9
|
-
declare const MutationRunner: Context.Tag<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) =>
|
|
11
|
+
declare const MutationRunner: Context.Tag<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) => effect_Effect0.Effect<Ref$1.Ref_d_exports.Returns<Mutation>, effect_ParseResult0.ParseError, never>), <Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) => effect_Effect0.Effect<Ref$1.Ref_d_exports.Returns<Mutation>, effect_ParseResult0.ParseError, never>>;
|
|
10
12
|
type MutationRunner = typeof MutationRunner.Identifier;
|
|
11
|
-
declare const layer: (runMutation: GenericMutationCtx<any>["runMutation"]) => Layer.Layer<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) =>
|
|
13
|
+
declare const layer: (runMutation: GenericMutationCtx<any>["runMutation"]) => Layer.Layer<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>) => effect_Effect0.Effect<Ref$1.Ref_d_exports.Returns<Mutation>, effect_ParseResult0.ParseError, never>), never, never>;
|
|
12
14
|
declare const MutationRollback_base: Schema.TaggedErrorClass<MutationRollback, "MutationRollback", {
|
|
13
15
|
readonly _tag: Schema.tag<"MutationRollback">;
|
|
14
16
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationRunner.d.ts","names":[],"sources":["../src/MutationRunner.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MutationRunner.d.ts","names":[],"sources":["../src/MutationRunner.ts"],"mappings":";;;;;;;;;;cAca,cAAA,EAAc,OAAA,CAAA,GAAA,oBARP,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,MAAS,cAAA,CAAA,MAAA,CAAA,KAAA,CAAA,aAAA,CAAA,OAAA,CAAA,QAAA,GAAA,mBAAA,CAAA,UAAA,6BAFR,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,MAAS,cAAA,CAAA,MAAA,CAAA,KAAA,CAAA,aAAA,CAAA,OAAA,CAAA,QAAA,GAAA,mBAAA,CAAA,UAAA;AAAA,KAShB,cAAA,UAAwB,cAAA,CAAe,UAAA;AAAA,cAEtC,KAAA,GAAS,WAAA,EAAa,kBAAA,yBAAsC,KAAA,CAAA,KAAA,oBAbrD,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,MAAS,cAAA,CAAA,MAAA,CAAA,KAAA,CAAA,aAAA,CAAA,OAAA,CAAA,QAAA,GAAA,mBAAA,CAAA,UAAA;AAAA,cAYuB,qBAAA;;;;;;cAEtC,gBAAA,SAAyB,qBAAA;EAAA,IAQvB,OAAA,CAAA;AAAA"}
|