@confect/server 9.0.0-next.9 → 9.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 +154 -4
- package/dist/ActionCtx.d.ts +3 -10
- package/dist/ActionCtx.d.ts.map +1 -1
- package/dist/ActionRunner.d.ts +7 -14
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/Auth.d.ts +15 -23
- package/dist/Auth.d.ts.map +1 -1
- package/dist/BlobNotFoundError.d.ts +5 -11
- package/dist/BlobNotFoundError.d.ts.map +1 -1
- package/dist/ConvexConfigProvider.d.ts +1 -8
- package/dist/ConvexConfigProvider.d.ts.map +1 -1
- package/dist/CronJob.d.ts +12 -19
- package/dist/CronJob.d.ts.map +1 -1
- package/dist/CronJobs.d.ts +11 -18
- package/dist/CronJobs.d.ts.map +1 -1
- package/dist/DataModel.d.ts +24 -29
- package/dist/DataModel.d.ts.map +1 -1
- package/dist/DatabaseReader.d.ts +4313 -4328
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseSchema.d.ts +19 -24
- package/dist/DatabaseSchema.d.ts.map +1 -1
- package/dist/DatabaseWriter.d.ts +36 -42
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/Document.d.ts +26 -36
- package/dist/Document.d.ts.map +1 -1
- package/dist/FunctionImpl.d.ts +11 -20
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/GroupImpl.d.ts +29 -35
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/Handler.d.ts +34 -40
- package/dist/Handler.d.ts.map +1 -1
- package/dist/HttpApi.d.ts +19 -25
- package/dist/HttpApi.d.ts.map +1 -1
- package/dist/HttpApi.js +4 -4
- package/dist/HttpApi.js.map +1 -1
- package/dist/MutationCtx.d.ts +3 -10
- package/dist/MutationCtx.d.ts.map +1 -1
- package/dist/MutationRunner.d.ts +7 -14
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/OrderedQuery.d.ts +15 -22
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/QueryCtx.d.ts +3 -10
- package/dist/QueryCtx.d.ts.map +1 -1
- package/dist/QueryInitializer.d.ts +32 -38
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryRunner.d.ts +7 -14
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +1099 -1121
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +4 -4
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +46 -64
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +4 -4
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +20 -22
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +4 -14
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegistryItem.d.ts +17 -27
- package/dist/RegistryItem.d.ts.map +1 -1
- package/dist/Scheduler.d.ts +14 -22
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/SchemaToValidator.d.ts +68 -64
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +2 -2
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/StorageActionWriter.d.ts +20 -28
- package/dist/StorageActionWriter.d.ts.map +1 -1
- package/dist/StorageReader.d.ts +13 -21
- package/dist/StorageReader.d.ts.map +1 -1
- package/dist/StorageWriter.d.ts +15 -23
- package/dist/StorageWriter.d.ts.map +1 -1
- package/dist/Table.d.ts +202 -203
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +2 -2
- 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 +28 -35
- package/dist/VectorSearch.d.ts.map +1 -1
- package/dist/index.d.ts +35 -35
- package/dist/index.d.ts.map +1 -0
- package/dist/internal/utils.d.ts +10 -13
- package/dist/internal/utils.d.ts.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 +4 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredConvexFunction.d.ts","
|
|
1
|
+
{"version":3,"file":"RegisteredConvexFunction.d.ts","sourceRoot":"","sources":["../src/RegisteredConvexFunction.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,kBAAkB,EAOxB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,KAAK,SAAS,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,cAAc,MAAM,kBAAkB,CAAC;AAEnD,OAAO,KAAK,WAAW,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,kBAAkB,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,eAAO,MAAM,IAAI,GACf,gBAAgB,cAAc,CAAC,YAAY,EAC3C,2BAA2B,YAAY,CAAC,YAAY,KACnD,k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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAkBxE,CAAC;AAEJ,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,cAAc,CAAC,YAAY,IACnE,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,GACrC,cAAc,CAAC,cAAc,CAAC,MAAM,CAAC,GACrC,IAAI,CAAC,IAAI,GACT,SAAS,CAAC,SAAS,GACnB,aAAa,GACb,aAAa,GACb,WAAW,CAAC,WAAW,GACvB,cAAc,CAAC,cAAc,GAC7B,WAAW,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -7,8 +7,8 @@ import { layer as layer$2 } from "./DatabaseWriter.js";
|
|
|
7
7
|
import { layer as layer$3 } from "./MutationRunner.js";
|
|
8
8
|
import { layer as layer$4 } from "./QueryRunner.js";
|
|
9
9
|
import { layer as layer$5 } from "./Scheduler.js";
|
|
10
|
-
import { StorageReader
|
|
11
|
-
import { StorageWriter
|
|
10
|
+
import { StorageReader } from "./StorageReader.js";
|
|
11
|
+
import { StorageWriter } from "./StorageWriter.js";
|
|
12
12
|
import { MutationCtx } from "./MutationCtx.js";
|
|
13
13
|
import { QueryCtx } from "./QueryCtx.js";
|
|
14
14
|
import { actionFunctionBase, actionLayer, runHandlerPromise } from "./RegisteredFunction.js";
|
|
@@ -89,10 +89,10 @@ const queryFunction = ({ databaseSchema, args, returns, error, handler }) => ({
|
|
|
89
89
|
args: compileArgsSchema(args),
|
|
90
90
|
returns: compileReturnsSchema(returns),
|
|
91
91
|
handler: (ctx, actualArgs) => withStubbedDateNow((clock) => Effect.gen(function* () {
|
|
92
|
-
return yield* pipe(yield* handler(yield* pipe(actualArgs, Schema.decode(args), Effect.orDie)).pipe(Effect.provide(Layer.mergeAll(layer$1(databaseSchema, ctx.db), layer(ctx.auth), StorageReader
|
|
92
|
+
return yield* pipe(yield* handler(yield* pipe(actualArgs, Schema.decode(args), Effect.orDie)).pipe(Effect.provide(Layer.mergeAll(layer$1(databaseSchema, ctx.db), layer(ctx.auth), StorageReader.layer(ctx.storage), layer$4(ctx.runQuery), Layer.succeed(QueryCtx(), ctx), Layer.setConfigProvider(make$1())))), Schema.encode(returns), Effect.orDie);
|
|
93
93
|
}).pipe(Effect.withClock(clock), runHandlerPromise(error)))
|
|
94
94
|
});
|
|
95
|
-
const mutationLayer = (schema, ctx) => Layer.mergeAll(layer$1(schema, ctx.db), layer$2(schema, ctx.db), layer(ctx.auth), layer$5(ctx.scheduler), StorageReader
|
|
95
|
+
const mutationLayer = (schema, ctx) => Layer.mergeAll(layer$1(schema, ctx.db), layer$2(schema, ctx.db), layer(ctx.auth), layer$5(ctx.scheduler), StorageReader.layer(ctx.storage), StorageWriter.layer(ctx.storage), layer$4(ctx.runQuery), layer$3(ctx.runMutation), Layer.succeed(MutationCtx(), ctx), Layer.setConfigProvider(make$1()));
|
|
96
96
|
const mutationFunction = ({ databaseSchema, args, returns, error, handler }) => ({
|
|
97
97
|
args: compileArgsSchema(args),
|
|
98
98
|
returns: compileReturnsSchema(returns),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredConvexFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","StorageReader","QueryRunner.layer","QueryCtx.QueryCtx","ConvexConfigProvider.make","RegisteredFunction.runHandlerPromise","DatabaseWriter.layer","Scheduler.layer","StorageWriter","MutationRunner.layer","MutationCtx.MutationCtx","RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredConvexFunction.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport {\n actionGeneric,\n type DefaultFunctionArgs,\n type GenericMutationCtx,\n type GenericQueryCtx,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n mutationGeneric,\n queryGeneric,\n} from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Clock from \"effect/Clock\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Match from \"effect/Match\";\nimport * as Schema from \"effect/Schema\";\nimport * as Auth from \"./Auth\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as Handler from \"./Handler\";\nimport * as MutationCtx from \"./MutationCtx\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryCtx from \"./QueryCtx\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as RegistryItem from \"./RegistryItem\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport { StorageReader } from \"./StorageReader\";\nimport { StorageWriter } from \"./StorageWriter\";\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 return Match.value(functionSpec.runtimeAndFunctionType.functionType).pipe(\n Match.when(\"query\", () => {\n const genericFunction = Match.value(functionVisibility).pipe(\n Match.when(\"public\", () => queryGeneric),\n Match.when(\"internal\", () => internalQueryGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n queryFunction({\n databaseSchema,\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.when(\"mutation\", () => {\n const genericFunction = Match.value(functionVisibility).pipe(\n Match.when(\"public\", () => mutationGeneric),\n Match.when(\"internal\", () => internalMutationGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n mutationFunction({\n databaseSchema,\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.when(\"action\", () => {\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 convexActionFunction(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 }),\n Match.exhaustive,\n );\n\n/**\n * Convex's query cache is invalidated by any Date.now() call during handler\n * execution. Effect's unsafeFork calls Date.now() when constructing a\n * FiberId.Runtime, which trips the cache for every confect-wrapped query. We\n * stub Date.now to 0 for the span of the handler; queries are forbidden from\n * relying on real time for correctness anyway.\n *\n * Users who explicitly want the real timestamp can still reach it via Effect's\n * Clock service (Clock.currentTimeMillis/Clock.currentTimeNanos). We provide a\n * Clock whose user-facing Effects call realDateNow (Convex's tracker) directly,\n * making Clock an explicit opt-in to cache invalidation. The unsafe methods\n * used internally by Effect (logging, span events, scheduler) return constants\n * so they never touch the tracker—caching is not broken by default.\n */\nconst unpatchedClock = (realDateNow: () => number): Clock.Clock => {\n const defaultClock = Clock.make();\n return {\n ...defaultClock,\n unsafeCurrentTimeMillis: () => 0,\n unsafeCurrentTimeNanos: () => 0n,\n currentTimeMillis: Effect.sync(() => realDateNow()),\n currentTimeNanos: Effect.sync(() => BigInt(realDateNow()) * 1_000_000n),\n };\n};\n\nconst withStubbedDateNow = async <T>(\n queryHandler: (clock: Clock.Clock) => Promise<T>,\n): Promise<T> => {\n const realDateNow = Date.now;\n const clock = unpatchedClock(realDateNow);\n Date.now = () => 0;\n try {\n return await queryHandler(clock);\n } finally {\n Date.now = realDateNow;\n }\n};\n\nconst queryFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n databaseSchema,\n args,\n returns,\n error,\n handler,\n}: {\n databaseSchema: DatabaseSchema_;\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n >;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericQueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n withStubbedDateNow((clock) =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(\n Layer.mergeAll(\n DatabaseReader.layer(databaseSchema, ctx.db),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n Layer.succeed(\n QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >(),\n ctx,\n ),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n ),\n );\n return yield* pipe(\n decodedReturns,\n Schema.encode(returns),\n Effect.orDie,\n );\n }).pipe(\n Effect.withClock(clock),\n RegisteredFunction.runHandlerPromise(error),\n ),\n ),\n});\n\nexport const mutationLayer = <Schema extends DatabaseSchema.AnyWithProps>(\n schema: Schema,\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n) =>\n Layer.mergeAll(\n DatabaseReader.layer(schema, ctx.db),\n DatabaseWriter.layer(schema, ctx.db),\n Auth.layer(ctx.auth),\n Scheduler.layer(ctx.scheduler),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n Layer.succeed(\n MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n );\n\nexport type MutationServices<Schema extends DatabaseSchema.AnyWithProps> =\n | DatabaseReader.DatabaseReader<Schema>\n | DatabaseWriter.DatabaseWriter<Schema>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>;\n\nconst mutationFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n databaseSchema,\n args,\n returns,\n error,\n handler,\n}: {\n databaseSchema: DatabaseSchema_;\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\n handler: (\n a: Args,\n ) => Effect.Effect<Returns, E, MutationServices<DatabaseSchema_>>;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericMutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(mutationLayer(databaseSchema, ctx)),\n );\n return yield* pipe(decodedReturns, Schema.encode(returns), Effect.orDie);\n }).pipe(RegisteredFunction.runHandlerPromise(error)),\n});\n\nconst convexActionFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: 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 >;\n },\n) =>\n RegisteredFunction.actionFunctionBase({\n args,\n returns,\n error,\n handler,\n createLayer: (ctx) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(schema, ctx),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,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;AAEF,QAAO,MAAM,MAAM,aAAa,uBAAuB,aAAa,CAAC,KACnE,MAAM,KAAK,eAAe;AAOxB,SANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gB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MAAM,wBAQJ,QACA,EACE,MACA,SACA,OACA,cAcFM,mBAAsC;CACpC;CACA;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,QAAQ,IAAI,EAC3C,MAAM,kBAAkBR,QAA2B,CAAC,CACrD;CACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"RegisteredConvexFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","QueryRunner.layer","QueryCtx.QueryCtx","ConvexConfigProvider.make","RegisteredFunction.runHandlerPromise","DatabaseWriter.layer","Scheduler.layer","MutationRunner.layer","MutationCtx.MutationCtx","RegisteredFunction.actionFunctionBase","RegisteredFunction.actionLayer"],"sources":["../src/RegisteredConvexFunction.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport {\n actionGeneric,\n type DefaultFunctionArgs,\n type GenericMutationCtx,\n type GenericQueryCtx,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n mutationGeneric,\n queryGeneric,\n} from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Clock from \"effect/Clock\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Match from \"effect/Match\";\nimport * as Schema from \"effect/Schema\";\nimport * as Auth from \"./Auth\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as Handler from \"./Handler\";\nimport * as MutationCtx from \"./MutationCtx\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryCtx from \"./QueryCtx\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as RegistryItem from \"./RegistryItem\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport { StorageReader } from \"./StorageReader\";\nimport { StorageWriter } from \"./StorageWriter\";\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 return Match.value(functionSpec.runtimeAndFunctionType.functionType).pipe(\n Match.when(\"query\", () => {\n const genericFunction = Match.value(functionVisibility).pipe(\n Match.when(\"public\", () => queryGeneric),\n Match.when(\"internal\", () => internalQueryGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n queryFunction({\n databaseSchema,\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.when(\"mutation\", () => {\n const genericFunction = Match.value(functionVisibility).pipe(\n Match.when(\"public\", () => mutationGeneric),\n Match.when(\"internal\", () => internalMutationGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n mutationFunction({\n databaseSchema,\n args: functionProvenance.args,\n returns: functionProvenance.returns,\n error: functionProvenance.error,\n handler: handler as Handler.AnyConfectProvenance,\n }),\n );\n }),\n Match.when(\"action\", () => {\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 convexActionFunction(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 }),\n Match.exhaustive,\n );\n\n/**\n * Convex's query cache is invalidated by any Date.now() call during handler\n * execution. Effect's unsafeFork calls Date.now() when constructing a\n * FiberId.Runtime, which trips the cache for every confect-wrapped query. We\n * stub Date.now to 0 for the span of the handler; queries are forbidden from\n * relying on real time for correctness anyway.\n *\n * Users who explicitly want the real timestamp can still reach it via Effect's\n * Clock service (Clock.currentTimeMillis/Clock.currentTimeNanos). We provide a\n * Clock whose user-facing Effects call realDateNow (Convex's tracker) directly,\n * making Clock an explicit opt-in to cache invalidation. The unsafe methods\n * used internally by Effect (logging, span events, scheduler) return constants\n * so they never touch the tracker—caching is not broken by default.\n */\nconst unpatchedClock = (realDateNow: () => number): Clock.Clock => {\n const defaultClock = Clock.make();\n return {\n ...defaultClock,\n unsafeCurrentTimeMillis: () => 0,\n unsafeCurrentTimeNanos: () => 0n,\n currentTimeMillis: Effect.sync(() => realDateNow()),\n currentTimeNanos: Effect.sync(() => BigInt(realDateNow()) * 1_000_000n),\n };\n};\n\nconst withStubbedDateNow = async <T>(\n queryHandler: (clock: Clock.Clock) => Promise<T>,\n): Promise<T> => {\n const realDateNow = Date.now;\n const clock = unpatchedClock(realDateNow);\n Date.now = () => 0;\n try {\n return await queryHandler(clock);\n } finally {\n Date.now = realDateNow;\n }\n};\n\nconst queryFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n databaseSchema,\n args,\n returns,\n error,\n handler,\n}: {\n databaseSchema: DatabaseSchema_;\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >\n >;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericQueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n withStubbedDateNow((clock) =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(\n Layer.mergeAll(\n DatabaseReader.layer(databaseSchema, ctx.db),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n Layer.succeed(\n QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >(),\n ctx,\n ),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n ),\n );\n return yield* pipe(\n decodedReturns,\n Schema.encode(returns),\n Effect.orDie,\n );\n }).pipe(\n Effect.withClock(clock),\n RegisteredFunction.runHandlerPromise(error),\n ),\n ),\n});\n\nexport const mutationLayer = <Schema extends DatabaseSchema.AnyWithProps>(\n schema: Schema,\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n) =>\n Layer.mergeAll(\n DatabaseReader.layer(schema, ctx.db),\n DatabaseWriter.layer(schema, ctx.db),\n Auth.layer(ctx.auth),\n Scheduler.layer(ctx.scheduler),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n Layer.succeed(\n MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n );\n\nexport type MutationServices<Schema extends DatabaseSchema.AnyWithProps> =\n | DatabaseReader.DatabaseReader<Schema>\n | DatabaseWriter.DatabaseWriter<Schema>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>;\n\nconst mutationFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n databaseSchema,\n args,\n returns,\n error,\n handler,\n}: {\n databaseSchema: DatabaseSchema_;\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\n handler: (\n a: Args,\n ) => Effect.Effect<Returns, E, MutationServices<DatabaseSchema_>>;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericMutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(mutationLayer(databaseSchema, ctx)),\n );\n return yield* pipe(decodedReturns, Schema.encode(returns), Effect.orDie);\n }).pipe(RegisteredFunction.runHandlerPromise(error)),\n});\n\nconst convexActionFunction = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: 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 >;\n },\n) =>\n RegisteredFunction.actionFunctionBase({\n args,\n returns,\n error,\n handler,\n createLayer: (ctx) =>\n Layer.mergeAll(\n RegisteredFunction.actionLayer(schema, ctx),\n Layer.setConfigProvider(ConvexConfigProvider.make()),\n ),\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,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;AAEF,QAAO,MAAM,MAAM,aAAa,uBAAuB,aAAa,CAAC,KACnE,MAAM,KAAK,eAAe;AAOxB,SANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gBAAgB,aAAa,EACxC,MAAM,KAAK,kBAAkB,qBAAqB,EAClD,MAAM,WACP,CAGC,cAAc;GACZ;GACA,MAAM,mBAAmB;GACzB,SAAS,mBAAmB;GAC5B,OAAO,mBAAmB;GACjB;GACV,CAAC,CACH;GACD,EACF,MAAM,KAAK,kBAAkB;AAO3B,SANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gBAAgB,gBAAgB,EAC3C,MAAM,KAAK,kBAAkB,wBAAwB,EACrD,MAAM,WACP,CAGC,iBAAiB;GACf;GACA,MAAM,mBAAmB;GACzB,SAAS,mBAAmB;GAC5B,OAAO,mBAAmB;GACjB;GACV,CAAC,CACH;GACD,EACF,MAAM,KAAK,gBAAgB;AAOzB,SANwB,MAAM,MAAM,mBAAmB,CAAC,KACtD,MAAM,KAAK,gBAAgB,cAAc,EACzC,MAAM,KAAK,kBAAkB,sBAAsB,EACnD,MAAM,WACP,CAGC,qBAAqB,gBAAgB;GACnC,MAAM,mBAAmB;GACzB,SAAS,mBAAmB;GAC5B,OAAO,mBAAmB;GACjB;GACV,CAAC,CACH;GACD,EACF,MAAM,WACP;EACD,EACF,MAAM,WACP;;;;;;;;;;;;;;;AAgBH,MAAM,kBAAkB,gBAA2C;AAEjE,QAAO;EACL,GAFmB,MAAM,MA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AAkBL,QAA2B,CAAC,CACrD;AAaH,MAAM,oBAOJ,EACA,gBACA,MACA,SACA,OACA,eASK;CACL,MAAMN,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KAGA,eAEA,OAAO,IAAI,aAAa;AAStB,SAAO,OAAO,KAHS,OAAO,QALV,OAAO,KACzB,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,MACR,CACiD,CAAC,KACjD,OAAO,QAAQ,cAAc,gBAAgB,IAAI,CAAC,CACnD,EACkC,OAAO,OAAO,QAAQ,EAAE,OAAO,MAAM;GACxE,CAAC,KAAKM,kBAAqC,MAAM,CAAC;CACvD;AAED,MAAM,wBAQJ,QACA,EACE,MACA,SACA,OACA,cAcFK,mBAAsC;CACpC;CACA;CACA;CACA;CACA,cAAc,QACZ,MAAM,SACJC,YAA+B,QAAQ,IAAI,EAC3C,MAAM,kBAAkBP,QAA2B,CAAC,CACrD;CACJ,CAAC"}
|
|
@@ -1,43 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { FromSchema, TableNames, ToConvex } from "./DataModel.js";
|
|
6
|
-
import { MutationRunner } from "./MutationRunner.js";
|
|
7
|
-
import { QueryRunner } from "./QueryRunner.js";
|
|
8
|
-
import { Scheduler as Scheduler$1 } from "./Scheduler.js";
|
|
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";
|
|
12
|
-
import { VectorSearch } from "./VectorSearch.js";
|
|
13
|
-
import * as _confect_core_Ref0 from "@confect/core/Ref";
|
|
14
|
-
import * as convex_server0 from "convex/server";
|
|
15
|
-
import { DefaultFunctionArgs, FunctionVisibility, GenericActionCtx, RegisteredAction, RegisteredMutation, RegisteredQuery } from "convex/server";
|
|
16
|
-
import * as Layer from "effect/Layer";
|
|
1
|
+
import type { FunctionSpec, RuntimeAndFunctionType } from "@confect/core";
|
|
2
|
+
import type * as FunctionProvenance from "@confect/core/FunctionProvenance";
|
|
3
|
+
import { type DefaultFunctionArgs, type FunctionVisibility, type GenericActionCtx, type RegisteredAction, type RegisteredMutation, type RegisteredQuery } from "convex/server";
|
|
4
|
+
import type { Value } from "convex/values";
|
|
17
5
|
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
18
7
|
import * as Schema from "effect/Schema";
|
|
19
|
-
import
|
|
20
|
-
import * as
|
|
21
|
-
import * as
|
|
22
|
-
import * as
|
|
23
|
-
import
|
|
24
|
-
import * as
|
|
25
|
-
import * as
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
type Any = RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;
|
|
8
|
+
import * as ActionCtx from "./ActionCtx";
|
|
9
|
+
import * as ActionRunner from "./ActionRunner";
|
|
10
|
+
import * as Auth from "./Auth";
|
|
11
|
+
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
12
|
+
import type * as DataModel from "./DataModel";
|
|
13
|
+
import * as MutationRunner from "./MutationRunner";
|
|
14
|
+
import * as QueryRunner from "./QueryRunner";
|
|
15
|
+
import * as Scheduler from "./Scheduler";
|
|
16
|
+
import * as StorageActionWriter from "./StorageActionWriter";
|
|
17
|
+
import * as StorageReader from "./StorageReader";
|
|
18
|
+
import * as StorageWriter from "./StorageWriter";
|
|
19
|
+
import * as VectorSearch from "./VectorSearch";
|
|
20
|
+
export type Any = RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any> | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;
|
|
32
21
|
type ConfectRegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec.EncodedArgs<FunctionSpec_> extends infer Args_ extends DefaultFunctionArgs ? RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "query" ? RegisteredQuery<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "mutation" ? RegisteredMutation<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "action" ? RegisteredAction<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>> : never : never;
|
|
33
|
-
type ConvexRegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
export type ConvexRegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends {
|
|
23
|
+
functionProvenance: {
|
|
24
|
+
_tag: "Convex";
|
|
25
|
+
_args: infer Args_ extends DefaultFunctionArgs;
|
|
26
|
+
_returns: infer Returns_;
|
|
27
|
+
};
|
|
39
28
|
} ? RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "query" ? RegisteredQuery<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Returns_> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "mutation" ? RegisteredMutation<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Returns_> : RuntimeAndFunctionType.GetFunctionType<FunctionSpec_["runtimeAndFunctionType"]> extends "action" ? RegisteredAction<FunctionSpec.GetFunctionVisibility<FunctionSpec_>, Args_, Returns_> : never : never;
|
|
40
|
-
type RegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConvex> ? ConvexRegisteredFunction<FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConfect> ? ConfectRegisteredFunction<FunctionSpec_> : never;
|
|
29
|
+
export type RegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConvex> ? ConvexRegisteredFunction<FunctionSpec_> : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<FunctionSpec_, FunctionProvenance.AnyConfect> ? ConfectRegisteredFunction<FunctionSpec_> : never;
|
|
41
30
|
/**
|
|
42
31
|
* Run the `Effect` as a `Promise`. The error schema acts as an allowlist of
|
|
43
32
|
* failures that may be surfaced to the client as a `ConvexError`:
|
|
@@ -53,36 +42,29 @@ type RegisteredFunction<FunctionSpec_ extends FunctionSpec.AnyWithProps> = Funct
|
|
|
53
42
|
* error channel—reaches the client as a `ConvexError`. The fiber dies and
|
|
54
43
|
* `runPromise` rejects with a generic failure.
|
|
55
44
|
*/
|
|
56
|
-
declare const runHandlerPromise: (errorSchema: Schema.Schema.AnyNoContext | undefined) => <A, E>(effect: Effect.Effect<A, E>) => Promise<A>;
|
|
57
|
-
declare const actionFunctionBase: <Schema extends AnyWithProps, Args, ConvexArgs extends DefaultFunctionArgs, Returns, ConvexReturns, E, R>({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}: {
|
|
64
|
-
args: Schema.Schema<Args, ConvexArgs>;
|
|
65
|
-
returns: Schema.Schema<Returns, ConvexReturns>;
|
|
66
|
-
error: Schema.Schema<Error, Value> | undefined;
|
|
67
|
-
handler: (a: Args) => Effect.Effect<Returns, E, R>;
|
|
68
|
-
createLayer: (ctx: GenericActionCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<R>;
|
|
45
|
+
export declare const runHandlerPromise: (errorSchema: Schema.Schema.AnyNoContext | undefined) => <A, E>(effect: Effect.Effect<A, E>) => Promise<A>;
|
|
46
|
+
export declare const actionFunctionBase: <Schema extends DatabaseSchema.AnyWithProps, Args, ConvexArgs extends DefaultFunctionArgs, Returns, ConvexReturns, E, R>({ args, returns, error, handler, createLayer, }: {
|
|
47
|
+
args: Schema.Schema<Args, ConvexArgs>;
|
|
48
|
+
returns: Schema.Schema<Returns, ConvexReturns>;
|
|
49
|
+
error: Schema.Schema<Error, Value> | undefined;
|
|
50
|
+
handler: (a: Args) => Effect.Effect<Returns, E, R>;
|
|
51
|
+
createLayer: (ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>) => Layer.Layer<R>;
|
|
69
52
|
}) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
53
|
+
args: import("convex/values").PropertyValidators;
|
|
54
|
+
returns: import("convex/values").Validator<any, any, any>;
|
|
55
|
+
handler: (ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>, actualArgs: ConvexArgs) => Promise<ConvexReturns>;
|
|
73
56
|
};
|
|
74
|
-
type ActionServices<DatabaseSchema_ extends AnyWithProps> = Scheduler
|
|
75
|
-
declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<(<Action extends
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
} |
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
57
|
+
export type ActionServices<DatabaseSchema_ extends DatabaseSchema.AnyWithProps> = Scheduler.Scheduler | Auth.Auth | StorageReader.StorageReader | StorageWriter.StorageWriter | StorageActionWriter.StorageActionWriter | QueryRunner.QueryRunner | MutationRunner.MutationRunner | ActionRunner.ActionRunner | VectorSearch.VectorSearch<DataModel.FromSchema<DatabaseSchema_>> | ActionCtx.ActionCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>;
|
|
58
|
+
export declare const actionLayer: <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>>) => Layer.Layer<(<Action extends import("@confect/core/Ref").AnyAction>(action: Action, ...args: import("@confect/core/Ref").OptionalArgs<Action>) => Effect.Effect<import("@confect/core/Ref").Returns<Action>, import("@confect/core/Ref").Error<Action> | import("effect/ParseResult").ParseError>) | Auth.Auth | (<Mutation extends import("@confect/core/Ref").AnyMutation>(mutation: Mutation, ...args: import("@confect/core/Ref").OptionalArgs<Mutation>) => Effect.Effect<import("@confect/core/Ref").Returns<Mutation>, import("@confect/core/Ref").Error<Mutation> | import("effect/ParseResult").ParseError>) | (<Query extends import("@confect/core/Ref").AnyQuery>(query: Query, ...args: import("@confect/core/Ref").OptionalArgs<Query>) => Effect.Effect<import("@confect/core/Ref").Returns<Query>, import("@confect/core/Ref").Error<Query> | import("effect/ParseResult").ParseError>) | {
|
|
59
|
+
runAfter: <Ref_ extends import("@confect/core/Ref").AnyMutation | import("@confect/core/Ref").AnyAction>(delay: import("effect/Duration").Duration, ref: Ref_, ...args: import("@confect/core/Ref").OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
|
|
60
|
+
runAt: <Ref_ extends import("@confect/core/Ref").AnyMutation | import("@confect/core/Ref").AnyAction>(dateTime: import("effect/DateTime").DateTime, ref: Ref_, ...args: import("@confect/core/Ref").OptionalArgs<Ref_>) => Effect.Effect<import("convex/values").GenericId<"_scheduled_functions">, never, never>;
|
|
61
|
+
} | StorageActionWriter.StorageActionWriter | StorageReader.StorageReader | StorageWriter.StorageWriter | GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>> | (<TableName extends DataModel.TableNames<DataModel.FromSchema<DatabaseSchema_>>, IndexName extends keyof import("convex/server").VectorIndexes<import("convex/server").NamedTableInfo<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>, TableName>>>(tableName: TableName, indexName: IndexName, query: {
|
|
62
|
+
vector: number[];
|
|
63
|
+
limit?: number;
|
|
64
|
+
filter?: (q: import("convex/server").VectorFilterBuilder<import("convex/server").DocumentByInfo<import("convex/server").NamedTableInfo<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>, TableName>>, import("convex/server").NamedVectorIndex<import("convex/server").NamedTableInfo<DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>, TableName>, IndexName>>) => import("convex/server").FilterExpression<boolean>;
|
|
82
65
|
}) => Effect.Effect<{
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
_id: import("convex/values").GenericId<TableName>;
|
|
67
|
+
_score: number;
|
|
85
68
|
}[], never, never>), never, never>;
|
|
86
|
-
|
|
87
|
-
export { ActionServices, Any, ConvexRegisteredFunction, RegisteredFunction, RegisteredFunction_d_exports, actionFunctionBase, actionLayer, runHandlerPromise };
|
|
69
|
+
export {};
|
|
88
70
|
//# sourceMappingURL=RegisteredFunction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunction.d.ts","
|
|
1
|
+
{"version":3,"file":"RegisteredFunction.d.ts","sourceRoot":"","sources":["../src/RegisteredFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,KAAK,KAAK,kBAAkB,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACrB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C,KAAK,CAAC,CAAC,CAAC,CAAC;CACrB;;;mBAIQ,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,cAC3D,UAAU,KACrB,OAAO,CAAC,aAAa,CAAC;CAYzB,CAAC;AAEH,MAAM,MAAM,cAAc,CACxB,eAAe,SAAS,cAAc,CAAC,YAAY,IAEjD,SAAS,CAAC,SAAS,GACnB,IAAI,CAAC,IAAI,GACT,aAAa,CAAC,aAAa,GAC3B,aAAa,CAAC,aAAa,GAC3B,mBAAmB,CAAC,mBAAmB,GACvC,WAAW,CAAC,WAAW,GACvB,cAAc,CAAC,cAAc,GAC7B,YAAY,CAAC,YAAY,GACzB,YAAY,CAAC,YAAY,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,GAChE,SAAS,CAAC,SAAS,CACjB,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAC1D,CAAC;AAEN,eAAO,MAAM,WAAW,GACtB,eAAe,SAAS,cAAc,CAAC,YAAY,EAEnD,gBAAgB,eAAe,EAC/B,KAAK,gBAAgB,CACnB,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAC1D;;;;;;;;;;kCAkBA,CAAC"}
|
|
@@ -6,9 +6,9 @@ import { compileArgsSchema, compileReturnsSchema } from "./SchemaToValidator.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
|
|
10
|
-
import { StorageReader
|
|
11
|
-
import { StorageWriter
|
|
9
|
+
import { StorageActionWriter } from "./StorageActionWriter.js";
|
|
10
|
+
import { StorageReader } from "./StorageReader.js";
|
|
11
|
+
import { StorageWriter } from "./StorageWriter.js";
|
|
12
12
|
import { layer as layer$5 } from "./VectorSearch.js";
|
|
13
13
|
import "convex/server";
|
|
14
14
|
import * as Layer from "effect/Layer";
|
|
@@ -56,7 +56,7 @@ const actionFunctionBase = ({ args, returns, error, handler, createLayer }) => (
|
|
|
56
56
|
return yield* pipe(yield* handler(yield* pipe(actualArgs, Schema.decode(args), Effect.orDie)).pipe(Effect.provide(createLayer(ctx))), Schema.encode(returns), Effect.orDie);
|
|
57
57
|
}).pipe(runHandlerPromise(error))
|
|
58
58
|
});
|
|
59
|
-
const actionLayer = (databaseSchema, ctx) => Layer.mergeAll(layer$4(ctx.scheduler), layer$1(ctx.auth), StorageReader
|
|
59
|
+
const actionLayer = (databaseSchema, ctx) => Layer.mergeAll(layer$4(ctx.scheduler), layer$1(ctx.auth), StorageReader.layer(ctx.storage), StorageWriter.layer(ctx.storage), StorageActionWriter.layer(ctx.storage), layer$3(ctx.runQuery), layer$2(ctx.runMutation), layer(ctx.runAction), layer$5(ctx.vectorSearch), Layer.succeed(ActionCtx(), ctx));
|
|
60
60
|
|
|
61
61
|
//#endregion
|
|
62
62
|
export { RegisteredFunction_exports, actionFunctionBase, actionLayer, runHandlerPromise };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","Scheduler.layer","Auth.layer","QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","VectorSearch.layer","ActionCtx.ActionCtx"],"sources":["../src/RegisteredFunction.ts"],"sourcesContent":["import type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport type * as FunctionProvenance from \"@confect/core/FunctionProvenance\";\nimport {\n type DefaultFunctionArgs,\n type FunctionVisibility,\n type GenericActionCtx,\n type RegisteredAction,\n type RegisteredMutation,\n type RegisteredQuery,\n} from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Effect from \"effect/Effect\";\nimport * as Either from \"effect/Either\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DataModel from \"./DataModel\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport * as StorageActionWriter from \"./StorageActionWriter\";\nimport * as StorageReader from \"./StorageReader\";\nimport * as StorageWriter from \"./StorageWriter\";\nimport * as VectorSearch from \"./VectorSearch\";\n\nexport type Any =\n | RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;\n\ntype ConfectRegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec.EncodedArgs<FunctionSpec_> extends infer Args_ extends\n DefaultFunctionArgs\n ? RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"query\"\n ? RegisteredQuery<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"mutation\"\n ? RegisteredMutation<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"action\"\n ? RegisteredAction<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : never\n : never;\n\nexport type ConvexRegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> = FunctionSpec_ extends {\n functionProvenance: {\n _tag: \"Convex\";\n _args: infer Args_ extends DefaultFunctionArgs;\n _returns: infer Returns_;\n };\n}\n ? RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"query\"\n ? RegisteredQuery<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"mutation\"\n ? RegisteredMutation<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"action\"\n ? RegisteredAction<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : never\n : never;\n\nexport type RegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRegisteredFunction<FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRegisteredFunction<FunctionSpec_>\n : never;\n\n/**\n * Run the `Effect` as a `Promise`. The error schema acts as an allowlist of\n * failures that may be surfaced to the client as a `ConvexError`:\n *\n * - With a schema: typed errors are schema-encoded and wrapped in a\n * `ConvexError`, then thrown so Convex surfaces the data to the client.\n * `Effect.either` escapes the failure channel before `runPromise` so the thrown\n * `ConvexError` retains its `Symbol.for(\"ConvexError\")` identity instead of\n * being wrapped in Effect's `FiberFailure`.\n *\n * - Without a schema: every failure is converted to a defect via\n * `Effect.orDie`, so nothing—not even a `ConvexError` the handler placed in its\n * error channel—reaches the client as a `ConvexError`. The fiber dies and\n * `runPromise` rejects with a generic failure.\n */\nexport const runHandlerPromise =\n (errorSchema: Schema.Schema.AnyNoContext | undefined) =>\n <A, E>(effect: Effect.Effect<A, E>): Promise<A> => {\n if (errorSchema === undefined) {\n return Effect.runPromise(Effect.orDie(effect));\n }\n const withConvexError = effect.pipe(\n Effect.catchAll((typedError) =>\n pipe(\n Schema.encode(errorSchema)(typedError),\n Effect.orDie,\n Effect.andThen((encodedError) =>\n Effect.fail(new ConvexError(encodedError)),\n ),\n ),\n ),\n );\n return Effect.runPromise(Effect.either(withConvexError)).then(\n Either.match({\n onLeft: (error) => {\n throw error;\n },\n onRight: (value) => value,\n }),\n );\n };\n\nexport const actionFunctionBase = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n R,\n>({\n args,\n returns,\n error,\n handler,\n createLayer,\n}: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\n handler: (a: Args) => Effect.Effect<Returns, E, R>;\n createLayer: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n ) => Layer.Layer<R>;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(createLayer(ctx)),\n );\n return yield* pipe(decodedReturns, Schema.encode(returns), Effect.orDie);\n }).pipe(runHandlerPromise(error)),\n});\n\nexport type ActionServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> =\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader.StorageReader\n | StorageWriter.StorageWriter\n | StorageActionWriter.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 const actionLayer = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n>(\n databaseSchema: DatabaseSchema_,\n ctx: GenericActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n) =>\n Layer.mergeAll(\n Scheduler.layer(ctx.scheduler),\n Auth.layer(ctx.auth),\n StorageReader.StorageReader.layer(ctx.storage),\n StorageWriter.StorageWriter.layer(ctx.storage),\n StorageActionWriter.StorageActionWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n ActionRunner.layer(ctx.runAction),\n VectorSearch.layer(ctx.vectorSearch),\n Layer.succeed(\n ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >(),\n ctx,\n ),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsIA,MAAa,qBACV,iBACM,WAA4C;AACjD,KAAI,gBAAgB,OAClB,QAAO,OAAO,WAAW,OAAO,MAAM,OAAO,CAAC;CAEhD,MAAM,kBAAkB,OAAO,KAC7B,OAAO,UAAU,eACf,KACE,OAAO,OAAO,YAAY,CAAC,WAAW,EACtC,OAAO,OACP,OAAO,SAAS,iBACd,OAAO,KAAK,IAAI,YAAY,aAAa,CAAC,CAC3C,CACF,CACF,CACF;AACD,QAAO,OAAO,WAAW,OAAO,OAAO,gBAAgB,CAAC,CAAC,KACvD,OAAO,MAAM;EACX,SAAS,UAAU;AACjB,SAAM;;EAER,UAAU,UAAU;EACrB,CAAC,CACH;;AAGL,MAAa,sBAQX,EACA,MACA,SACA,OACA,SACA,mBASK;CACL,MAAMA,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KACA,eAEA,OAAO,IAAI,aAAa;AAStB,SAAO,OAAO,KAHS,OAAO,QALV,OAAO,KACzB,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,MACR,CACiD,CAAC,KACjD,OAAO,QAAQ,YAAY,IAAI,CAAC,CACjC,EACkC,OAAO,OAAO,QAAQ,EAAE,OAAO,MAAM;GACxE,CAAC,KAAK,kBAAkB,MAAM,CAAC;CACpC;AAkBD,MAAa,eAGX,gBACA,QAIA,MAAM,SACJC,QAAgB,IAAI,UAAU,EAC9BC,QAAW,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"RegisteredFunction.js","names":["SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","Scheduler.layer","Auth.layer","QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","VectorSearch.layer","ActionCtx.ActionCtx"],"sources":["../src/RegisteredFunction.ts"],"sourcesContent":["import type { FunctionSpec, RuntimeAndFunctionType } from \"@confect/core\";\nimport type * as FunctionProvenance from \"@confect/core/FunctionProvenance\";\nimport {\n type DefaultFunctionArgs,\n type FunctionVisibility,\n type GenericActionCtx,\n type RegisteredAction,\n type RegisteredMutation,\n type RegisteredQuery,\n} from \"convex/server\";\nimport type { Value } from \"convex/values\";\nimport { ConvexError } from \"convex/values\";\nimport { pipe } from \"effect/Function\";\nimport * as Effect from \"effect/Effect\";\nimport * as Either from \"effect/Either\";\nimport * as Layer from \"effect/Layer\";\nimport * as Schema from \"effect/Schema\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DataModel from \"./DataModel\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport * as StorageActionWriter from \"./StorageActionWriter\";\nimport * as StorageReader from \"./StorageReader\";\nimport * as StorageWriter from \"./StorageWriter\";\nimport * as VectorSearch from \"./VectorSearch\";\n\nexport type Any =\n | RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;\n\ntype ConfectRegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec.EncodedArgs<FunctionSpec_> extends infer Args_ extends\n DefaultFunctionArgs\n ? RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"query\"\n ? RegisteredQuery<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"mutation\"\n ? RegisteredMutation<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"action\"\n ? RegisteredAction<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Promise<FunctionSpec.EncodedReturns<FunctionSpec_>>\n >\n : never\n : never;\n\nexport type ConvexRegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> = FunctionSpec_ extends {\n functionProvenance: {\n _tag: \"Convex\";\n _args: infer Args_ extends DefaultFunctionArgs;\n _returns: infer Returns_;\n };\n}\n ? RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"query\"\n ? RegisteredQuery<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"mutation\"\n ? RegisteredMutation<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n > extends \"action\"\n ? RegisteredAction<\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n Args_,\n Returns_\n >\n : never\n : never;\n\nexport type RegisteredFunction<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n> =\n FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConvex\n >\n ? ConvexRegisteredFunction<FunctionSpec_>\n : FunctionSpec_ extends FunctionSpec.WithFunctionProvenance<\n FunctionSpec_,\n FunctionProvenance.AnyConfect\n >\n ? ConfectRegisteredFunction<FunctionSpec_>\n : never;\n\n/**\n * Run the `Effect` as a `Promise`. The error schema acts as an allowlist of\n * failures that may be surfaced to the client as a `ConvexError`:\n *\n * - With a schema: typed errors are schema-encoded and wrapped in a\n * `ConvexError`, then thrown so Convex surfaces the data to the client.\n * `Effect.either` escapes the failure channel before `runPromise` so the thrown\n * `ConvexError` retains its `Symbol.for(\"ConvexError\")` identity instead of\n * being wrapped in Effect's `FiberFailure`.\n *\n * - Without a schema: every failure is converted to a defect via\n * `Effect.orDie`, so nothing—not even a `ConvexError` the handler placed in its\n * error channel—reaches the client as a `ConvexError`. The fiber dies and\n * `runPromise` rejects with a generic failure.\n */\nexport const runHandlerPromise =\n (errorSchema: Schema.Schema.AnyNoContext | undefined) =>\n <A, E>(effect: Effect.Effect<A, E>): Promise<A> => {\n if (errorSchema === undefined) {\n return Effect.runPromise(Effect.orDie(effect));\n }\n const withConvexError = effect.pipe(\n Effect.catchAll((typedError) =>\n pipe(\n Schema.encode(errorSchema)(typedError),\n Effect.orDie,\n Effect.andThen((encodedError) =>\n Effect.fail(new ConvexError(encodedError)),\n ),\n ),\n ),\n );\n return Effect.runPromise(Effect.either(withConvexError)).then(\n Either.match({\n onLeft: (error) => {\n throw error;\n },\n onRight: (value) => value,\n }),\n );\n };\n\nexport const actionFunctionBase = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n R,\n>({\n args,\n returns,\n error,\n handler,\n createLayer,\n}: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n error: Schema.Schema<Error, Value> | undefined;\n handler: (a: Args) => Effect.Effect<Returns, E, R>;\n createLayer: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n ) => Layer.Layer<R>;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n Effect.gen(function* () {\n const decodedArgs = yield* pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n );\n const decodedReturns = yield* handler(decodedArgs).pipe(\n Effect.provide(createLayer(ctx)),\n );\n return yield* pipe(decodedReturns, Schema.encode(returns), Effect.orDie);\n }).pipe(runHandlerPromise(error)),\n});\n\nexport type ActionServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> =\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader.StorageReader\n | StorageWriter.StorageWriter\n | StorageActionWriter.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 const actionLayer = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n>(\n databaseSchema: DatabaseSchema_,\n ctx: GenericActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n) =>\n Layer.mergeAll(\n Scheduler.layer(ctx.scheduler),\n Auth.layer(ctx.auth),\n StorageReader.StorageReader.layer(ctx.storage),\n StorageWriter.StorageWriter.layer(ctx.storage),\n StorageActionWriter.StorageActionWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n ActionRunner.layer(ctx.runAction),\n VectorSearch.layer(ctx.vectorSearch),\n Layer.succeed(\n ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >(),\n ctx,\n ),\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsIA,MAAa,qBACV,iBACM,WAA4C;AACjD,KAAI,gBAAgB,OAClB,QAAO,OAAO,WAAW,OAAO,MAAM,OAAO,CAAC;CAEhD,MAAM,kBAAkB,OAAO,KAC7B,OAAO,UAAU,eACf,KACE,OAAO,OAAO,YAAY,CAAC,WAAW,EACtC,OAAO,OACP,OAAO,SAAS,iBACd,OAAO,KAAK,IAAI,YAAY,aAAa,CAAC,CAC3C,CACF,CACF,CACF;AACD,QAAO,OAAO,WAAW,OAAO,OAAO,gBAAgB,CAAC,CAAC,KACvD,OAAO,MAAM;EACX,SAAS,UAAU;AACjB,SAAM;;EAER,UAAU,UAAU;EACrB,CAAC,CACH;;AAGL,MAAa,sBAQX,EACA,MACA,SACA,OACA,SACA,mBASK;CACL,MAAMA,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KACA,eAEA,OAAO,IAAI,aAAa;AAStB,SAAO,OAAO,KAHS,OAAO,QALV,OAAO,KACzB,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,MACR,CACiD,CAAC,KACjD,OAAO,QAAQ,YAAY,IAAI,CAAC,CACjC,EACkC,OAAO,OAAO,QAAQ,EAAE,OAAO,MAAM;GACxE,CAAC,KAAK,kBAAkB,MAAM,CAAC;CACpC;AAkBD,MAAa,eAGX,gBACA,QAIA,MAAM,SACJC,QAAgB,IAAI,UAAU,EAC9BC,QAAW,IAAI,KAAK,gBACQ,MAAM,IAAI,QAAQ,gBAClB,MAAM,IAAI,QAAQ,sBACN,MAAM,IAAI,QAAQ,EAC1DC,QAAkB,IAAI,SAAS,EAC/BC,QAAqB,IAAI,YAAY,EACrCC,MAAmB,IAAI,UAAU,EACjCC,QAAmB,IAAI,aAAa,EACpC,MAAM,QACJC,WAEG,EACH,IACD,CACF"}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
8
|
-
import * as
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> = Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;
|
|
15
|
-
type RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = { [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<Groups, GroupName> extends infer Group extends GroupSpec.AnyWithProps ? RegisteredFunctionsForGroupSpec<Group> : never };
|
|
1
|
+
import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
2
|
+
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
3
|
+
import type * as Spec from "@confect/core/Spec";
|
|
4
|
+
import type { Layer, Types } from "effect";
|
|
5
|
+
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
6
|
+
import type * as GroupImpl from "./GroupImpl";
|
|
7
|
+
import type * as RegisteredFunction from "./RegisteredFunction";
|
|
8
|
+
import * as RegistryItem from "./RegistryItem";
|
|
9
|
+
export type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> = Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;
|
|
10
|
+
type RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = {
|
|
11
|
+
[GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<Groups, GroupName> extends infer Group extends GroupSpec.AnyWithProps ? RegisteredFunctionsForGroupSpec<Group> : never;
|
|
12
|
+
};
|
|
16
13
|
/** The `RegisteredFunction` record for a group's own declared functions. */
|
|
17
|
-
type RegisteredFunctionsOf<Group extends GroupSpec.AnyWithProps> = {
|
|
14
|
+
type RegisteredFunctionsOf<Group extends GroupSpec.AnyWithProps> = {
|
|
15
|
+
[FunctionName in FunctionSpec.Name<GroupSpec.Functions<Group>>]: FunctionSpec.WithName<GroupSpec.Functions<Group>, FunctionName> extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps ? RegisteredFunction.RegisteredFunction<FunctionSpec_> : never;
|
|
16
|
+
};
|
|
18
17
|
/**
|
|
19
18
|
* The registered-functions record for a single group, derived from the group's
|
|
20
19
|
* own `GroupSpec`: its declared functions, plus any nested subgroups it carries
|
|
@@ -25,9 +24,9 @@ type RegisteredFunctionsOf<Group extends GroupSpec.AnyWithProps> = { [FunctionNa
|
|
|
25
24
|
* (subdirectory children are assembled separately into `_generated/spec.ts`),
|
|
26
25
|
* so this resolves to just the leaf's functions.
|
|
27
26
|
*/
|
|
28
|
-
type RegisteredFunctionsForGroupSpec<Group extends GroupSpec.AnyWithProps> = GroupSpec.Groups<Group> extends infer SubGroups extends GroupSpec.AnyWithProps ? Types.Simplify<RegisteredFunctionsHelper<SubGroups> & RegisteredFunctionsOf<Group>> : RegisteredFunctionsOf<Group>;
|
|
29
|
-
interface AnyWithProps {
|
|
30
|
-
|
|
27
|
+
export type RegisteredFunctionsForGroupSpec<Group extends GroupSpec.AnyWithProps> = GroupSpec.Groups<Group> extends infer SubGroups extends GroupSpec.AnyWithProps ? Types.Simplify<RegisteredFunctionsHelper<SubGroups> & RegisteredFunctionsOf<Group>> : RegisteredFunctionsOf<Group>;
|
|
28
|
+
export interface AnyWithProps {
|
|
29
|
+
readonly [key: string]: RegisteredFunction.Any | AnyWithProps;
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* Build the registered Convex functions for a single group from its finalized
|
|
@@ -51,7 +50,6 @@ interface AnyWithProps {
|
|
|
51
50
|
* the leaf spec type-only (`typeof import("…/<group>.spec")["default"]`), so a
|
|
52
51
|
* function's bundle never imports a spec module at runtime.
|
|
53
52
|
*/
|
|
54
|
-
declare const buildForGroup: <Group extends GroupSpec.AnyWithProps>(databaseSchema: AnyWithProps
|
|
55
|
-
|
|
56
|
-
export { AnyWithProps, RegisteredFunctions, RegisteredFunctionsForGroupSpec, RegisteredFunctions_d_exports, buildForGroup };
|
|
53
|
+
export declare const buildForGroup: <Group extends GroupSpec.AnyWithProps>(databaseSchema: DatabaseSchema.AnyWithProps, groupLayer: Layer.Layer<GroupImpl.GroupImpl<"Finalized">>, makeRegisteredFunction: (databaseSchema: DatabaseSchema.AnyWithProps, registryItem: RegistryItem.AnyWithProps) => RegisteredFunction.Any) => RegisteredFunctionsForGroupSpec<Group>;
|
|
54
|
+
export {};
|
|
57
55
|
//# sourceMappingURL=RegisteredFunctions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunctions.d.ts","
|
|
1
|
+
{"version":3,"file":"RegisteredFunctions.d.ts","sourceRoot":"","sources":["../src/RegisteredFunctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,KAAK,SAAS,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAG3C,OAAO,KAAK,KAAK,cAAc,MAAM,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B,CAAC,KAAK,CAAC,CAAC;AAEnC,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,kBAAkB,CAAC,GAAG,GAAG,YAAY,CAAC;CAC/D;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,SAAS,SAAS,CAAC,YAAY,EAChE,gBAAgB,cAAc,CAAC,YAAY,EAC3C,YAAY,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,EACzD,wBAAwB,CACtB,cAAc,EAAE,cAAc,CAAC,YAAY,EAC3C,YAAY,EAAE,YAAY,CAAC,YAAY,KACpC,kBAAkB,CAAC,GAAG,KAC1B,+BAA+B,CAAC,KAAK,CAkBvC,CAAC"}
|
|
@@ -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: (databaseSchema: AnyWithProps, {
|
|
10
|
-
functionSpec,
|
|
11
|
-
handler
|
|
12
|
-
}: AnyWithProps$1) => 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"}
|
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"}
|