@confect/server 9.0.0-next.1 → 9.0.0-next.10
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 +293 -4
- package/dist/ActionCtx.d.ts +4 -11
- package/dist/ActionCtx.d.ts.map +1 -1
- package/dist/ActionCtx.js +1 -1
- package/dist/ActionCtx.js.map +1 -1
- package/dist/ActionRunner.d.ts +8 -13
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/ActionRunner.js +4 -3
- package/dist/ActionRunner.js.map +1 -1
- package/dist/Auth.d.ts +17 -23
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +5 -1
- package/dist/Auth.js.map +1 -1
- package/dist/BlobNotFoundError.d.ts +6 -12
- package/dist/BlobNotFoundError.d.ts.map +1 -1
- package/dist/BlobNotFoundError.js +1 -1
- package/dist/BlobNotFoundError.js.map +1 -1
- package/dist/ConvexConfigProvider.d.ts +2 -9
- package/dist/ConvexConfigProvider.d.ts.map +1 -1
- package/dist/ConvexConfigProvider.js +6 -1
- package/dist/ConvexConfigProvider.js.map +1 -1
- package/dist/CronJob.d.ts +12 -19
- package/dist/CronJob.d.ts.map +1 -1
- package/dist/CronJob.js +1 -1
- package/dist/CronJob.js.map +1 -1
- package/dist/CronJobs.d.ts +11 -18
- package/dist/CronJobs.d.ts.map +1 -1
- package/dist/CronJobs.js +11 -4
- package/dist/CronJobs.js.map +1 -1
- package/dist/DataModel.d.ts +24 -29
- package/dist/DataModel.d.ts.map +1 -1
- package/dist/DatabaseReader.d.ts +4323 -64
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseReader.js +6 -6
- package/dist/DatabaseReader.js.map +1 -1
- package/dist/DatabaseSchema.d.ts +38 -130
- package/dist/DatabaseSchema.d.ts.map +1 -1
- package/dist/DatabaseSchema.js +20 -30
- package/dist/DatabaseSchema.js.map +1 -1
- package/dist/DatabaseWriter.d.ts +38 -42
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +8 -5
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/Document.d.ts +28 -37
- package/dist/Document.d.ts.map +1 -1
- package/dist/Document.js +5 -1
- package/dist/Document.js.map +1 -1
- package/dist/FunctionImpl.d.ts +30 -29
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/FunctionImpl.js +25 -14
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/GroupImpl.d.ts +45 -41
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/GroupImpl.js +42 -35
- package/dist/GroupImpl.js.map +1 -1
- package/dist/Handler.d.ts +34 -40
- package/dist/Handler.d.ts.map +1 -1
- package/dist/HttpApi.d.ts +21 -25
- package/dist/HttpApi.d.ts.map +1 -1
- package/dist/HttpApi.js +11 -6
- package/dist/HttpApi.js.map +1 -1
- package/dist/MutationCtx.d.ts +4 -11
- package/dist/MutationCtx.d.ts.map +1 -1
- package/dist/MutationCtx.js +1 -1
- package/dist/MutationCtx.js.map +1 -1
- package/dist/MutationRunner.d.ts +8 -13
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +4 -3
- package/dist/MutationRunner.js.map +1 -1
- package/dist/OrderedQuery.d.ts +16 -21
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/OrderedQuery.js +4 -1
- package/dist/OrderedQuery.js.map +1 -1
- package/dist/QueryCtx.d.ts +4 -11
- package/dist/QueryCtx.d.ts.map +1 -1
- package/dist/QueryCtx.js +1 -1
- package/dist/QueryCtx.js.map +1 -1
- package/dist/QueryInitializer.d.ts +34 -39
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryInitializer.js +5 -1
- package/dist/QueryInitializer.js.map +1 -1
- package/dist/QueryRunner.d.ts +8 -13
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +4 -3
- package/dist/QueryRunner.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +1107 -60
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +14 -9
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +48 -64
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +9 -5
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +48 -26
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js +22 -9
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +4 -14
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +5 -4
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/RegistryItem.d.ts +17 -27
- package/dist/RegistryItem.d.ts.map +1 -1
- package/dist/RegistryItem.js +1 -1
- package/dist/RegistryItem.js.map +1 -1
- package/dist/Scheduler.d.ts +16 -20
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +10 -6
- package/dist/Scheduler.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +71 -64
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +15 -3
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/StorageActionWriter.d.ts +21 -28
- package/dist/StorageActionWriter.d.ts.map +1 -1
- package/dist/StorageActionWriter.js +4 -1
- package/dist/StorageActionWriter.js.map +1 -1
- package/dist/StorageReader.d.ts +14 -21
- package/dist/StorageReader.d.ts.map +1 -1
- package/dist/StorageReader.js +5 -1
- package/dist/StorageReader.js.map +1 -1
- package/dist/StorageWriter.d.ts +16 -23
- package/dist/StorageWriter.d.ts.map +1 -1
- package/dist/StorageWriter.js +4 -1
- package/dist/StorageWriter.js.map +1 -1
- package/dist/Table.d.ts +204 -197
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +72 -62
- package/dist/Table.js.map +1 -1
- package/dist/TableInfo.d.ts +35 -41
- package/dist/TableInfo.d.ts.map +1 -1
- package/dist/VectorSearch.d.ts +30 -35
- package/dist/VectorSearch.d.ts.map +1 -1
- package/dist/VectorSearch.js +3 -1
- package/dist/VectorSearch.js.map +1 -1
- package/dist/index.d.ts +35 -36
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -5
- package/dist/internal/utils.d.ts +9 -11
- package/dist/internal/utils.d.ts.map +1 -1
- package/dist/internal/utils.js +3 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.d.ts.map +1 -0
- package/dist/tsconfig.src.tsbuildinfo +1 -0
- package/package.json +50 -59
- package/src/ActionCtx.ts +1 -1
- package/src/ActionRunner.ts +2 -1
- package/src/Auth.ts +5 -1
- package/src/BlobNotFoundError.ts +1 -1
- package/src/ConvexConfigProvider.ts +6 -8
- package/src/CronJob.ts +1 -1
- package/src/CronJobs.ts +8 -10
- package/src/DatabaseReader.ts +18 -21
- package/src/DatabaseSchema.ts +38 -98
- package/src/DatabaseWriter.ts +13 -6
- package/src/Document.ts +5 -1
- package/src/FunctionImpl.ts +36 -44
- package/src/GroupImpl.ts +54 -81
- package/src/HttpApi.ts +8 -9
- package/src/MutationCtx.ts +1 -1
- package/src/MutationRunner.ts +2 -1
- package/src/OrderedQuery.ts +5 -1
- package/src/QueryCtx.ts +1 -1
- package/src/QueryInitializer.ts +15 -3
- package/src/QueryRunner.ts +2 -1
- package/src/RegisteredConvexFunction.ts +11 -7
- package/src/RegisteredFunction.ts +5 -1
- package/src/RegisteredFunctions.ts +69 -93
- package/src/RegisteredNodeFunction.ts +7 -6
- package/src/RegistryItem.ts +1 -1
- package/src/Scheduler.ts +5 -1
- package/src/SchemaToValidator.ts +14 -16
- package/src/StorageActionWriter.ts +4 -1
- package/src/StorageReader.ts +5 -1
- package/src/StorageWriter.ts +4 -1
- package/src/Table.ts +253 -132
- package/src/VectorSearch.ts +3 -1
- package/src/index.ts +0 -1
- package/src/internal/utils.ts +3 -1
- package/dist/Api.d.ts +0 -30
- package/dist/Api.d.ts.map +0 -1
- package/dist/Api.js +0 -26
- package/dist/Api.js.map +0 -1
- package/dist/GroupPath.d.ts +0 -8
- package/dist/GroupPath.d.ts.map +0 -1
- package/dist/GroupPath.js +0 -10
- package/dist/GroupPath.js.map +0 -1
- package/src/Api.ts +0 -75
- package/src/GroupPath.ts +0 -43
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunctions.js","names":["RegistryItem.isRegistryItem"],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport
|
|
1
|
+
{"version":3,"file":"RegisteredFunctions.js","names":["RegistryItem.isRegistryItem"],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport type { Layer, Types } from \"effect\";\nimport * as Effect from \"effect/Effect\";\nimport * as Ref from \"effect/Ref\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as GroupImpl from \"./GroupImpl\";\nimport { mapLeaves } from \"./internal/utils\";\nimport type * as RegisteredFunction from \"./RegisteredFunction\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> =\n Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;\n\ntype RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? RegisteredFunctionsForGroupSpec<Group>\n : never;\n};\n\n/** The `RegisteredFunction` record for a group's own declared functions. */\ntype RegisteredFunctionsOf<Group extends GroupSpec.AnyWithProps> = {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? RegisteredFunction.RegisteredFunction<FunctionSpec_>\n : never;\n};\n\n/**\n * The registered-functions record for a single group, derived from the group's\n * own `GroupSpec`: its declared functions, plus any nested subgroups it carries\n * directly. This is the node that `buildForGroup` returns — computed from the\n * leaf `GroupSpec` itself rather than by navigating the project-wide assembled\n * `Spec` to a dot-path, so the per-group registry's type depends only on its\n * own leaf. For the filesystem layout a leaf `GroupSpec` carries no subgroups\n * (subdirectory children are assembled separately into `_generated/spec.ts`),\n * so this resolves to just the leaf's functions.\n */\nexport type RegisteredFunctionsForGroupSpec<\n Group extends GroupSpec.AnyWithProps,\n> =\n GroupSpec.Groups<Group> extends infer SubGroups extends GroupSpec.AnyWithProps\n ? Types.Simplify<\n RegisteredFunctionsHelper<SubGroups> & RegisteredFunctionsOf<Group>\n >\n : RegisteredFunctionsOf<Group>;\n\nexport interface AnyWithProps {\n readonly [key: string]: RegisteredFunction.Any | AnyWithProps;\n}\n\n/**\n * Build the registered Convex functions for a single group from its finalized\n * `GroupImpl` layer.\n *\n * The `groupLayer` parameter requires `GroupImpl<\"Finalized\">`, so impls that\n * were never piped through `GroupImpl.finalize` (and impls with unmet\n * `FunctionImpl` requirements, which cannot be finalized) are rejected at the\n * codegen boundary, not just deep inside Convex at runtime.\n *\n * The group layer is built with a fresh, isolated `Registry` (rather than the\n * globally-cached default `Context.Reference`), so each `FunctionImpl.make`\n * registers under its flat, single-segment function-name key without colliding\n * with any other group built in the same process — the built registry holds\n * exactly this group's functions at the top level.\n *\n * Only the runtime `databaseSchema` value is needed at runtime (it is forwarded\n * to `makeRegisteredFunction` to build each function's ctx services); the\n * group's `GroupSpec` is supplied purely as the `Group` type parameter to shape\n * the returned record. The generated caller passes it explicitly and imports\n * the leaf spec type-only (`typeof import(\"…/<group>.spec\")[\"default\"]`), so a\n * function's bundle never imports a spec module at runtime.\n */\nexport const buildForGroup = <Group extends GroupSpec.AnyWithProps>(\n databaseSchema: DatabaseSchema.AnyWithProps,\n groupLayer: Layer.Layer<GroupImpl.GroupImpl<\"Finalized\">>,\n makeRegisteredFunction: (\n databaseSchema: DatabaseSchema.AnyWithProps,\n registryItem: RegistryItem.AnyWithProps,\n ) => RegisteredFunction.Any,\n): RegisteredFunctionsForGroupSpec<Group> => {\n const registryItems = Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n return yield* Ref.get(registry);\n }).pipe(\n Effect.provide(groupLayer),\n Effect.provideService(\n Registry.Registry,\n Ref.unsafeMake<Registry.RegistryItems>({}),\n ),\n Effect.runSync,\n );\n\n return mapLeaves<RegistryItem.AnyWithProps, RegisteredFunction.Any>(\n registryItems as { [key: string]: RegistryItem.AnyWithProps },\n RegistryItem.isRegistryItem,\n (registryItem) => makeRegisteredFunction(databaseSchema, registryItem),\n ) as RegisteredFunctionsForGroupSpec<Group>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFA,MAAa,iBACX,gBACA,YACA,2BAI2C;AAa3C,QAAO,UAZe,OAAO,IAAI,aAAa;EAC5C,MAAM,WAAW,OAAO,SAAS;AACjC,SAAO,OAAO,IAAI,IAAI,SAAS;GAC/B,CAAC,KACD,OAAO,QAAQ,WAAW,EAC1B,OAAO,eACL,SAAS,UACT,IAAI,WAAmC,EAAE,CAAC,CAC3C,EACD,OAAO,QACR,EAICA,iBACC,iBAAiB,uBAAuB,gBAAgB,aAAa,CACvE"}
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
//#region src/RegisteredNodeFunction.d.ts
|
|
6
|
-
declare namespace RegisteredNodeFunction_d_exports {
|
|
7
|
-
export { make };
|
|
8
|
-
}
|
|
9
|
-
declare const make: <Api_ extends AnyWithPropsWithRuntime<"Node">>(api: Api_, {
|
|
10
|
-
functionSpec,
|
|
11
|
-
handler
|
|
12
|
-
}: AnyWithProps) => Any;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { RegisteredNodeFunction_d_exports, make };
|
|
1
|
+
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
2
|
+
import * as RegisteredFunction from "./RegisteredFunction";
|
|
3
|
+
import type * as RegistryItem from "./RegistryItem";
|
|
4
|
+
export declare const make: (databaseSchema: DatabaseSchema.AnyWithProps, { functionSpec, handler }: RegistryItem.AnyWithProps) => RegisteredFunction.Any;
|
|
15
5
|
//# sourceMappingURL=RegisteredNodeFunction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredNodeFunction.d.ts","
|
|
1
|
+
{"version":3,"file":"RegisteredNodeFunction.d.ts","sourceRoot":"","sources":["../src/RegisteredNodeFunction.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,IAAI,GACf,gBAAgB,cAAc,CAAC,YAAY,EAC3C,2BAA2B,YAAY,CAAC,YAAY,KACnD,kBAAkB,CAAC,GAuBnB,CAAC"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { actionFunctionBase, actionLayer } from "./RegisteredFunction.js";
|
|
3
|
-
import { Layer, Match } from "effect";
|
|
4
3
|
import { actionGeneric, internalActionGeneric } from "convex/server";
|
|
5
|
-
import
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import * as Match from "effect/Match";
|
|
6
|
+
import * as NodeContext from "@effect/platform-node/NodeContext";
|
|
6
7
|
|
|
7
8
|
//#region src/RegisteredNodeFunction.ts
|
|
8
9
|
var RegisteredNodeFunction_exports = /* @__PURE__ */ __exportAll({ make: () => make });
|
|
9
|
-
const make = (
|
|
10
|
+
const make = (databaseSchema, { functionSpec, handler }) => Match.value(functionSpec.functionProvenance).pipe(Match.tag("Convex", () => handler), Match.tag("Confect", () => {
|
|
10
11
|
const { functionVisibility, functionProvenance } = functionSpec;
|
|
11
|
-
return Match.value(functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(nodeActionFunction(
|
|
12
|
+
return Match.value(functionVisibility).pipe(Match.when("public", () => actionGeneric), Match.when("internal", () => internalActionGeneric), Match.exhaustive)(nodeActionFunction(databaseSchema, {
|
|
12
13
|
args: functionProvenance.args,
|
|
13
14
|
returns: functionProvenance.returns,
|
|
14
15
|
error: functionProvenance.error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredNodeFunction.js","names":["RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredNodeFunction.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport
|
|
1
|
+
{"version":3,"file":"RegisteredNodeFunction.js","names":["RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredNodeFunction.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport * as NodeContext from \"@effect/platform-node/NodeContext\";\nimport {\n actionGeneric,\n type DefaultFunctionArgs,\n internalActionGeneric,\n} from \"convex/server\";\nimport type { Effect } from \"effect\";\nimport type { Schema } from \"effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Match from \"effect/Match\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as Handler from \"./Handler\";\nimport * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as RegistryItem from \"./RegistryItem\";\n\nexport const make = (\n databaseSchema: DatabaseSchema.AnyWithProps,\n { functionSpec, handler }: RegistryItem.AnyWithProps,\n): RegisteredFunction.Any =>\n Match.value(functionSpec.functionProvenance).pipe(\n Match.tag(\"Convex\", () => handler as RegisteredFunction.Any),\n Match.tag(\"Confect\", () => {\n const { functionVisibility, functionProvenance } =\n functionSpec as FunctionSpec.AnyConfect;\n\n const genericFunction = Match.value(functionVisibility).pipe(\n Match.when(\"public\", () => actionGeneric),\n Match.when(\"internal\", () => internalActionGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n nodeActionFunction(databaseSchema, {\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.exhaustive,\n );\n\nconst nodeActionFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n databaseSchema: DatabaseSchema_,\n {\n args,\n returns,\n error,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema.AnyNoContext | undefined;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n | RegisteredFunction.ActionServices<DatabaseSchema_>\n | NodeContext.NodeContext\n >;\n },\n) =>\n RegisteredFunction.actionFunctionBase({\n args,\n returns,\n error,\n handler,\n createLayer: (ctx) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(databaseSchema, ctx),\n NodeContext.layer,\n ),\n });\n"],"mappings":";;;;;;;;;AAgBA,MAAa,QACX,gBACA,EAAE,cAAc,cAEhB,MAAM,MAAM,aAAa,mBAAmB,CAAC,KAC3C,MAAM,IAAI,gBAAgB,QAAkC,EAC5D,MAAM,IAAI,iBAAiB;CACzB,MAAM,EAAE,oBAAoB,uBAC1B;AAQF,QANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gBAAgB,cAAc,EACzC,MAAM,KAAK,kBAAkB,sBAAsB,EACnD,MAAM,WACP,CAGC,mBAAmB,gBAAgB;EACjC,MAAM,mBAAmB;EACzB,SAAS,mBAAmB;EAC5B,OAAO,mBAAmB;EACjB;EACV,CAAC,CACH;EACD,EACF,MAAM,WACP;AAEH,MAAM,sBAQJ,gBACA,EACE,MACA,SACA,OACA,cAeFA,mBAAsC;CACpC;CACA;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,gBAAgB,IAAI,EACnD,YAAY,MACb;CACJ,CAAC"}
|
package/dist/RegistryItem.d.ts
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare
|
|
7
|
-
|
|
1
|
+
import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
2
|
+
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
3
|
+
import type * as Handler from "./Handler";
|
|
4
|
+
export declare const TypeId = "@confect/server/RegistryItem";
|
|
5
|
+
export type TypeId = typeof TypeId;
|
|
6
|
+
export declare const isRegistryItem: (value: unknown) => value is AnyWithProps;
|
|
7
|
+
export interface RegistryItem<DatabaseSchema_ extends DatabaseSchema.AnyWithProps, FunctionSpec_ extends FunctionSpec.AnyWithProps> {
|
|
8
|
+
readonly [TypeId]: TypeId;
|
|
9
|
+
readonly functionSpec: FunctionSpec_;
|
|
10
|
+
readonly handler: Handler.Handler<DatabaseSchema_, FunctionSpec_>;
|
|
8
11
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
readonly [TypeId]: TypeId;
|
|
14
|
-
readonly functionSpec: FunctionSpec_;
|
|
15
|
-
readonly handler: Handler<DatabaseSchema_, FunctionSpec_>;
|
|
12
|
+
export interface AnyWithProps {
|
|
13
|
+
readonly [TypeId]: TypeId;
|
|
14
|
+
readonly functionSpec: FunctionSpec.AnyWithProps;
|
|
15
|
+
readonly handler: Handler.Any;
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
readonly handler: Any;
|
|
21
|
-
}
|
|
22
|
-
declare const make: ({
|
|
23
|
-
functionSpec,
|
|
24
|
-
handler
|
|
25
|
-
}: {
|
|
26
|
-
functionSpec: FunctionSpec.AnyWithProps;
|
|
27
|
-
handler: AnyWithProps["handler"];
|
|
17
|
+
export declare const make: ({ functionSpec, handler, }: {
|
|
18
|
+
functionSpec: FunctionSpec.AnyWithProps;
|
|
19
|
+
handler: AnyWithProps["handler"];
|
|
28
20
|
}) => AnyWithProps;
|
|
29
|
-
//#endregion
|
|
30
|
-
export { AnyWithProps, RegistryItem, RegistryItem_d_exports, TypeId, isRegistryItem, make };
|
|
31
21
|
//# sourceMappingURL=RegistryItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegistryItem.d.ts","
|
|
1
|
+
{"version":3,"file":"RegistryItem.d.ts","sourceRoot":"","sources":["../src/RegistryItem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,KAAK,OAAO,MAAM,WAAW,CAAC;AAE1C,eAAO,MAAM,MAAM,iCAAiC,CAAC;AACrD,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC;AAEnC,eAAO,MAAM,cAAc,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,YACnB,CAAC;AAMvC,MAAM,WAAW,YAAY,CAC3B,eAAe,SAAS,cAAc,CAAC,YAAY,EACnD,aAAa,SAAS,YAAY,CAAC,YAAY;IAE/C,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,aAAa,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;CACnE;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC;IACjD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;CAC/B;AAED,eAAO,MAAM,IAAI,GAAI,4BAGlB;IACD,YAAY,EAAE,YAAY,CAAC,YAAY,CAAC;IACxC,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;CAClC,KAAG,YAIA,CAAC"}
|
package/dist/RegistryItem.js
CHANGED
package/dist/RegistryItem.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegistryItem.js","names":[],"sources":["../src/RegistryItem.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport
|
|
1
|
+
{"version":3,"file":"RegistryItem.js","names":[],"sources":["../src/RegistryItem.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as Handler from \"./Handler\";\n\nexport const TypeId = \"@confect/server/RegistryItem\";\nexport type TypeId = typeof TypeId;\n\nexport const isRegistryItem = (value: unknown): value is AnyWithProps =>\n Predicate.hasProperty(value, TypeId);\n\nconst RegistryItemProto = {\n [TypeId]: TypeId,\n};\n\nexport interface RegistryItem<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> {\n readonly [TypeId]: TypeId;\n readonly functionSpec: FunctionSpec_;\n readonly handler: Handler.Handler<DatabaseSchema_, FunctionSpec_>;\n}\n\nexport interface AnyWithProps {\n readonly [TypeId]: TypeId;\n readonly functionSpec: FunctionSpec.AnyWithProps;\n readonly handler: Handler.Any;\n}\n\nexport const make = ({\n functionSpec,\n handler,\n}: {\n functionSpec: FunctionSpec.AnyWithProps;\n handler: AnyWithProps[\"handler\"];\n}): AnyWithProps =>\n Object.assign(Object.create(RegistryItemProto), {\n functionSpec,\n handler,\n });\n"],"mappings":";;;;;;;;;AAKA,MAAa,SAAS;AAGtB,MAAa,kBAAkB,UAC7B,UAAU,YAAY,OAAO,OAAO;AAEtC,MAAM,oBAAoB,GACvB,SAAS,QACX;AAiBD,MAAa,QAAQ,EACnB,cACA,cAKA,OAAO,OAAO,OAAO,OAAO,kBAAkB,EAAE;CAC9C;CACA;CACD,CAAC"}
|
package/dist/Scheduler.d.ts
CHANGED
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Scheduler as
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
runAfter: <Ref_ extends Ref$1.AnyMutation | Ref$1.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref$1.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
12
|
-
runAt: <Ref_ extends Ref$1.AnyMutation | Ref$1.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref$1.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
1
|
+
import { Ref } from "@confect/core";
|
|
2
|
+
import type { Scheduler as ConvexScheduler } from "convex/server";
|
|
3
|
+
import * as Context from "effect/Context";
|
|
4
|
+
import * as DateTime from "effect/DateTime";
|
|
5
|
+
import * as Duration from "effect/Duration";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
|
+
export declare const Scheduler: Context.Tag<{
|
|
9
|
+
runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
|
|
10
|
+
runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
|
|
13
11
|
}, {
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
|
|
13
|
+
runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
|
|
16
14
|
}>;
|
|
17
|
-
type Scheduler = typeof Scheduler.Identifier;
|
|
18
|
-
declare const layer: (scheduler:
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export type Scheduler = typeof Scheduler.Identifier;
|
|
16
|
+
export declare const layer: (scheduler: ConvexScheduler) => Layer.Layer<{
|
|
17
|
+
runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(delay: Duration.Duration, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
|
|
18
|
+
runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(dateTime: DateTime.DateTime, ref: Ref_, ...args: Ref.OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
|
|
21
19
|
}, never, never>;
|
|
22
|
-
//#endregion
|
|
23
|
-
export { Scheduler, Scheduler_d_exports, layer };
|
|
24
20
|
//# sourceMappingURL=Scheduler.d.ts.map
|
package/dist/Scheduler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file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Q,OACnB,IAAI,WACA,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;YAazB,IAAI,SAAS,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,SAAS,YACxC,QAAQ,CAAC,QAAQ,OACtB,IAAI,WACA,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC;gBAqBQ,CAAC"}
|
package/dist/Scheduler.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as Layer from "effect/Layer";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { Ref } from "@confect/core";
|
|
6
|
+
import * as Duration from "effect/Duration";
|
|
7
|
+
import * as DateTime from "effect/DateTime";
|
|
4
8
|
|
|
5
9
|
//#region src/Scheduler.ts
|
|
6
10
|
var Scheduler_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -10,14 +14,14 @@ var Scheduler_exports = /* @__PURE__ */ __exportAll({
|
|
|
10
14
|
const make = (scheduler) => ({
|
|
11
15
|
runAfter: (delay, ref, ...args) => {
|
|
12
16
|
const delayMs = Duration.toMillis(delay);
|
|
13
|
-
const functionReference = Ref
|
|
14
|
-
const encodedArgs = Ref
|
|
17
|
+
const functionReference = Ref.getFunctionReference(ref);
|
|
18
|
+
const encodedArgs = Ref.encodeArgsSync(ref, args[0] ?? {});
|
|
15
19
|
return Effect.promise(() => scheduler.runAfter(delayMs, functionReference, encodedArgs));
|
|
16
20
|
},
|
|
17
21
|
runAt: (dateTime, ref, ...args) => {
|
|
18
22
|
const timestamp = DateTime.toEpochMillis(dateTime);
|
|
19
|
-
const functionReference = Ref
|
|
20
|
-
const encodedArgs = Ref
|
|
23
|
+
const functionReference = Ref.getFunctionReference(ref);
|
|
24
|
+
const encodedArgs = Ref.encodeArgsSync(ref, args[0] ?? {});
|
|
21
25
|
return Effect.promise(() => scheduler.runAt(timestamp, functionReference, encodedArgs));
|
|
22
26
|
}
|
|
23
27
|
});
|
package/dist/Scheduler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheduler.js","names":[
|
|
1
|
+
{"version":3,"file":"Scheduler.js","names":[],"sources":["../src/Scheduler.ts"],"sourcesContent":["import { Ref } from \"@confect/core\";\nimport type { Scheduler as ConvexScheduler } from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport * as DateTime from \"effect/DateTime\";\nimport * as Duration from \"effect/Duration\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\nconst make = (scheduler: ConvexScheduler) => ({\n runAfter: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(\n delay: Duration.Duration,\n ref: Ref_,\n ...args: Ref.OptionalArgs<Ref_>\n ) => {\n const delayMs = Duration.toMillis(delay);\n const functionReference = Ref.getFunctionReference(ref);\n const encodedArgs = Ref.encodeArgsSync(\n ref,\n (args[0] ?? {}) as Ref.Args<Ref_>,\n );\n\n return Effect.promise(() =>\n scheduler.runAfter(delayMs, functionReference, encodedArgs),\n );\n },\n runAt: <Ref_ extends Ref.AnyMutation | Ref.AnyAction>(\n dateTime: DateTime.DateTime,\n ref: Ref_,\n ...args: Ref.OptionalArgs<Ref_>\n ) => {\n const timestamp = DateTime.toEpochMillis(dateTime);\n const functionReference = Ref.getFunctionReference(ref);\n const encodedArgs = Ref.encodeArgsSync(\n ref,\n (args[0] ?? {}) as Ref.Args<Ref_>,\n );\n\n return Effect.promise(() =>\n scheduler.runAt(timestamp, functionReference, encodedArgs),\n );\n },\n});\n\nexport const Scheduler = Context.GenericTag<ReturnType<typeof make>>(\n \"@confect/server/Scheduler\",\n);\nexport type Scheduler = typeof Scheduler.Identifier;\n\nexport const layer = (scheduler: ConvexScheduler) =>\n Layer.succeed(Scheduler, make(scheduler));\n"],"mappings":";;;;;;;;;;;;;AAQA,MAAM,QAAQ,eAAgC;CAC5C,WACE,OACA,KACA,GAAG,SACA;EACH,MAAM,UAAU,SAAS,SAAS,MAAM;EACxC,MAAM,oBAAoB,IAAI,qBAAqB,IAAI;EACvD,MAAM,cAAc,IAAI,eACtB,KACC,KAAK,MAAM,EAAE,CACf;AAED,SAAO,OAAO,cACZ,UAAU,SAAS,SAAS,mBAAmB,YAAY,CAC5D;;CAEH,QACE,UACA,KACA,GAAG,SACA;EACH,MAAM,YAAY,SAAS,cAAc,SAAS;EAClD,MAAM,oBAAoB,IAAI,qBAAqB,IAAI;EACvD,MAAM,cAAc,IAAI,eACtB,KACC,KAAK,MAAM,EAAE,CACf;AAED,SAAO,OAAO,cACZ,UAAU,MAAM,WAAW,mBAAmB,YAAY,CAC3D;;CAEJ;AAED,MAAa,YAAY,QAAQ,WAC/B,4BACD;AAGD,MAAa,SAAS,cACpB,MAAM,QAAQ,WAAW,KAAK,UAAU,CAAC"}
|
|
@@ -1,89 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
declare
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
declare const compileArgsSchema: <ConfectValue, ConvexValue>(argsSchema: Schema.Schema<ConfectValue, ConvexValue>) => PropertyValidators;
|
|
12
|
-
declare const compileReturnsSchema: <ConfectValue, ConvexValue>(schema: Schema.Schema<ConfectValue, ConvexValue>) => Validator<any, any, any>;
|
|
1
|
+
import type { PropertyValidators, Validator, VAny, VArray, VBoolean, VBytes, VFloat64, VId, VInt64, VLiteral, VNull, VObject, VOptional, VRecord, VString, VUnion } from "convex/values";
|
|
2
|
+
import * as Cause from "effect/Cause";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Schema from "effect/Schema";
|
|
5
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
6
|
+
import * as GenericId from "@confect/core/GenericId";
|
|
7
|
+
import type { IsAny, IsOptional, IsRecord, IsRecursive, IsUnion, TypeError, UnionToTuple } from "@confect/core/Types";
|
|
8
|
+
export declare const compileArgsSchema: <ConfectValue, ConvexValue>(argsSchema: Schema.Schema<ConfectValue, ConvexValue>) => PropertyValidators;
|
|
9
|
+
export declare const compileReturnsSchema: <ConfectValue, ConvexValue>(schema: Schema.Schema<ConfectValue, ConvexValue>) => Validator<any, any, any>;
|
|
13
10
|
/**
|
|
14
11
|
* Convert a table `Schema` to a table `Validator`.
|
|
15
12
|
*/
|
|
16
|
-
type TableSchemaToTableValidator<TableSchema extends Schema.Schema.AnyNoContext> = ValueToValidator<TableSchema["Encoded"]> extends infer Vd extends VObject<any, any, any, any> | VUnion<any, any, any, any> ? Vd : never;
|
|
17
|
-
declare const compileTableSchema: <TableSchema extends Schema.Schema.AnyNoContext>(schema: TableSchema) => TableSchemaToTableValidator<TableSchema>;
|
|
18
|
-
type ReadonlyValue = string | number | bigint | boolean | ArrayBuffer | ReadonlyArrayValue | ReadonlyRecordValue | null;
|
|
13
|
+
export type TableSchemaToTableValidator<TableSchema extends Schema.Schema.AnyNoContext> = ValueToValidator<TableSchema["Encoded"]> extends infer Vd extends VObject<any, any, any, any> | VUnion<any, any, any, any> ? Vd : never;
|
|
14
|
+
export declare const compileTableSchema: <TableSchema extends Schema.Schema.AnyNoContext>(schema: TableSchema) => TableSchemaToTableValidator<TableSchema>;
|
|
15
|
+
export type ReadonlyValue = string | number | bigint | boolean | ArrayBuffer | ReadonlyArrayValue | ReadonlyRecordValue | null;
|
|
19
16
|
type ReadonlyArrayValue = readonly ReadonlyValue[];
|
|
20
|
-
type ReadonlyRecordValue = {
|
|
21
|
-
|
|
17
|
+
export type ReadonlyRecordValue = {
|
|
18
|
+
readonly [key: string]: ReadonlyValue | undefined;
|
|
22
19
|
};
|
|
23
|
-
type MutableValue<T> = T extends ReadonlyArray<infer El> ? MutableValue<El>[] : T extends ReadonlyRecordValue ? {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
type MutableValue<T> = T extends ReadonlyArray<infer El> ? MutableValue<El>[] : T extends ReadonlyRecordValue ? {
|
|
21
|
+
-readonly [K in keyof T]: MutableValue<T[K]>;
|
|
22
|
+
} : T;
|
|
23
|
+
export type ValueToValidator<Vl> = [Vl] extends [never] ? never : IsAny<Vl> extends true ? VAny : [Vl] extends [null] ? VNull : [Vl] extends [boolean] ? [boolean] extends [Vl] ? VBoolean : VLiteral<Vl> : IsUnion<Vl> extends true ? IsRecursive<Vl> extends true ? VAny : [Vl] extends [ReadonlyValue] ? UnionValueToValidator<Vl> : TypeError<"Provided value is not a valid Convex value", Vl> : [Vl] extends [number] ? [number] extends [Vl] ? VFloat64 : VLiteral<Vl> : [Vl] extends [bigint] ? [bigint] extends [Vl] ? VInt64 : VLiteral<Vl> : [Vl] extends [string] ? Vl extends {
|
|
24
|
+
__tableName: infer TableName extends string;
|
|
25
|
+
} ? VId<GenericId.GenericId<TableName>> : [string] extends [Vl] ? VString : VLiteral<Vl> : [Vl] extends [ArrayBuffer] ? VBytes : IsRecursive<Vl> extends true ? VAny : [Vl] extends [ReadonlyValue] ? Vl extends ReadonlyArray<ReadonlyValue> ? ArrayValueToValidator<Vl> : Vl extends ReadonlyRecordValue ? RecordValueToValidator<Vl> : TypeError<"Unexpected value", Vl> : TypeError<"Provided value is not a valid Convex value", Vl>;
|
|
27
26
|
type ArrayValueToValidator<Vl extends ReadonlyArray<ReadonlyValue>> = Vl extends ReadonlyArray<infer El extends ReadonlyValue> ? ValueToValidator<El> extends infer Vd extends Validator<any, any, any> ? VArray<MutableValue<El[]>, Vd> : never : never;
|
|
28
|
-
type RecordValueToValidator<Vl> = Vl extends ReadonlyRecordValue ? {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
type RecordValueToValidator<Vl> = Vl extends ReadonlyRecordValue ? {
|
|
28
|
+
-readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true ? IsOptional<Vl, K> extends true ? VOptional<VAny> : VAny : UndefinedOrValueToValidator<Vl[K]>;
|
|
29
|
+
} extends infer VdRecord extends Record<string, any> ? {
|
|
30
|
+
-readonly [K in keyof Vl]: undefined extends Vl[K] ? MutableValue<Exclude<Vl[K], undefined>> : MutableValue<Vl[K]>;
|
|
31
|
+
} extends infer VlRecord extends Record<string, any> ? IsRecord<VlRecord> extends true ? VRecord<VlRecord, VString, VdRecord[keyof VdRecord]> : VObject<VlRecord, VdRecord> : never : never : never;
|
|
32
|
+
export type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> = undefined extends Vl ? [Vl] extends [(infer Val extends ReadonlyValue) | undefined] ? ValueToValidator<Val> extends infer Vd extends Validator<any, "required", any> ? VOptional<Vd> : never : never : [Vl] extends [ReadonlyValue] ? ValueToValidator<Vl> : never;
|
|
33
|
+
type UnionValueToValidator<Vl extends ReadonlyValue> = [Vl] extends [
|
|
34
|
+
ReadonlyValue
|
|
35
|
+
] ? IsUnion<Vl> extends true ? UnionToTuple<Vl> extends infer VlTuple extends ReadonlyArray<ReadonlyValue> ? ValueTupleToValidatorTuple<VlTuple> extends infer VdTuple extends Validator<any, "required", any>[] ? VUnion<MutableValue<Vl>, VdTuple> : TypeError<"Failed to convert value tuple to validator tuple"> : TypeError<"Failed to convert union to tuple"> : TypeError<"Expected a union of values, but got a single value instead"> : TypeError<"Provided value is not a valid Convex value">;
|
|
36
|
+
type ValueTupleToValidatorTuple<VlTuple extends ReadonlyArray<ReadonlyValue>> = VlTuple extends [true, false, ...infer VlRest extends ReadonlyArray<ReadonlyValue>] | [false, true, ...infer VlRest extends ReadonlyArray<ReadonlyValue>] ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<any, any, any>[] ? [VBoolean<boolean>, ...VdRest] : never : VlTuple extends [
|
|
37
|
+
infer Vl extends ReadonlyValue,
|
|
38
|
+
...infer VlRest extends ReadonlyArray<ReadonlyValue>
|
|
39
|
+
] ? ValueToValidator<Vl> extends infer Vd extends Validator<any, any, any> ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<any, "required", any>[] ? [Vd, ...VdRest] : never : never : [];
|
|
40
|
+
export declare const compileSchema: <T, E>(schema: Schema.Schema<T, E>) => ValueToValidator<(typeof schema)["Encoded"]>;
|
|
41
|
+
export declare const isRecursive: (ast: SchemaAST.AST) => boolean;
|
|
42
|
+
export declare const compileAst: (ast: SchemaAST.AST, isOptionalPropertyOfTypeLiteral?: boolean) => Effect.Effect<Validator<any, any, any>, UnsupportedSchemaTypeError | UnsupportedPropertySignatureKeyTypeError | IndexSignaturesAreNotSupportedError | MixedIndexAndPropertySignaturesAreNotSupportedError | OptionalTupleElementsAreNotSupportedError | EmptyTupleIsNotSupportedError>;
|
|
43
|
+
declare const TopLevelMustBeObjectError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
44
|
+
readonly _tag: "TopLevelMustBeObjectError";
|
|
37
45
|
} & Readonly<A>;
|
|
38
|
-
declare class TopLevelMustBeObjectError extends TopLevelMustBeObjectError_base {
|
|
39
|
-
|
|
46
|
+
export declare class TopLevelMustBeObjectError extends TopLevelMustBeObjectError_base {
|
|
47
|
+
get message(): string;
|
|
40
48
|
}
|
|
41
|
-
declare const TopLevelMustBeObjectOrUnionError_base: new <A extends Record<string, any> = {}>(args:
|
|
42
|
-
|
|
49
|
+
declare const TopLevelMustBeObjectOrUnionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
50
|
+
readonly _tag: "TopLevelMustBeObjectOrUnionError";
|
|
43
51
|
} & Readonly<A>;
|
|
44
|
-
declare class TopLevelMustBeObjectOrUnionError extends TopLevelMustBeObjectOrUnionError_base {
|
|
45
|
-
|
|
52
|
+
export declare class TopLevelMustBeObjectOrUnionError extends TopLevelMustBeObjectOrUnionError_base {
|
|
53
|
+
get message(): string;
|
|
46
54
|
}
|
|
47
|
-
declare const UnsupportedPropertySignatureKeyTypeError_base: new <A extends Record<string, any> = {}>(args:
|
|
48
|
-
|
|
55
|
+
declare const UnsupportedPropertySignatureKeyTypeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
56
|
+
readonly _tag: "UnsupportedPropertySignatureKeyTypeError";
|
|
49
57
|
} & Readonly<A>;
|
|
50
|
-
declare class UnsupportedPropertySignatureKeyTypeError extends UnsupportedPropertySignatureKeyTypeError_base<{
|
|
51
|
-
|
|
58
|
+
export declare class UnsupportedPropertySignatureKeyTypeError extends UnsupportedPropertySignatureKeyTypeError_base<{
|
|
59
|
+
readonly propertyKey: number | symbol;
|
|
52
60
|
}> {
|
|
53
|
-
|
|
61
|
+
get message(): string;
|
|
54
62
|
}
|
|
55
|
-
declare const EmptyTupleIsNotSupportedError_base: new <A extends Record<string, any> = {}>(args:
|
|
56
|
-
|
|
63
|
+
declare const EmptyTupleIsNotSupportedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
64
|
+
readonly _tag: "EmptyTupleIsNotSupportedError";
|
|
57
65
|
} & Readonly<A>;
|
|
58
|
-
declare class EmptyTupleIsNotSupportedError extends EmptyTupleIsNotSupportedError_base {
|
|
59
|
-
|
|
66
|
+
export declare class EmptyTupleIsNotSupportedError extends EmptyTupleIsNotSupportedError_base {
|
|
67
|
+
get message(): string;
|
|
60
68
|
}
|
|
61
|
-
declare const UnsupportedSchemaTypeError_base: new <A extends Record<string, any> = {}>(args:
|
|
62
|
-
|
|
69
|
+
declare const UnsupportedSchemaTypeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
70
|
+
readonly _tag: "UnsupportedSchemaTypeError";
|
|
63
71
|
} & Readonly<A>;
|
|
64
|
-
declare class UnsupportedSchemaTypeError extends UnsupportedSchemaTypeError_base<{
|
|
65
|
-
|
|
72
|
+
export declare class UnsupportedSchemaTypeError extends UnsupportedSchemaTypeError_base<{
|
|
73
|
+
readonly schemaType: SchemaAST.AST["_tag"];
|
|
66
74
|
}> {
|
|
67
|
-
|
|
75
|
+
get message(): string;
|
|
68
76
|
}
|
|
69
|
-
declare const IndexSignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args:
|
|
70
|
-
|
|
77
|
+
declare const IndexSignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
78
|
+
readonly _tag: "IndexSignaturesAreNotSupportedError";
|
|
71
79
|
} & Readonly<A>;
|
|
72
|
-
declare class IndexSignaturesAreNotSupportedError extends IndexSignaturesAreNotSupportedError_base {
|
|
73
|
-
|
|
80
|
+
export declare class IndexSignaturesAreNotSupportedError extends IndexSignaturesAreNotSupportedError_base {
|
|
81
|
+
get message(): string;
|
|
74
82
|
}
|
|
75
|
-
declare const MixedIndexAndPropertySignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args:
|
|
76
|
-
|
|
83
|
+
declare const MixedIndexAndPropertySignaturesAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
84
|
+
readonly _tag: "MixedIndexAndPropertySignaturesAreNotSupportedError";
|
|
77
85
|
} & Readonly<A>;
|
|
78
|
-
declare class MixedIndexAndPropertySignaturesAreNotSupportedError extends MixedIndexAndPropertySignaturesAreNotSupportedError_base {
|
|
79
|
-
|
|
86
|
+
export declare class MixedIndexAndPropertySignaturesAreNotSupportedError extends MixedIndexAndPropertySignaturesAreNotSupportedError_base {
|
|
87
|
+
get message(): string;
|
|
80
88
|
}
|
|
81
|
-
declare const OptionalTupleElementsAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args:
|
|
82
|
-
|
|
89
|
+
declare const OptionalTupleElementsAreNotSupportedError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => Cause.YieldableError & {
|
|
90
|
+
readonly _tag: "OptionalTupleElementsAreNotSupportedError";
|
|
83
91
|
} & Readonly<A>;
|
|
84
|
-
declare class OptionalTupleElementsAreNotSupportedError extends OptionalTupleElementsAreNotSupportedError_base {
|
|
85
|
-
|
|
92
|
+
export declare class OptionalTupleElementsAreNotSupportedError extends OptionalTupleElementsAreNotSupportedError_base {
|
|
93
|
+
get message(): string;
|
|
86
94
|
}
|
|
87
|
-
|
|
88
|
-
export { EmptyTupleIsNotSupportedError, IndexSignaturesAreNotSupportedError, MixedIndexAndPropertySignaturesAreNotSupportedError, OptionalTupleElementsAreNotSupportedError, ReadonlyRecordValue, ReadonlyValue, SchemaToValidator_d_exports, TableSchemaToTableValidator, TopLevelMustBeObjectError, TopLevelMustBeObjectOrUnionError, UndefinedOrValueToValidator, UnsupportedPropertySignatureKeyTypeError, UnsupportedSchemaTypeError, ValueToValidator, compileArgsSchema, compileAst, compileReturnsSchema, compileSchema, compileTableSchema, isRecursive };
|
|
95
|
+
export {};
|
|
89
96
|
//# sourceMappingURL=SchemaToValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaToValidator.d.ts","
|
|
1
|
+
{"version":3,"file":"SchemaToValidator.d.ts","sourceRoot":"","sources":["../src/SchemaToValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,SAAS,EACT,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AExD;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,mDAAoD,SAAQ,wDAExE;IAEC,IAAa,OAAO,WAEnB;CAEF;;;;AAED,qBAAa,yCAA0C,SAAQ,8CAE9D;IAEC,IAAa,OAAO,WAEnB;CAEF"}
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import {
|
|
2
|
+
import { pipe } from "effect/Function";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Option from "effect/Option";
|
|
5
|
+
import * as Schema from "effect/Schema";
|
|
6
|
+
import * as Array from "effect/Array";
|
|
7
|
+
import * as Predicate from "effect/Predicate";
|
|
8
|
+
import * as Match from "effect/Match";
|
|
3
9
|
import { v } from "convex/values";
|
|
4
|
-
import * as
|
|
10
|
+
import * as Cause from "effect/Cause";
|
|
11
|
+
import * as Data from "effect/Data";
|
|
12
|
+
import * as Exit from "effect/Exit";
|
|
13
|
+
import * as Number from "effect/Number";
|
|
14
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
15
|
+
import * as String from "effect/String";
|
|
16
|
+
import * as GenericId from "@confect/core/GenericId";
|
|
5
17
|
|
|
6
18
|
//#region src/SchemaToValidator.ts
|
|
7
19
|
var SchemaToValidator_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -31,7 +43,7 @@ const compileTableSchema = (schema) => {
|
|
|
31
43
|
};
|
|
32
44
|
const compileSchema = (schema) => runSyncThrow(compileAst(schema.ast));
|
|
33
45
|
const isRecursive = (ast) => pipe(ast, Match.value, Match.tag("Literal", "BooleanKeyword", "StringKeyword", "NumberKeyword", "BigIntKeyword", "UnknownKeyword", "AnyKeyword", "Declaration", "UniqueSymbol", "SymbolKeyword", "UndefinedKeyword", "VoidKeyword", "NeverKeyword", "Enums", "TemplateLiteral", "ObjectKeyword", "Transformation", () => false), Match.tag("Union", ({ types }) => Array.some(types, (type) => isRecursive(type))), Match.tag("TypeLiteral", ({ propertySignatures }) => Array.some(propertySignatures, ({ type }) => isRecursive(type))), Match.tag("TupleType", ({ elements: optionalElements, rest: elements }) => Array.some(optionalElements, (optionalElement) => isRecursive(optionalElement.type)) || Array.some(elements, (element) => isRecursive(element.type))), Match.tag("Refinement", ({ from }) => isRecursive(from)), Match.tag("Suspend", () => true), Match.exhaustive);
|
|
34
|
-
const compileAst = (ast, isOptionalPropertyOfTypeLiteral = false) => isRecursive(ast) ? Effect.succeed(v.any()) : pipe(ast, Match.value, Match.tag("Literal", ({ literal }) => pipe(literal, Match.value, Match.whenOr(Match.string, Match.number, Match.bigint, Match.boolean, (l) => v.literal(l)), Match.when(Match.null, () => v.null()), Match.exhaustive, Effect.succeed)), Match.tag("BooleanKeyword", () => Effect.succeed(v.boolean())), Match.tag("StringKeyword", (stringAst) => GenericId
|
|
46
|
+
const compileAst = (ast, isOptionalPropertyOfTypeLiteral = false) => isRecursive(ast) ? Effect.succeed(v.any()) : pipe(ast, Match.value, Match.tag("Literal", ({ literal }) => pipe(literal, Match.value, Match.whenOr(Match.string, Match.number, Match.bigint, Match.boolean, (l) => v.literal(l)), Match.when(Match.null, () => v.null()), Match.exhaustive, Effect.succeed)), Match.tag("BooleanKeyword", () => Effect.succeed(v.boolean())), Match.tag("StringKeyword", (stringAst) => GenericId.tableName(stringAst).pipe(Option.match({
|
|
35
47
|
onNone: () => Effect.succeed(v.string()),
|
|
36
48
|
onSome: (tableName) => Effect.succeed(v.id(tableName))
|
|
37
49
|
}))), Match.tag("NumberKeyword", () => Effect.succeed(v.float64())), Match.tag("BigIntKeyword", () => Effect.succeed(v.int64())), Match.tag("Union", (unionAst) => handleUnion(unionAst, isOptionalPropertyOfTypeLiteral)), Match.tag("TypeLiteral", (typeLiteralAst) => handleTypeLiteral(typeLiteralAst)), Match.tag("TupleType", (tupleTypeAst) => handleTupleType(tupleTypeAst)), Match.tag("UnknownKeyword", "AnyKeyword", () => Effect.succeed(v.any())), Match.tag("Declaration", (declaration) => Effect.mapBoth(declaration.decodeUnknown(...declaration.typeParameters)(/* @__PURE__ */ new ArrayBuffer(0), {}, declaration), {
|