@gaganref/confect-server 10.3.1-fork.2 → 10.3.1-fork.21

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.
Files changed (220) hide show
  1. package/dist/ActionCtx.d.ts +1 -1
  2. package/dist/ActionCtx.d.ts.map +1 -1
  3. package/dist/ActionCtx.js.map +1 -1
  4. package/dist/AiGatewayDecisionClient.d.ts +2 -2
  5. package/dist/AiGatewayDecisionClient.d.ts.map +1 -1
  6. package/dist/AiGatewayDecisionClient.js.map +1 -1
  7. package/dist/AiGatewayLanguageClient.d.ts +2 -2
  8. package/dist/AiGatewayLanguageClient.d.ts.map +1 -1
  9. package/dist/AiGatewayLanguageClient.js.map +1 -1
  10. package/dist/Auth.d.ts +1 -1
  11. package/dist/Auth.d.ts.map +1 -1
  12. package/dist/Auth.js.map +1 -1
  13. package/dist/ComponentCtx.d.ts +1 -1
  14. package/dist/ComponentCtx.d.ts.map +1 -1
  15. package/dist/ConvexFunctionDefinitions.d.ts +4 -4
  16. package/dist/ConvexFunctionDefinitions.d.ts.map +1 -1
  17. package/dist/ConvexFunctionDefinitions.js.map +1 -1
  18. package/dist/CronJobs.d.ts +1 -1
  19. package/dist/CronJobs.d.ts.map +1 -1
  20. package/dist/CronJobs.js.map +1 -1
  21. package/dist/DataModel.d.ts +3 -3
  22. package/dist/DataModel.d.ts.map +1 -1
  23. package/dist/DataModel.js.map +1 -1
  24. package/dist/DatabaseReader.d.ts +4 -4
  25. package/dist/DatabaseReader.d.ts.map +1 -1
  26. package/dist/DatabaseReader.js.map +1 -1
  27. package/dist/DatabaseSchema.d.ts +1 -1
  28. package/dist/DatabaseSchema.d.ts.map +1 -1
  29. package/dist/DatabaseSchema.js.map +1 -1
  30. package/dist/DatabaseWriter.d.ts +5 -5
  31. package/dist/DatabaseWriter.d.ts.map +1 -1
  32. package/dist/DatabaseWriter.js +23 -3
  33. package/dist/DatabaseWriter.js.map +1 -1
  34. package/dist/Document.d.ts +4 -4
  35. package/dist/Document.d.ts.map +1 -1
  36. package/dist/Document.js.map +1 -1
  37. package/dist/FunctionImpl.d.ts +2 -2
  38. package/dist/FunctionImpl.d.ts.map +1 -1
  39. package/dist/FunctionImpl.js.map +1 -1
  40. package/dist/FunctionRegistryItem.d.ts +1 -1
  41. package/dist/FunctionRegistryItem.d.ts.map +1 -1
  42. package/dist/FunctionRegistryItem.js.map +1 -1
  43. package/dist/GroupImpl.d.ts +24 -5
  44. package/dist/GroupImpl.d.ts.map +1 -1
  45. package/dist/GroupImpl.js +17 -18
  46. package/dist/GroupImpl.js.map +1 -1
  47. package/dist/GroupRegistry.d.ts +2 -2
  48. package/dist/GroupRegistry.d.ts.map +1 -1
  49. package/dist/GroupRegistry.js.map +1 -1
  50. package/dist/Handler.d.ts +23 -23
  51. package/dist/Handler.d.ts.map +1 -1
  52. package/dist/Handler.js.map +1 -1
  53. package/dist/HttpRouter.d.ts +13 -13
  54. package/dist/HttpRouter.d.ts.map +1 -1
  55. package/dist/HttpRouter.js.map +1 -1
  56. package/dist/MiddlewareImpl.d.ts +14 -14
  57. package/dist/MiddlewareImpl.d.ts.map +1 -1
  58. package/dist/MiddlewareImpl.js.map +1 -1
  59. package/dist/MutationCtx.d.ts +1 -1
  60. package/dist/MutationCtx.d.ts.map +1 -1
  61. package/dist/MutationCtx.js.map +1 -1
  62. package/dist/MutationRunner.d.ts +1 -1
  63. package/dist/MutationRunner.d.ts.map +1 -1
  64. package/dist/MutationRunner.js.map +1 -1
  65. package/dist/MutationTransactionContext.d.ts +2 -2
  66. package/dist/MutationTransactionContext.d.ts.map +1 -1
  67. package/dist/MutationTransactionContext.js.map +1 -1
  68. package/dist/OfficialComponent.d.ts +50 -0
  69. package/dist/OfficialComponent.d.ts.map +1 -0
  70. package/dist/OfficialComponent.js +70 -0
  71. package/dist/OfficialComponent.js.map +1 -0
  72. package/dist/OrderedQuery.d.ts +4 -4
  73. package/dist/OrderedQuery.d.ts.map +1 -1
  74. package/dist/OrderedQuery.js.map +1 -1
  75. package/dist/QueryCtx.d.ts +1 -1
  76. package/dist/QueryCtx.d.ts.map +1 -1
  77. package/dist/QueryCtx.js.map +1 -1
  78. package/dist/QueryInitializer.d.ts +10 -10
  79. package/dist/QueryInitializer.d.ts.map +1 -1
  80. package/dist/QueryInitializer.js.map +1 -1
  81. package/dist/QueryRunner.d.ts +2 -2
  82. package/dist/QueryRunner.d.ts.map +1 -1
  83. package/dist/QueryRunner.js.map +1 -1
  84. package/dist/QueryStream.d.ts +11 -11
  85. package/dist/QueryStream.d.ts.map +1 -1
  86. package/dist/QueryStream.js.map +1 -1
  87. package/dist/QueryStreamCursor.d.ts +2 -2
  88. package/dist/QueryStreamCursor.d.ts.map +1 -1
  89. package/dist/QueryStreamCursor.js.map +1 -1
  90. package/dist/QueryStreamIndexPrefix.d.ts +2 -2
  91. package/dist/QueryStreamIndexPrefix.d.ts.map +1 -1
  92. package/dist/QueryStreamIndexPrefix.js.map +1 -1
  93. package/dist/QueryStreamIndexRange.d.ts +4 -4
  94. package/dist/QueryStreamIndexRange.d.ts.map +1 -1
  95. package/dist/QueryStreamIndexRange.js.map +1 -1
  96. package/dist/QueryStreamKey.d.ts +2 -2
  97. package/dist/QueryStreamKey.d.ts.map +1 -1
  98. package/dist/QueryStreamKey.js.map +1 -1
  99. package/dist/QueryStreamKeyBounds.d.ts +3 -3
  100. package/dist/QueryStreamKeyBounds.d.ts.map +1 -1
  101. package/dist/QueryStreamKeyBounds.js.map +1 -1
  102. package/dist/QueryStreamKeyLayout.d.ts +1 -1
  103. package/dist/QueryStreamKeyLayout.d.ts.map +1 -1
  104. package/dist/QueryStreamKeyLayout.js.map +1 -1
  105. package/dist/QueryStreamKeyValues.d.ts +1 -1
  106. package/dist/QueryStreamKeyValues.d.ts.map +1 -1
  107. package/dist/QueryStreamKeyValues.js.map +1 -1
  108. package/dist/QueryStreamPagination.d.ts +1 -1
  109. package/dist/QueryStreamPagination.d.ts.map +1 -1
  110. package/dist/QueryStreamPagination.js.map +1 -1
  111. package/dist/RegisteredConvexFunction.d.ts +20 -20
  112. package/dist/RegisteredConvexFunction.d.ts.map +1 -1
  113. package/dist/RegisteredConvexFunction.js.map +1 -1
  114. package/dist/RegisteredFunction.d.ts +26 -26
  115. package/dist/RegisteredFunction.d.ts.map +1 -1
  116. package/dist/RegisteredFunction.js.map +1 -1
  117. package/dist/RegisteredFunctions.d.ts +3 -3
  118. package/dist/RegisteredFunctions.d.ts.map +1 -1
  119. package/dist/RegisteredFunctions.js.map +1 -1
  120. package/dist/RegisteredNodeFunction.d.ts +6 -6
  121. package/dist/RegisteredNodeFunction.d.ts.map +1 -1
  122. package/dist/RegisteredNodeFunction.js.map +1 -1
  123. package/dist/Registry.d.ts +1 -1
  124. package/dist/Registry.d.ts.map +1 -1
  125. package/dist/Registry.js.map +1 -1
  126. package/dist/RegistryItems.d.ts +7 -0
  127. package/dist/RegistryItems.d.ts.map +1 -1
  128. package/dist/RegistryItems.js +7 -2
  129. package/dist/RegistryItems.js.map +1 -1
  130. package/dist/ResolvedMiddleware.d.ts +2 -2
  131. package/dist/ResolvedMiddleware.d.ts.map +1 -1
  132. package/dist/ResolvedMiddleware.js.map +1 -1
  133. package/dist/Storage.d.ts +6 -6
  134. package/dist/Storage.d.ts.map +1 -1
  135. package/dist/Storage.js.map +1 -1
  136. package/dist/StorageActionWriter.d.ts +1 -1
  137. package/dist/StorageActionWriter.d.ts.map +1 -1
  138. package/dist/StorageActionWriter.js.map +1 -1
  139. package/dist/StorageReader.d.ts +1 -1
  140. package/dist/StorageReader.d.ts.map +1 -1
  141. package/dist/StorageReader.js.map +1 -1
  142. package/dist/StorageWriter.d.ts +1 -1
  143. package/dist/StorageWriter.d.ts.map +1 -1
  144. package/dist/StorageWriter.js.map +1 -1
  145. package/dist/TableInfo.d.ts +2 -2
  146. package/dist/TableInfo.d.ts.map +1 -1
  147. package/dist/TableInfo.js.map +1 -1
  148. package/dist/VectorSearch.d.ts +1 -1
  149. package/dist/VectorSearch.d.ts.map +1 -1
  150. package/dist/VectorSearch.js.map +1 -1
  151. package/dist/index.d.ts +61 -60
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +2 -1
  154. package/dist/internal/AiGatewayDecisionClient.d.ts +1 -1
  155. package/dist/internal/AiGatewayDecisionClient.d.ts.map +1 -1
  156. package/dist/internal/AiGatewayDecisionClient.js.map +1 -1
  157. package/dist/internal/AiGatewayLanguageClient.d.ts +1 -1
  158. package/dist/internal/AiGatewayLanguageClient.d.ts.map +1 -1
  159. package/dist/internal/AiGatewayLanguageClient.js.map +1 -1
  160. package/dist/internal/DocumentPatch.d.ts +16 -0
  161. package/dist/internal/DocumentPatch.d.ts.map +1 -0
  162. package/dist/internal/DocumentPatch.js +36 -0
  163. package/dist/internal/DocumentPatch.js.map +1 -0
  164. package/dist/node.d.ts +1 -1
  165. package/dist/node.d.ts.map +1 -1
  166. package/package.json +2 -2
  167. package/src/ActionCtx.ts +1 -1
  168. package/src/AiGatewayDecisionClient.ts +3 -3
  169. package/src/AiGatewayLanguageClient.ts +3 -3
  170. package/src/Auth.ts +1 -1
  171. package/src/ComponentCtx.ts +1 -1
  172. package/src/ConvexFunctionDefinitions.ts +8 -8
  173. package/src/CronJobs.ts +1 -1
  174. package/src/DataModel.ts +3 -3
  175. package/src/DatabaseReader.ts +4 -4
  176. package/src/DatabaseSchema.ts +1 -1
  177. package/src/DatabaseWriter.ts +100 -27
  178. package/src/Document.ts +4 -4
  179. package/src/FunctionImpl.ts +5 -5
  180. package/src/FunctionRegistryItem.ts +1 -1
  181. package/src/GroupImpl.ts +66 -13
  182. package/src/GroupRegistry.ts +4 -4
  183. package/src/Handler.ts +23 -23
  184. package/src/HttpRouter.ts +17 -17
  185. package/src/MiddlewareImpl.ts +17 -17
  186. package/src/MutationCtx.ts +1 -1
  187. package/src/MutationRunner.ts +1 -1
  188. package/src/MutationTransactionContext.ts +2 -2
  189. package/src/OfficialComponent.ts +151 -0
  190. package/src/OrderedQuery.ts +4 -4
  191. package/src/QueryCtx.ts +1 -1
  192. package/src/QueryInitializer.ts +9 -9
  193. package/src/QueryRunner.ts +2 -2
  194. package/src/QueryStream.ts +15 -15
  195. package/src/QueryStreamCursor.ts +3 -3
  196. package/src/QueryStreamIndexPrefix.ts +2 -2
  197. package/src/QueryStreamIndexRange.ts +4 -4
  198. package/src/QueryStreamKey.ts +2 -2
  199. package/src/QueryStreamKeyBounds.ts +3 -3
  200. package/src/QueryStreamKeyLayout.ts +1 -1
  201. package/src/QueryStreamKeyValues.ts +1 -1
  202. package/src/QueryStreamPagination.ts +2 -2
  203. package/src/RegisteredConvexFunction.ts +21 -21
  204. package/src/RegisteredFunction.ts +18 -18
  205. package/src/RegisteredFunctions.ts +4 -4
  206. package/src/RegisteredNodeFunction.ts +8 -8
  207. package/src/Registry.ts +1 -1
  208. package/src/RegistryItems.ts +33 -2
  209. package/src/ResolvedMiddleware.ts +2 -2
  210. package/src/Storage.ts +3 -3
  211. package/src/StorageActionWriter.ts +1 -1
  212. package/src/StorageReader.ts +1 -1
  213. package/src/StorageWriter.ts +1 -1
  214. package/src/TableInfo.ts +2 -2
  215. package/src/VectorSearch.ts +1 -1
  216. package/src/index.ts +61 -60
  217. package/src/internal/AiGatewayDecisionClient.ts +2 -2
  218. package/src/internal/AiGatewayLanguageClient.ts +2 -2
  219. package/src/internal/DocumentPatch.ts +87 -0
  220. package/src/node.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"HttpRouter.js","names":["RegisteredFunction.baseActionLayer","RegisteredFunction.actionLayer","ConvexLogger.layer","ConvexConfigProvider.layer","layer"],"sources":["../src/HttpRouter.ts"],"sourcesContent":["import {\n type HttpRouter as ConvexHttpRouter,\n httpActionGeneric,\n httpRouter,\n ROUTABLE_HTTP_METHODS,\n type RouteSpecWithPathPrefix,\n type GenericActionCtx,\n type GenericDataModel,\n} from \"convex/server\";\nimport * as Array from \"effect/Array\";\nimport * as Console from \"effect/Console\";\nimport * as Context from \"effect/Context\";\nimport * as Config from \"effect/Config\";\nimport * as Effect from \"effect/Effect\";\nimport type * as FileSystem from \"effect/FileSystem\";\nimport * as Layer from \"effect/Layer\";\nimport * as Match from \"effect/Match\";\nimport type * as Path from \"effect/Path\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport * as FindMyWay from \"effect/http/FindMyWay\";\nimport * as HttpApi from \"effect/http-api/HttpApi\";\nimport type * as HttpApiGroup from \"effect/http-api/HttpApiGroup\";\nimport type * as Etag from \"effect/http/Etag\";\nimport type * as HttpPlatform from \"effect/http/HttpPlatform\";\nimport * as HttpRouter from \"effect/http/HttpRouter\";\nimport * as HttpServer from \"effect/http/HttpServer\";\nimport type * as ActionRunner from \"./ActionRunner\";\nimport type * as Auth from \"./Auth\";\nimport type { ExecutionMetadata } from \"./ExecutionMetadata\";\nimport type { RequestMetadata } from \"./RequestMetadata\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DataModel from \"./DataModel\";\nimport type * as Handler from \"./Handler\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider\";\nimport * as ConvexLogger from \"./ConvexLogger\";\nimport type * as MutationRunner from \"./MutationRunner\";\nimport type * as QueryRunner from \"./QueryRunner\";\nimport * as RegisteredFunction from \"./RegisteredFunction\";\nimport type * as Scheduler from \"./Scheduler\";\nimport type { Storage } from \"./Storage\";\nimport type { StorageActionWriter } from \"./StorageActionWriter\";\nimport type { StorageReader } from \"./StorageReader\";\nimport type { StorageWriter } from \"./StorageWriter\";\n\n/**\n * The Confect services available to HTTP route handlers and middleware,\n * supplied per request from the Convex action context.\n */\nexport type Services =\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | ExecutionMetadata\n | RequestMetadata\n | Storage\n | StorageReader\n | StorageWriter\n | StorageActionWriter;\n\n/**\n * A layer that registers routes on the HTTP router—the input to {@link make}.\n *\n * Compose it from Effect's `effect/http` and `effect/http-api` modules:\n * `HttpApiBuilder.layer(api)` registers an `HttpApi`'s endpoints (provide its\n * group handler layers with `Layer.provide`), `HttpApiScalar.layer(api, ...)`\n * serves interactive API docs, `HttpRouter.add` registers a plain route, and\n * `HttpRouter.middleware(fn, { global: true })` applies middleware to every\n * route. Merge any number of these with `Layer.mergeAll`.\n *\n * Route handlers and middleware may require any of the Confect {@link Services},\n * which surface as request-level `Requires` markers and are supplied per\n * request. Anything else the layer requires is a type error—notably, an\n * `HttpApiBuilder.layer(api)` whose group handler layers are not provided\n * leaves an `HttpApiGroup.ToService` requirement behind, so a missing handler\n * group is caught at compile time.\n *\n * Layers are built with Confect's Convex-aware `ConfigProvider` in context, so\n * `Config` reads (e.g. in `Layer.unwrap`) resolve against Convex environment\n * variables.\n */\nexport type Routes<Services_ = Services> = Layer.Layer<\n never,\n never,\n | HttpRouter.HttpRouter\n | Etag.Generator\n | FileSystem.FileSystem\n | HttpPlatform.HttpPlatform\n | Path.Path\n | HttpRouter.Request<\"Requires\", Services_>\n | HttpRouter.Request<\"GlobalRequires\", Services_>\n | HttpRouter.Request<\"Error\", any>\n | HttpRouter.Request<\"GlobalError\", any>\n>;\n\n/**\n * Create a Convex HTTP router serving the given routes.\n *\n * A single catch-all `httpAction` is registered for every routable method under\n * the path prefix `\"/\"`, making the Effect router the single source of truth\n * for paths: place an API with `HttpApi.prefix` or absolute route paths.\n * Requests that match no route receive the Effect router's 404 response.\n *\n * Supply `{ api }` with the `HttpApi` registered by the routes layer to show\n * endpoint patterns in Convex completion logs and the dashboard. Requests that\n * match no reflected endpoint keep the catch-all completion label. Without the\n * option, Convex reports the catch-all registrations. Application endpoints\n * must not overlap component HTTP mounts: Convex also uses dashboard route\n * entries to select between application and component routers.\n *\n * Plain Convex routes can still be added to the returned router—Convex matches\n * exact paths first and longer path prefixes before the catch-all, so they take\n * precedence.\n */\nexport const make = <Id extends string, Groups extends HttpApiGroup.Constraint>(\n routes: Routes,\n options?: { readonly api?: HttpApi.HttpApi<Id, Groups> | undefined },\n): ConvexHttpRouter =>\n makeWithLayer(routes, RegisteredFunction.baseActionLayer, options?.api);\n\n/**\n * Derive HTTP capabilities and ID scopes from the generated database schema.\n * Component routes are relative to their installation's HTTP mount prefix.\n * Supply `{ api }` as in {@link make}; labels stay component-relative.\n */\nexport const forSchema =\n <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n schema: DatabaseSchema_,\n ) =>\n <Id extends string, Groups extends HttpApiGroup.Constraint>(\n routes: Routes<Handler.ActionServices<DatabaseSchema_>>,\n options?: { readonly api?: HttpApi.HttpApi<Id, Groups> | undefined },\n ): ConvexHttpRouter =>\n makeWithLayer<\n Handler.ActionServices<DatabaseSchema_>,\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>,\n Id,\n Groups\n >(\n Match.value(schema.target.kind).pipe(\n Match.when(\"app\", () => routes),\n Match.when(\"component\", () =>\n routes.pipe(Layer.provide(componentRouter)),\n ),\n Match.exhaustive,\n ),\n (ctx) => RegisteredFunction.actionLayer(schema, ctx),\n options?.api,\n );\n\n// Convex uses a component-relative path to select its HTTP action but passes\n// the original request URL to that action. Its CONVEX_SITE_URL includes the\n// installation's full mount prefix (including parent mounts). Prefixing the\n// Effect router preserves relative routes without rewriting the Request body.\nconst componentRouter = Layer.effect(\n HttpRouter.HttpRouter,\n Effect.gen(function* () {\n const router = yield* HttpRouter.HttpRouter;\n const siteUrl = yield* Config.schema(\n Schema.URLFromString,\n \"CONVEX_SITE_URL\",\n );\n return router.prefixed(siteUrl.pathname);\n }).pipe(Effect.orDie),\n);\n\nconst makeWithLayer = <\n Services_,\n DataModel_ extends GenericDataModel,\n Id extends string,\n Groups extends HttpApiGroup.Constraint,\n>(\n routes: Routes<Services_>,\n layer: (ctx: GenericActionCtx<DataModel_>) => Layer.Layer<Services_>,\n api: HttpApi.HttpApi<Id, Groups> | undefined,\n): ConvexHttpRouter => {\n applyMonkeyPatches();\n\n // Provided (not just merged) so that route layers' own construction—e.g.\n // a `Layer.unwrap` reading `Config`—resolves configuration through the\n // Convex-aware provider; merged so that request fibers—endpoint handlers\n // and middleware—do too.\n const AppLayer = routes.pipe(\n Layer.provideMerge(ConvexLogger.layer),\n Layer.provideMerge(ConvexConfigProvider.layer),\n Layer.provide(HttpServer.layerServices),\n );\n\n // The Confect service requirements of route handlers and middleware surface\n // as request-level `Requires` markers on the layer, which the web handler\n // exposes as a per-request context argument.\n const { handler } = HttpRouter.toWebHandler(AppLayer, {\n disableLogger: true,\n });\n\n const httpAction = httpActionGeneric((ctx, request): Promise<Response> => {\n // The ctx-backed service layers are all synchronous and finalizer-free,\n // so the scope can close as soon as the context is built.\n // Convex's HTTP registration erases the data model. The supplied generated\n // schema restores it; this does not change the runtime context or services.\n const services = Effect.runSync(\n Effect.scoped(\n Layer.build(layer(ctx as unknown as GenericActionCtx<DataModel_>)),\n ),\n );\n return handler(\n request,\n Context.add(services, Console.Console, globalThis.console),\n );\n });\n\n const convexHttpRouter = httpRouter();\n\n Array.forEach(ROUTABLE_HTTP_METHODS, (method) => {\n const routeSpec: RouteSpecWithPathPrefix = {\n pathPrefix: \"/\",\n method,\n handler: httpAction,\n };\n convexHttpRouter.route(routeSpec);\n });\n\n if (api !== undefined) {\n const matcher = FindMyWay.make<string>();\n const reflected: ReturnType<ConvexHttpRouter[\"getRoutes\"]> = [];\n HttpApi.reflect(api, {\n onGroup: () => {},\n onEndpoint: ({ endpoint }) => {\n const method = ROUTABLE_HTTP_METHODS.find(\n (candidate) => candidate === endpoint.method,\n );\n if (method === undefined) return;\n const path = apiRouterPath(\n endpoint.path as FindMyWay.PathInput,\n endpoint.params,\n );\n matcher.on(method, path, endpoint.path);\n // Effect also matches a wildcard route's base path without its slash.\n if (path.endsWith(\"/*\")) {\n matcher.on(method, path.slice(0, -2) as `/${string}`, endpoint.path);\n }\n reflected.push([endpoint.path, method, httpAction]);\n },\n });\n reflected.sort(\n ([pathA, methodA], [pathB, methodB]) =>\n pathA.localeCompare(pathB) || methodA.localeCompare(methodB),\n );\n\n const getRoutes = convexHttpRouter.getRoutes;\n convexHttpRouter.getRoutes = () =>\n reflected.length === 0\n ? getRoutes()\n : [\n ...getRoutes().filter(([, , action]) => action !== httpAction),\n ...reflected,\n ];\n const lookup = convexHttpRouter.lookup;\n convexHttpRouter.lookup = (path, method) => {\n const match = lookup(path, method);\n if (match === null || match[0] !== httpAction) return match;\n const normalized = match[1];\n const reflectedPath = matcher.find(normalized, path)?.handler;\n return reflectedPath === undefined\n ? match\n : [httpAction, normalized, reflectedPath];\n };\n }\n\n return convexHttpRouter;\n};\n\n/*!\n * apiRouterPath is adapted from Effect 4.0.1 http-api/internal/path.ts.\n *\n * MIT License\n *\n * Copyright (c) 2023 Effectful Technologies Inc\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n// Match Effect's HttpApiBuilder path normalization, which is not publicly\n// exported (effect/http-api/internal/path.ts). Undeclared colons are literals;\n// declared params followed by a literal suffix need an explicit regex boundary.\nconst apiRouterPath = (\n path: FindMyWay.PathInput,\n params: Schema.Top | undefined,\n): FindMyWay.PathInput => {\n if (params === undefined || !path.includes(\":\")) return path;\n let ast = params.ast;\n while (ast.encoding !== undefined) {\n ast = ast.encoding[ast.encoding.length - 1].to;\n }\n if (!SchemaAST.isObjects(ast) || ast.indexSignatures.length !== 0)\n return path;\n const names = new Set(\n ast.propertySignatures.map((property) => String(property.name)),\n );\n let normalized = \"\";\n let depth = 0;\n let regexStart = -1;\n for (let i = 0; i < path.length; i++) {\n const char = path[i];\n if (depth > 0 || i === regexStart) {\n normalized += char;\n if (char === \"\\\\\") normalized += path[++i] ?? \"\";\n else if (char === \"(\") depth++;\n else if (char === \")\") depth--;\n } else if (char !== \":\") {\n normalized += char;\n } else if (path[i + 1] === \":\") {\n normalized += \"::\";\n i++;\n } else {\n const param = /^:(\\w+)/.exec(path.slice(i));\n if (param !== null && names.has(param[1])) {\n normalized += param[0];\n i += param[0].length - 1;\n const next = path[i + 1];\n if (next === \"(\") regexStart = i + 1;\n else if (next !== undefined && !\"/.-?\".includes(next))\n normalized += \"(.*?)\";\n } else {\n normalized += \"::\";\n }\n }\n }\n return normalized as FindMyWay.PathInput;\n};\n\n// These are necessary until the Convex runtime supports these APIs. See\n// https://discord.com/channels/1019350475847499849/1281364098419785760\n// Each patch is applied only where the API is actually broken, so runtimes\n// with working implementations—Node under convex-test, notably, where\n// `new AbortSignal()` is an illegal constructor—keep their native behavior.\nconst applyMonkeyPatches = () => {\n const urlCredentialsBroken = (() => {\n try {\n return new URL(\"https://confect.dev\").username === undefined;\n } catch {\n return true;\n }\n })();\n if (urlCredentialsBroken) {\n URL = class extends URL {\n override get username() {\n return \"\";\n }\n override get password() {\n return \"\";\n }\n };\n }\n\n const requestSignalBroken = (() => {\n try {\n return new Request(\"https://confect.dev\").signal === undefined;\n } catch {\n return true;\n }\n })();\n if (requestSignalBroken) {\n // `configurable` so repeated definition—e.g. module re-evaluation in a\n // long-lived environment—does not throw.\n Object.defineProperty(Request.prototype, \"signal\", {\n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EACjC,IAAI;GACF,OAAO,IAAI,QAAQ,qBAAqB,CAAC,CAAC,WAAW,KAAA;EACvD,QAAQ;GACN,OAAO;EACT;CACF,EAAA,CACsB,GAGpB,OAAO,eAAe,QAAQ,WAAW,UAAU;EACjD,WAAW,IAAI,YAAY;EAC3B,cAAc;CAChB,CAAC;AAEL"}
1
+ {"version":3,"file":"HttpRouter.js","names":["RegisteredFunction.baseActionLayer","RegisteredFunction.actionLayer","ConvexLogger.layer","ConvexConfigProvider.layer","layer"],"sources":["../src/HttpRouter.ts"],"sourcesContent":["import {\n type HttpRouter as ConvexHttpRouter,\n httpActionGeneric,\n httpRouter,\n ROUTABLE_HTTP_METHODS,\n type RouteSpecWithPathPrefix,\n type GenericActionCtx,\n type GenericDataModel,\n} from \"convex/server\";\nimport * as Array from \"effect/Array\";\nimport * as Console from \"effect/Console\";\nimport * as Context from \"effect/Context\";\nimport * as Config from \"effect/Config\";\nimport * as Effect from \"effect/Effect\";\nimport type * as FileSystem from \"effect/FileSystem\";\nimport * as Layer from \"effect/Layer\";\nimport * as Match from \"effect/Match\";\nimport type * as Path from \"effect/Path\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaAST from \"effect/SchemaAST\";\nimport * as FindMyWay from \"effect/http/FindMyWay\";\nimport * as HttpApi from \"effect/http-api/HttpApi\";\nimport type * as HttpApiGroup from \"effect/http-api/HttpApiGroup\";\nimport type * as Etag from \"effect/http/Etag\";\nimport type * as HttpPlatform from \"effect/http/HttpPlatform\";\nimport * as HttpRouter from \"effect/http/HttpRouter\";\nimport * as HttpServer from \"effect/http/HttpServer\";\nimport type * as ActionRunner from \"./ActionRunner.js\";\nimport type * as Auth from \"./Auth.js\";\nimport type { ExecutionMetadata } from \"./ExecutionMetadata.js\";\nimport type { RequestMetadata } from \"./RequestMetadata.js\";\nimport type * as DatabaseSchema from \"./DatabaseSchema.js\";\nimport type * as DataModel from \"./DataModel.js\";\nimport type * as Handler from \"./Handler.js\";\nimport * as ConvexConfigProvider from \"./ConvexConfigProvider.js\";\nimport * as ConvexLogger from \"./ConvexLogger.js\";\nimport type * as MutationRunner from \"./MutationRunner.js\";\nimport type * as QueryRunner from \"./QueryRunner.js\";\nimport * as RegisteredFunction from \"./RegisteredFunction.js\";\nimport type * as Scheduler from \"./Scheduler.js\";\nimport type { Storage } from \"./Storage.js\";\nimport type { StorageActionWriter } from \"./StorageActionWriter.js\";\nimport type { StorageReader } from \"./StorageReader.js\";\nimport type { StorageWriter } from \"./StorageWriter.js\";\n\n/**\n * The Confect services available to HTTP route handlers and middleware,\n * supplied per request from the Convex action context.\n */\nexport type Services =\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | ExecutionMetadata\n | RequestMetadata\n | Storage\n | StorageReader\n | StorageWriter\n | StorageActionWriter;\n\n/**\n * A layer that registers routes on the HTTP router—the input to {@link make}.\n *\n * Compose it from Effect's `effect/http` and `effect/http-api` modules:\n * `HttpApiBuilder.layer(api)` registers an `HttpApi`'s endpoints (provide its\n * group handler layers with `Layer.provide`), `HttpApiScalar.layer(api, ...)`\n * serves interactive API docs, `HttpRouter.add` registers a plain route, and\n * `HttpRouter.middleware(fn, { global: true })` applies middleware to every\n * route. Merge any number of these with `Layer.mergeAll`.\n *\n * Route handlers and middleware may require any of the Confect {@link Services},\n * which surface as request-level `Requires` markers and are supplied per\n * request. Anything else the layer requires is a type error—notably, an\n * `HttpApiBuilder.layer(api)` whose group handler layers are not provided\n * leaves an `HttpApiGroup.ToService` requirement behind, so a missing handler\n * group is caught at compile time.\n *\n * Layers are built with Confect's Convex-aware `ConfigProvider` in context, so\n * `Config` reads (e.g. in `Layer.unwrap`) resolve against Convex environment\n * variables.\n */\nexport type Routes<Services_ = Services> = Layer.Layer<\n never,\n never,\n | HttpRouter.HttpRouter\n | Etag.Generator\n | FileSystem.FileSystem\n | HttpPlatform.HttpPlatform\n | Path.Path\n | HttpRouter.Request<\"Requires\", Services_>\n | HttpRouter.Request<\"GlobalRequires\", Services_>\n | HttpRouter.Request<\"Error\", any>\n | HttpRouter.Request<\"GlobalError\", any>\n>;\n\n/**\n * Create a Convex HTTP router serving the given routes.\n *\n * A single catch-all `httpAction` is registered for every routable method under\n * the path prefix `\"/\"`, making the Effect router the single source of truth\n * for paths: place an API with `HttpApi.prefix` or absolute route paths.\n * Requests that match no route receive the Effect router's 404 response.\n *\n * Supply `{ api }` with the `HttpApi` registered by the routes layer to show\n * endpoint patterns in Convex completion logs and the dashboard. Requests that\n * match no reflected endpoint keep the catch-all completion label. Without the\n * option, Convex reports the catch-all registrations. Application endpoints\n * must not overlap component HTTP mounts: Convex also uses dashboard route\n * entries to select between application and component routers.\n *\n * Plain Convex routes can still be added to the returned router—Convex matches\n * exact paths first and longer path prefixes before the catch-all, so they take\n * precedence.\n */\nexport const make = <Id extends string, Groups extends HttpApiGroup.Constraint>(\n routes: Routes,\n options?: { readonly api?: HttpApi.HttpApi<Id, Groups> | undefined },\n): ConvexHttpRouter =>\n makeWithLayer(routes, RegisteredFunction.baseActionLayer, options?.api);\n\n/**\n * Derive HTTP capabilities and ID scopes from the generated database schema.\n * Component routes are relative to their installation's HTTP mount prefix.\n * Supply `{ api }` as in {@link make}; labels stay component-relative.\n */\nexport const forSchema =\n <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n schema: DatabaseSchema_,\n ) =>\n <Id extends string, Groups extends HttpApiGroup.Constraint>(\n routes: Routes<Handler.ActionServices<DatabaseSchema_>>,\n options?: { readonly api?: HttpApi.HttpApi<Id, Groups> | undefined },\n ): ConvexHttpRouter =>\n makeWithLayer<\n Handler.ActionServices<DatabaseSchema_>,\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>,\n Id,\n Groups\n >(\n Match.value(schema.target.kind).pipe(\n Match.when(\"app\", () => routes),\n Match.when(\"component\", () =>\n routes.pipe(Layer.provide(componentRouter)),\n ),\n Match.exhaustive,\n ),\n (ctx) => RegisteredFunction.actionLayer(schema, ctx),\n options?.api,\n );\n\n// Convex uses a component-relative path to select its HTTP action but passes\n// the original request URL to that action. Its CONVEX_SITE_URL includes the\n// installation's full mount prefix (including parent mounts). Prefixing the\n// Effect router preserves relative routes without rewriting the Request body.\nconst componentRouter = Layer.effect(\n HttpRouter.HttpRouter,\n Effect.gen(function* () {\n const router = yield* HttpRouter.HttpRouter;\n const siteUrl = yield* Config.schema(\n Schema.URLFromString,\n \"CONVEX_SITE_URL\",\n );\n return router.prefixed(siteUrl.pathname);\n }).pipe(Effect.orDie),\n);\n\nconst makeWithLayer = <\n Services_,\n DataModel_ extends GenericDataModel,\n Id extends string,\n Groups extends HttpApiGroup.Constraint,\n>(\n routes: Routes<Services_>,\n layer: (ctx: GenericActionCtx<DataModel_>) => Layer.Layer<Services_>,\n api: HttpApi.HttpApi<Id, Groups> | undefined,\n): ConvexHttpRouter => {\n applyMonkeyPatches();\n\n // Provided (not just merged) so that route layers' own construction—e.g.\n // a `Layer.unwrap` reading `Config`—resolves configuration through the\n // Convex-aware provider; merged so that request fibers—endpoint handlers\n // and middleware—do too.\n const AppLayer = routes.pipe(\n Layer.provideMerge(ConvexLogger.layer),\n Layer.provideMerge(ConvexConfigProvider.layer),\n Layer.provide(HttpServer.layerServices),\n );\n\n // The Confect service requirements of route handlers and middleware surface\n // as request-level `Requires` markers on the layer, which the web handler\n // exposes as a per-request context argument.\n const { handler } = HttpRouter.toWebHandler(AppLayer, {\n disableLogger: true,\n });\n\n const httpAction = httpActionGeneric((ctx, request): Promise<Response> => {\n // The ctx-backed service layers are all synchronous and finalizer-free,\n // so the scope can close as soon as the context is built.\n // Convex's HTTP registration erases the data model. The supplied generated\n // schema restores it; this does not change the runtime context or services.\n const services = Effect.runSync(\n Effect.scoped(\n Layer.build(layer(ctx as unknown as GenericActionCtx<DataModel_>)),\n ),\n );\n return handler(\n request,\n Context.add(services, Console.Console, globalThis.console),\n );\n });\n\n const convexHttpRouter = httpRouter();\n\n Array.forEach(ROUTABLE_HTTP_METHODS, (method) => {\n const routeSpec: RouteSpecWithPathPrefix = {\n pathPrefix: \"/\",\n method,\n handler: httpAction,\n };\n convexHttpRouter.route(routeSpec);\n });\n\n if (api !== undefined) {\n const matcher = FindMyWay.make<string>();\n const reflected: ReturnType<ConvexHttpRouter[\"getRoutes\"]> = [];\n HttpApi.reflect(api, {\n onGroup: () => {},\n onEndpoint: ({ endpoint }) => {\n const method = ROUTABLE_HTTP_METHODS.find(\n (candidate) => candidate === endpoint.method,\n );\n if (method === undefined) return;\n const path = apiRouterPath(\n endpoint.path as FindMyWay.PathInput,\n endpoint.params,\n );\n matcher.on(method, path, endpoint.path);\n // Effect also matches a wildcard route's base path without its slash.\n if (path.endsWith(\"/*\")) {\n matcher.on(method, path.slice(0, -2) as `/${string}`, endpoint.path);\n }\n reflected.push([endpoint.path, method, httpAction]);\n },\n });\n reflected.sort(\n ([pathA, methodA], [pathB, methodB]) =>\n pathA.localeCompare(pathB) || methodA.localeCompare(methodB),\n );\n\n const getRoutes = convexHttpRouter.getRoutes;\n convexHttpRouter.getRoutes = () =>\n reflected.length === 0\n ? getRoutes()\n : [\n ...getRoutes().filter(([, , action]) => action !== httpAction),\n ...reflected,\n ];\n const lookup = convexHttpRouter.lookup;\n convexHttpRouter.lookup = (path, method) => {\n const match = lookup(path, method);\n if (match === null || match[0] !== httpAction) return match;\n const normalized = match[1];\n const reflectedPath = matcher.find(normalized, path)?.handler;\n return reflectedPath === undefined\n ? match\n : [httpAction, normalized, reflectedPath];\n };\n }\n\n return convexHttpRouter;\n};\n\n/*!\n * apiRouterPath is adapted from Effect 4.0.1 http-api/internal/path.ts.\n *\n * MIT License\n *\n * Copyright (c) 2023 Effectful Technologies Inc\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n// Match Effect's HttpApiBuilder path normalization, which is not publicly\n// exported (effect/http-api/internal/path.ts). Undeclared colons are literals;\n// declared params followed by a literal suffix need an explicit regex boundary.\nconst apiRouterPath = (\n path: FindMyWay.PathInput,\n params: Schema.Top | undefined,\n): FindMyWay.PathInput => {\n if (params === undefined || !path.includes(\":\")) return path;\n let ast = params.ast;\n while (ast.encoding !== undefined) {\n ast = ast.encoding[ast.encoding.length - 1].to;\n }\n if (!SchemaAST.isObjects(ast) || ast.indexSignatures.length !== 0)\n return path;\n const names = new Set(\n ast.propertySignatures.map((property) => String(property.name)),\n );\n let normalized = \"\";\n let depth = 0;\n let regexStart = -1;\n for (let i = 0; i < path.length; i++) {\n const char = path[i];\n if (depth > 0 || i === regexStart) {\n normalized += char;\n if (char === \"\\\\\") normalized += path[++i] ?? \"\";\n else if (char === \"(\") depth++;\n else if (char === \")\") depth--;\n } else if (char !== \":\") {\n normalized += char;\n } else if (path[i + 1] === \":\") {\n normalized += \"::\";\n i++;\n } else {\n const param = /^:(\\w+)/.exec(path.slice(i));\n if (param !== null && names.has(param[1])) {\n normalized += param[0];\n i += param[0].length - 1;\n const next = path[i + 1];\n if (next === \"(\") regexStart = i + 1;\n else if (next !== undefined && !\"/.-?\".includes(next))\n normalized += \"(.*?)\";\n } else {\n normalized += \"::\";\n }\n }\n }\n return normalized as FindMyWay.PathInput;\n};\n\n// These are necessary until the Convex runtime supports these APIs. See\n// https://discord.com/channels/1019350475847499849/1281364098419785760\n// Each patch is applied only where the API is actually broken, so runtimes\n// with working implementations—Node under convex-test, notably, where\n// `new AbortSignal()` is an illegal constructor—keep their native behavior.\nconst applyMonkeyPatches = () => {\n const urlCredentialsBroken = (() => {\n try {\n return new URL(\"https://confect.dev\").username === undefined;\n } catch {\n return true;\n }\n })();\n if (urlCredentialsBroken) {\n URL = class extends URL {\n override get username() {\n return \"\";\n }\n override get password() {\n return \"\";\n }\n };\n }\n\n const requestSignalBroken = (() => {\n try {\n return new Request(\"https://confect.dev\").signal === undefined;\n } catch {\n return true;\n }\n })();\n if (requestSignalBroken) {\n // `configurable` so repeated definition—e.g. module re-evaluation in a\n // long-lived environment—does not throw.\n Object.defineProperty(Request.prototype, \"signal\", {\n get: () => new AbortSignal(),\n configurable: true,\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHA,MAAa,QACX,QACA,YAEA,cAAc,QAAQA,iBAAoC,SAAS,GAAG;;;;;;AAOxE,MAAa,aAET,YAGA,QACA,YAEA,cAME,MAAM,MAAM,OAAO,OAAO,IAAI,CAAC,CAAC,KAC9B,MAAM,KAAK,aAAa,MAAM,GAC9B,MAAM,KAAK,mBACT,OAAO,KAAK,MAAM,QAAQ,eAAe,CAAC,CAC5C,GACA,MAAM,UACR,IACC,QAAQC,YAA+B,QAAQ,GAAG,GACnD,SAAS,GACX;AAMJ,MAAM,kBAAkB,MAAM,OAC5B,WAAW,YACX,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,OAAO,WAAW;CACjC,MAAM,UAAU,OAAO,OAAO,OAC5B,OAAO,eACP,iBACF;CACA,OAAO,OAAO,SAAS,QAAQ,QAAQ;AACzC,CAAC,CAAC,CAAC,KAAK,OAA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L,MAAM,QAAQ,UAAU,KAAK,KAAK,MAAM,CAAC,CAAC;GAC1C,IAAI,UAAU,QAAQ,MAAM,IAAI,MAAM,EAAE,GAAG;IACzC,cAAc,MAAM;IACpB,KAAK,MAAM,EAAE,CAAC,SAAS;IACvB,MAAM,OAAO,KAAK,IAAI;IACtB,IAAI,SAAS,KAAK,aAAa,IAAI;SAC9B,IAAI,SAAS,KAAA,KAAa,CAAC,OAAO,SAAS,IAAI,GAClD,cAAc;GAClB,OACE,cAAc;EAElB;CACF;CACA,OAAO;AACT;AAOA,MAAM,2BAA2B;CAQ/B,WAPoC;EAClC,IAAI;GACF,OAAO,IAAI,IAAI,qBAAqB,CAAC,CAAC,aAAa,KAAA;EACrD,QAAQ;GACN,OAAO;EACT;CACF,EAAA,CACuB,GACrB,MAAM,cAAc,IAAI;EACtB,IAAa,WAAW;GACtB,OAAO;EACT;EACA,IAAa,WAAW;GACtB,OAAO;EACT;CACF;CAUF,WAPmC;EACjC,IAAI;GACF,OAAO,IAAI,QAAQ,qBAAqB,CAAC,CAAC,WAAW,KAAA;EACvD,QAAQ;GACN,OAAO;EACT;CACF,EAAA,CACsB,GAGpB,OAAO,eAAe,QAAQ,WAAW,UAAU;EACjD,WAAW,IAAI,YAAY;EAC3B,cAAc;CAChB,CAAC;AAEL"}
@@ -5,20 +5,20 @@ import type { FunctionType } from "convex/server";
5
5
  import * as Context from "effect/Context";
6
6
  import * as Effect from "effect/Effect";
7
7
  import * as Layer from "effect/Layer";
8
- import type * as Auth from "./Auth";
9
- import type * as DatabaseReader from "./DatabaseReader";
10
- import type * as DatabaseSchema from "./DatabaseSchema";
11
- import type * as Handler from "./Handler";
12
- import type { ExecutionMetadata } from "./ExecutionMetadata";
13
- import type { RequestMetadata } from "./RequestMetadata";
14
- import type { TransactionMetadata } from "./TransactionMetadata";
15
- import type * as MutationRunner from "./MutationRunner";
16
- import type * as QueryRunner from "./QueryRunner";
17
- import type { QueryTransactionContext } from "./QueryTransactionContext";
18
- import type * as Scheduler from "./Scheduler";
19
- import type { Storage } from "./Storage";
20
- import type * as StorageReader from "./StorageReader";
21
- import type * as StorageWriter from "./StorageWriter";
8
+ import type * as Auth from "./Auth.js";
9
+ import type * as DatabaseReader from "./DatabaseReader.js";
10
+ import type * as DatabaseSchema from "./DatabaseSchema.js";
11
+ import type * as Handler from "./Handler.js";
12
+ import type { ExecutionMetadata } from "./ExecutionMetadata.js";
13
+ import type { RequestMetadata } from "./RequestMetadata.js";
14
+ import type { TransactionMetadata } from "./TransactionMetadata.js";
15
+ import type * as MutationRunner from "./MutationRunner.js";
16
+ import type * as QueryRunner from "./QueryRunner.js";
17
+ import type { QueryTransactionContext } from "./QueryTransactionContext.js";
18
+ import type * as Scheduler from "./Scheduler.js";
19
+ import type { Storage } from "./Storage.js";
20
+ import type * as StorageReader from "./StorageReader.js";
21
+ import type * as StorageWriter from "./StorageWriter.js";
22
22
  /**
23
23
  * Marker service produced by providing a middleware's implementation to a
24
24
  * group's impl layer. `GroupImpl.make` requires one per middleware attached to
@@ -1 +1 @@
1
- {"version":3,"file":"MiddlewareImpl.d.ts","sourceRoot":"","sources":["../src/MiddlewareImpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,YAAY,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,KAAK,SAAS,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,cAAc,MAAM,8BAA8B,CAAC;AAE/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,KAAK,KAAK,IAAI,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACxD,OAAO,KA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GAAG,CAAC,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,UACzD,MAAM,CAAC,MAAM,CACnB,KAAK,EACL,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC,EACnC,cAAc,CACZ,eAAe,EACf,cAAc,CAAC,aAAa,CAAC,eAAe,CAAC,CAC9C,GACD,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,CAC3C,KACA,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAEE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MiddlewareImpl.js","names":["Registry.Registry","MiddlewareRegistryItem.registryKey","MiddlewareRegistryItem.TypeId"],"sources":["../src/MiddlewareImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as MiddlewareSpec from \"@confect/core/MiddlewareSpec\";\nimport * as Registry from \"./Registry\";\nimport type { FunctionType } from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Ref from \"effect/Ref\";\nimport type * as Auth from \"./Auth\";\nimport type * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as Handler from \"./Handler\";\nimport type { ExecutionMetadata } from \"./ExecutionMetadata\";\nimport type { RequestMetadata } from \"./RequestMetadata\";\nimport type { TransactionMetadata } from \"./TransactionMetadata\";\nimport type * as MutationRunner from \"./MutationRunner\";\nimport type * as QueryRunner from \"./QueryRunner\";\nimport type { QueryTransactionContext } from \"./QueryTransactionContext\";\nimport type * as Scheduler from \"./Scheduler\";\nimport type { Storage } from \"./Storage\";\nimport type * as StorageReader from \"./StorageReader\";\nimport type * as StorageWriter from \"./StorageWriter\";\nimport * as MiddlewareRegistryItem from \"./MiddlewareRegistryItem\";\nimport { setNestedProperty } from \"./internal/utils\";\n\n/**\n * Marker service produced by providing a middleware's implementation to a\n * group's impl layer. `GroupImpl.make` requires one per middleware attached to\n * the group's spec (via {@link FromGroupSpec}), so `GroupImpl.finalize`'s `RIn =\n * never` bound rejects a group that attaches a middleware but never provides\n * its implementation—the exact mechanism used for `FunctionImpl`s.\n */\nexport interface MiddlewareImpl<MiddlewareKey extends string> {\n readonly middlewareKey: MiddlewareKey;\n}\n\nexport const MiddlewareImpl = <MiddlewareKey extends string>({\n middlewareKey,\n}: {\n middlewareKey: MiddlewareKey;\n}) =>\n Context.Service<MiddlewareImpl<MiddlewareKey>>(\n `@confect/server/MiddlewareImpl/${middlewareKey}`,\n );\n\nexport type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =\n | GroupSpec.MiddlewareSpecs<Group>\n | FunctionSpec.MiddlewareSpecs<\n GroupSpec.Functions<Group>\n > extends infer MiddlewareSpec_\n ? MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec\n ? MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>\n : never\n : never;\n\nexport type FunctionTypeServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionType_ extends FunctionType,\n> = FunctionType_ extends \"query\"\n ? Handler.QueryServices<DatabaseSchema_>\n : FunctionType_ extends \"mutation\"\n ? Handler.MutationServices<DatabaseSchema_>\n : FunctionType_ extends \"action\"\n ? Handler.ActionServices<DatabaseSchema_>\n : never;\n\n/**\n * The services a single middleware implementation may use: the set-theoretic\n * intersection of the ctx-service unions of the middleware's declared\n * `functionTypes`, so one implementation is valid in every runtime it can be\n * invoked in. Enumerated by hand rather than derived with\n * `Exclude`/`Extract`—several ctx services are structurally typed (e.g. the raw\n * `GenericQueryCtx`/`GenericMutationCtx` tags), so conditional-type set\n * arithmetic over them is not reliable.\n */\nexport type CommonServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionTypes extends FunctionType,\n> = [FunctionTypes] extends [\"query\"]\n ? Handler.QueryServices<DatabaseSchema_>\n : [FunctionTypes] extends [\"mutation\"]\n ? Handler.MutationServices<DatabaseSchema_>\n : [FunctionTypes] extends [\"action\"]\n ? Handler.ActionServices<DatabaseSchema_>\n : [FunctionTypes] extends [\"query\" | \"mutation\"]\n ? QueryMutationCommonServices<DatabaseSchema_>\n : [FunctionTypes] extends [\"mutation\" | \"action\"]\n ? MutationActionCommonServices\n : AllFunctionTypesCommonServices;\n\ntype QueryMutationCommonServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> =\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | ExecutionMetadata\n | TransactionMetadata\n | QueryTransactionContext\n | Storage\n | StorageReader.StorageReader\n | QueryRunner.QueryRunner;\n\ntype MutationActionCommonServices =\n | Auth.Auth\n | ExecutionMetadata\n | RequestMetadata\n | Scheduler.Scheduler\n | Storage\n | StorageReader.StorageReader\n | StorageWriter.StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner;\n\ntype AllFunctionTypesCommonServices =\n | Auth.Auth\n | ExecutionMetadata\n | Storage\n | StorageReader.StorageReader\n | QueryRunner.QueryRunner;\n\nconst layerFromImpls = <\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec,\n>(\n middlewareSpec: MiddlewareSpec_,\n impls: MiddlewareRegistryItem.MiddlewareRegistryItem[\"impls\"],\n): Layer.Layer<MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>> =>\n Layer.effect(\n MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>({\n middlewareKey: middlewareSpec.key,\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n\n yield* Ref.update(registry, (registryItems) =>\n setNestedProperty(\n registryItems,\n [MiddlewareRegistryItem.registryKey(middlewareSpec.key)],\n {\n [MiddlewareRegistryItem.TypeId]: MiddlewareRegistryItem.TypeId,\n middlewareSpec,\n impls,\n } satisfies MiddlewareRegistryItem.MiddlewareRegistryItem,\n ),\n );\n\n return { middlewareKey: middlewareSpec.key };\n }),\n );\n\n/**\n * Provide a middleware's implementation with a single strategy shared by every\n * function type the middleware declares. The implementation's environment is\n * bounded by {@link CommonServices}—the intersection of the declared\n * functionTypes' ctx services—plus the middleware's declared `requires`, which\n * middleware running earlier in the chain provide. Reach for\n * {@link makeByFunctionType} when one strategy can't fit all declared\n * functionTypes (the usual case for database-touching middleware attached to\n * actions).\n *\n * Like `FunctionImpl.make`, `databaseSchema` is a type-level carrier only.\n */\nexport const make = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec,\n>(\n _databaseSchema: DatabaseSchema_,\n middlewareSpec: MiddlewareSpec_,\n impl: MiddlewareSpec.MiddlewareImpl<\n MiddlewareSpec.Provides<MiddlewareSpec_>,\n MiddlewareSpec.Error<MiddlewareSpec_>,\n | CommonServices<\n DatabaseSchema_,\n MiddlewareSpec.FunctionTypes<MiddlewareSpec_>\n >\n | MiddlewareSpec.Requires<MiddlewareSpec_>,\n MiddlewareSpec.Options<MiddlewareSpec_>\n >,\n): Layer.Layer<MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>> =>\n layerFromImpls(\n middlewareSpec,\n Object.fromEntries(\n MiddlewareSpec.allFunctionTypes\n .filter((functionType) => middlewareSpec.functionTypes[functionType])\n .map((functionType) => [\n functionType,\n impl as MiddlewareSpec.AnyMiddlewareImpl,\n ]),\n ),\n );\n\n/**\n * Provide a middleware's implementation with one strategy per declared function\n * type. Each entry may use that function type's full ctx-service union—the\n * recommended shape for database-touching middleware that also covers actions:\n * use `DatabaseReader`/`DatabaseWriter` in queries and mutations, and\n * `runQuery` of an internal query in actions.\n */\nexport const makeByFunctionType = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec,\n>(\n _databaseSchema: DatabaseSchema_,\n middlewareSpec: MiddlewareSpec_,\n impls: {\n readonly [\n FunctionType_ in MiddlewareSpec.FunctionTypes<MiddlewareSpec_>\n ]: MiddlewareSpec.MiddlewareImpl<\n MiddlewareSpec.Provides<MiddlewareSpec_>,\n MiddlewareSpec.Error<MiddlewareSpec_>,\n | FunctionTypeServices<DatabaseSchema_, FunctionType_>\n | MiddlewareSpec.Requires<MiddlewareSpec_>,\n MiddlewareSpec.Options<MiddlewareSpec_>\n >;\n },\n): Layer.Layer<MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>> =>\n layerFromImpls(\n middlewareSpec,\n impls as MiddlewareRegistryItem.MiddlewareRegistryItem[\"impls\"],\n );\n\n/**\n * Sugar over {@link make} for the flagship \"run something, provide a service\"\n * shape: run `effect` before the rest of the chain and provide its result under\n * `tag` (the runtime tag for the middleware's type-level `provides` service,\n * passed explicitly since the spec class only knows it at the type level).\n */\nexport const provides = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Shape,\n>(\n databaseSchema: DatabaseSchema_,\n middlewareSpec: MiddlewareSpec_,\n tag: Context.Key<MiddlewareSpec.Provides<MiddlewareSpec_>, Shape>,\n effect: Effect.Effect<\n Shape,\n MiddlewareSpec.Error<MiddlewareSpec_>,\n | CommonServices<\n DatabaseSchema_,\n MiddlewareSpec.FunctionTypes<MiddlewareSpec_>\n >\n | MiddlewareSpec.Requires<MiddlewareSpec_>\n >,\n): Layer.Layer<MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>> =>\n make(databaseSchema, middlewareSpec, ((handlerEffect: Effect.Effect<any>) =>\n Effect.provideServiceEffect(handlerEffect, tag, effect)) as any);\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,kBAAgD,EAC3D,oBAIA,QAAQ,QACN,kCAAkC,eACpC;AA6EF,MAAM,kBAGJ,gBACA,UAEA,MAAM,OACJ,eAAoD,EAClD,eAAe,eAAe,IAChC,CAAC,GACD,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAOA;CAExB,OAAO,IAAI,OAAO,WAAW,kBAC3B,kBACE,eACA,CAACC,YAAmC,eAAe,GAAG,CAAC,GACvD;GACGC,SAAgCA;EACjC;EACA;CACF,CACF,CACF;CAEA,OAAO,EAAE,eAAe,eAAe,IAAI;AAC7C,CAAC,CACH;;;;;;;;;;;;;AAcF,MAAa,QAIX,iBACA,gBACA,SAWA,eACE,gBACA,OAAO,YACL,eAAe,iBACZ,QAAQ,iBAAiB,eAAe,cAAc,aAAa,CAAC,CACpE,KAAK,iBAAiB,CACrB,cACA,IACF,CAAC,CACL,CACF;;;;;;;;AASF,MAAa,sBAIX,iBACA,gBACA,UAYA,eACE,gBACA,KACF;;;;;;;AAQF,MAAa,YAKX,gBACA,gBACA,KACA,WAUA,KAAK,gBAAgB,kBAAkB,kBACrC,OAAO,qBAAqB,eAAe,KAAK,MAAM,EAAS"}
1
+ {"version":3,"file":"MiddlewareImpl.js","names":["Registry.Registry","MiddlewareRegistryItem.registryKey","MiddlewareRegistryItem.TypeId"],"sources":["../src/MiddlewareImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as MiddlewareSpec from \"@confect/core/MiddlewareSpec\";\nimport * as Registry from \"./Registry.js\";\nimport type { FunctionType } from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Ref from \"effect/Ref\";\nimport type * as Auth from \"./Auth.js\";\nimport type * as DatabaseReader from \"./DatabaseReader.js\";\nimport type * as DatabaseSchema from \"./DatabaseSchema.js\";\nimport type * as Handler from \"./Handler.js\";\nimport type { ExecutionMetadata } from \"./ExecutionMetadata.js\";\nimport type { RequestMetadata } from \"./RequestMetadata.js\";\nimport type { TransactionMetadata } from \"./TransactionMetadata.js\";\nimport type * as MutationRunner from \"./MutationRunner.js\";\nimport type * as QueryRunner from \"./QueryRunner.js\";\nimport type { QueryTransactionContext } from \"./QueryTransactionContext.js\";\nimport type * as Scheduler from \"./Scheduler.js\";\nimport type { Storage } from \"./Storage.js\";\nimport type * as StorageReader from \"./StorageReader.js\";\nimport type * as StorageWriter from \"./StorageWriter.js\";\nimport * as MiddlewareRegistryItem from \"./MiddlewareRegistryItem.js\";\nimport { setNestedProperty } from \"./internal/utils.js\";\n\n/**\n * Marker service produced by providing a middleware's implementation to a\n * group's impl layer. `GroupImpl.make` requires one per middleware attached to\n * the group's spec (via {@link FromGroupSpec}), so `GroupImpl.finalize`'s `RIn =\n * never` bound rejects a group that attaches a middleware but never provides\n * its implementation—the exact mechanism used for `FunctionImpl`s.\n */\nexport interface MiddlewareImpl<MiddlewareKey extends string> {\n readonly middlewareKey: MiddlewareKey;\n}\n\nexport const MiddlewareImpl = <MiddlewareKey extends string>({\n middlewareKey,\n}: {\n middlewareKey: MiddlewareKey;\n}) =>\n Context.Service<MiddlewareImpl<MiddlewareKey>>(\n `@confect/server/MiddlewareImpl/${middlewareKey}`,\n );\n\nexport type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =\n | GroupSpec.MiddlewareSpecs<Group>\n | FunctionSpec.MiddlewareSpecs<\n GroupSpec.Functions<Group>\n > extends infer MiddlewareSpec_\n ? MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec\n ? MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>\n : never\n : never;\n\nexport type FunctionTypeServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionType_ extends FunctionType,\n> = FunctionType_ extends \"query\"\n ? Handler.QueryServices<DatabaseSchema_>\n : FunctionType_ extends \"mutation\"\n ? Handler.MutationServices<DatabaseSchema_>\n : FunctionType_ extends \"action\"\n ? Handler.ActionServices<DatabaseSchema_>\n : never;\n\n/**\n * The services a single middleware implementation may use: the set-theoretic\n * intersection of the ctx-service unions of the middleware's declared\n * `functionTypes`, so one implementation is valid in every runtime it can be\n * invoked in. Enumerated by hand rather than derived with\n * `Exclude`/`Extract`—several ctx services are structurally typed (e.g. the raw\n * `GenericQueryCtx`/`GenericMutationCtx` tags), so conditional-type set\n * arithmetic over them is not reliable.\n */\nexport type CommonServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n FunctionTypes extends FunctionType,\n> = [FunctionTypes] extends [\"query\"]\n ? Handler.QueryServices<DatabaseSchema_>\n : [FunctionTypes] extends [\"mutation\"]\n ? Handler.MutationServices<DatabaseSchema_>\n : [FunctionTypes] extends [\"action\"]\n ? Handler.ActionServices<DatabaseSchema_>\n : [FunctionTypes] extends [\"query\" | \"mutation\"]\n ? QueryMutationCommonServices<DatabaseSchema_>\n : [FunctionTypes] extends [\"mutation\" | \"action\"]\n ? MutationActionCommonServices\n : AllFunctionTypesCommonServices;\n\ntype QueryMutationCommonServices<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> =\n | DatabaseReader.DatabaseReader<DatabaseSchema_>\n | Auth.Auth\n | ExecutionMetadata\n | TransactionMetadata\n | QueryTransactionContext\n | Storage\n | StorageReader.StorageReader\n | QueryRunner.QueryRunner;\n\ntype MutationActionCommonServices =\n | Auth.Auth\n | ExecutionMetadata\n | RequestMetadata\n | Scheduler.Scheduler\n | Storage\n | StorageReader.StorageReader\n | StorageWriter.StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner;\n\ntype AllFunctionTypesCommonServices =\n | Auth.Auth\n | ExecutionMetadata\n | Storage\n | StorageReader.StorageReader\n | QueryRunner.QueryRunner;\n\nconst layerFromImpls = <\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec,\n>(\n middlewareSpec: MiddlewareSpec_,\n impls: MiddlewareRegistryItem.MiddlewareRegistryItem[\"impls\"],\n): Layer.Layer<MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>> =>\n Layer.effect(\n MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>({\n middlewareKey: middlewareSpec.key,\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n\n yield* Ref.update(registry, (registryItems) =>\n setNestedProperty(\n registryItems,\n [MiddlewareRegistryItem.registryKey(middlewareSpec.key)],\n {\n [MiddlewareRegistryItem.TypeId]: MiddlewareRegistryItem.TypeId,\n middlewareSpec,\n impls,\n } satisfies MiddlewareRegistryItem.MiddlewareRegistryItem,\n ),\n );\n\n return { middlewareKey: middlewareSpec.key };\n }),\n );\n\n/**\n * Provide a middleware's implementation with a single strategy shared by every\n * function type the middleware declares. The implementation's environment is\n * bounded by {@link CommonServices}—the intersection of the declared\n * functionTypes' ctx services—plus the middleware's declared `requires`, which\n * middleware running earlier in the chain provide. Reach for\n * {@link makeByFunctionType} when one strategy can't fit all declared\n * functionTypes (the usual case for database-touching middleware attached to\n * actions).\n *\n * Like `FunctionImpl.make`, `databaseSchema` is a type-level carrier only.\n */\nexport const make = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec,\n>(\n _databaseSchema: DatabaseSchema_,\n middlewareSpec: MiddlewareSpec_,\n impl: MiddlewareSpec.MiddlewareImpl<\n MiddlewareSpec.Provides<MiddlewareSpec_>,\n MiddlewareSpec.Error<MiddlewareSpec_>,\n | CommonServices<\n DatabaseSchema_,\n MiddlewareSpec.FunctionTypes<MiddlewareSpec_>\n >\n | MiddlewareSpec.Requires<MiddlewareSpec_>,\n MiddlewareSpec.Options<MiddlewareSpec_>\n >,\n): Layer.Layer<MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>> =>\n layerFromImpls(\n middlewareSpec,\n Object.fromEntries(\n MiddlewareSpec.allFunctionTypes\n .filter((functionType) => middlewareSpec.functionTypes[functionType])\n .map((functionType) => [\n functionType,\n impl as MiddlewareSpec.AnyMiddlewareImpl,\n ]),\n ),\n );\n\n/**\n * Provide a middleware's implementation with one strategy per declared function\n * type. Each entry may use that function type's full ctx-service union—the\n * recommended shape for database-touching middleware that also covers actions:\n * use `DatabaseReader`/`DatabaseWriter` in queries and mutations, and\n * `runQuery` of an internal query in actions.\n */\nexport const makeByFunctionType = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec,\n>(\n _databaseSchema: DatabaseSchema_,\n middlewareSpec: MiddlewareSpec_,\n impls: {\n readonly [\n FunctionType_ in MiddlewareSpec.FunctionTypes<MiddlewareSpec_>\n ]: MiddlewareSpec.MiddlewareImpl<\n MiddlewareSpec.Provides<MiddlewareSpec_>,\n MiddlewareSpec.Error<MiddlewareSpec_>,\n | FunctionTypeServices<DatabaseSchema_, FunctionType_>\n | MiddlewareSpec.Requires<MiddlewareSpec_>,\n MiddlewareSpec.Options<MiddlewareSpec_>\n >;\n },\n): Layer.Layer<MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>> =>\n layerFromImpls(\n middlewareSpec,\n impls as MiddlewareRegistryItem.MiddlewareRegistryItem[\"impls\"],\n );\n\n/**\n * Sugar over {@link make} for the flagship \"run something, provide a service\"\n * shape: run `effect` before the rest of the chain and provide its result under\n * `tag` (the runtime tag for the middleware's type-level `provides` service,\n * passed explicitly since the spec class only knows it at the type level).\n */\nexport const provides = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec,\n Shape,\n>(\n databaseSchema: DatabaseSchema_,\n middlewareSpec: MiddlewareSpec_,\n tag: Context.Key<MiddlewareSpec.Provides<MiddlewareSpec_>, Shape>,\n effect: Effect.Effect<\n Shape,\n MiddlewareSpec.Error<MiddlewareSpec_>,\n | CommonServices<\n DatabaseSchema_,\n MiddlewareSpec.FunctionTypes<MiddlewareSpec_>\n >\n | MiddlewareSpec.Requires<MiddlewareSpec_>\n >,\n): Layer.Layer<MiddlewareImpl<MiddlewareSpec.Key<MiddlewareSpec_>>> =>\n make(databaseSchema, middlewareSpec, ((handlerEffect: Effect.Effect<any>) =>\n Effect.provideServiceEffect(handlerEffect, tag, effect)) as any);\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,kBAAgD,EAC3D,oBAIA,QAAQ,QACN,kCAAkC,eACpC;AA6EF,MAAM,kBAGJ,gBACA,UAEA,MAAM,OACJ,eAAoD,EAClD,eAAe,eAAe,IAChC,CAAC,GACD,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAOA;CAExB,OAAO,IAAI,OAAO,WAAW,kBAC3B,kBACE,eACA,CAACC,YAAmC,eAAe,GAAG,CAAC,GACvD;GACGC,SAAgCA;EACjC;EACA;CACF,CACF,CACF;CAEA,OAAO,EAAE,eAAe,eAAe,IAAI;AAC7C,CAAC,CACH;;;;;;;;;;;;;AAcF,MAAa,QAIX,iBACA,gBACA,SAWA,eACE,gBACA,OAAO,YACL,eAAe,iBACZ,QAAQ,iBAAiB,eAAe,cAAc,aAAa,CAAC,CACpE,KAAK,iBAAiB,CACrB,cACA,IACF,CAAC,CACL,CACF;;;;;;;;AASF,MAAa,sBAIX,iBACA,gBACA,UAYA,eACE,gBACA,KACF;;;;;;;AAQF,MAAa,YAKX,gBACA,gBACA,KACA,WAUA,KAAK,gBAAgB,kBAAkB,kBACrC,OAAO,qBAAqB,eAAe,KAAK,MAAM,EAAS"}
@@ -1,7 +1,7 @@
1
1
  import type * as IdScope from "@confect/core/IdScope";
2
2
  import type { GenericDataModel, GenericMutationCtx } from "convex/server";
3
3
  import * as Context from "effect/Context";
4
- import type * as ComponentCtx from "./ComponentCtx";
4
+ import type * as ComponentCtx from "./ComponentCtx.js";
5
5
  import * as Layer from "effect/Layer";
6
6
  export type MutationCtxTag<DataModel extends GenericDataModel, Scope extends IdScope.IdScope = IdScope.App> = Context.Service<MutationCtx<DataModel, Scope>, Scope extends IdScope.App ? GenericMutationCtx<DataModel> : ComponentCtx.Mutation<DataModel, Scope>>;
7
7
  export declare const MutationCtx: <DataModel extends GenericDataModel, Scope extends IdScope.IdScope = IdScope.App>() => MutationCtxTag<DataModel, Scope>;
@@ -1 +1 @@
1
- {"version":3,"file":"MutationCtx.d.ts","sourceRoot":"","sources":["../src/MutationCtx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,MAAM,MAAM,cAAc,CACxB,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,IACzC,OAAO,CAAC,OAAO,CACjB,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,EAC7B,KAAK,SAAS,OAAO,CAAC,GAAG,GACrB,kBAAkB,CAAC,SAAS,CAAC,GAC7B,YAAY,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAC5C,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,OACxC,cAAc,CAAC,SAAS,EAAE,KAAK,CACY,CAAC;AAEjD,MAAM,MAAM,WAAW,CACrB,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,IACzC,KAAK,SAAS,OAAO,CAAC,GAAG,GACzB,kBAAkB,CAAC,SAAS,CAAC,GAC7B,YAAY,CAAC,UAAU,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AAE1D,eAAO,MAAM,KAAK,GAChB,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,OAAO,CAA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BAAkB,CAAC,SAAS,CAAC,SAC3B,KAAK,6DAUb,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MutationCtx.js","names":[],"sources":["../src/MutationCtx.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport type { GenericDataModel, GenericMutationCtx } from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport type * as ComponentCtx from \"./ComponentCtx\";\nimport * as Layer from \"effect/Layer\";\n\nexport type MutationCtxTag<\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Context.Service<\n MutationCtx<DataModel, Scope>,\n Scope extends IdScope.App\n ? GenericMutationCtx<DataModel>\n : ComponentCtx.Mutation<DataModel, Scope>\n>;\n\nexport const MutationCtx = <\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n>(): MutationCtxTag<DataModel, Scope> =>\n Context.Service(\"@confect/server/MutationCtx\");\n\nexport type MutationCtx<\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Scope extends IdScope.App\n ? GenericMutationCtx<DataModel>\n : ComponentCtx.Identifier<\"mutation\", DataModel, Scope>;\n\nexport const layer = <\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope,\n>(\n ctx: GenericMutationCtx<DataModel>,\n scope: Scope,\n) => {\n const tag = MutationCtx<DataModel, Scope>();\n const { auth: _auth, ...componentCtx } = ctx;\n return Layer.succeed(\n tag,\n (scope === \"\" ? ctx : componentCtx) as unknown as Context.Service.Shape<\n typeof tag\n >,\n );\n};\n"],"mappings":";;;;;;;;AAgBA,MAAa,oBAIX,QAAQ,QAAQ,6BAA6B;AAS/C,MAAa,SAIX,KACA,UACG;CACH,MAAM,MAAM,YAA8B;CAC1C,MAAM,EAAE,MAAM,OAAO,GAAG,iBAAiB;CACzC,OAAO,MAAM,QACX,KACC,UAAU,KAAK,MAAM,YAGxB;AACF"}
1
+ {"version":3,"file":"MutationCtx.js","names":[],"sources":["../src/MutationCtx.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport type { GenericDataModel, GenericMutationCtx } from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport type * as ComponentCtx from \"./ComponentCtx.js\";\nimport * as Layer from \"effect/Layer\";\n\nexport type MutationCtxTag<\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Context.Service<\n MutationCtx<DataModel, Scope>,\n Scope extends IdScope.App\n ? GenericMutationCtx<DataModel>\n : ComponentCtx.Mutation<DataModel, Scope>\n>;\n\nexport const MutationCtx = <\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n>(): MutationCtxTag<DataModel, Scope> =>\n Context.Service(\"@confect/server/MutationCtx\");\n\nexport type MutationCtx<\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Scope extends IdScope.App\n ? GenericMutationCtx<DataModel>\n : ComponentCtx.Identifier<\"mutation\", DataModel, Scope>;\n\nexport const layer = <\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope,\n>(\n ctx: GenericMutationCtx<DataModel>,\n scope: Scope,\n) => {\n const tag = MutationCtx<DataModel, Scope>();\n const { auth: _auth, ...componentCtx } = ctx;\n return Layer.succeed(\n tag,\n (scope === \"\" ? ctx : componentCtx) as unknown as Context.Service.Shape<\n typeof tag\n >,\n );\n};\n"],"mappings":";;;;;;;;AAgBA,MAAa,oBAIX,QAAQ,QAAQ,6BAA6B;AAS/C,MAAa,SAIX,KACA,UACG;CACH,MAAM,MAAM,YAA8B;CAC1C,MAAM,EAAE,MAAM,OAAO,GAAG,iBAAiB;CACzC,OAAO,MAAM,QACX,KACC,UAAU,KAAK,MAAM,YAGxB;AACF"}
@@ -4,7 +4,7 @@ import * as Context from "effect/Context";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as Layer from "effect/Layer";
6
6
  import type * as Schema from "effect/Schema";
7
- import * as MutationTransactionContext from "./MutationTransactionContext";
7
+ import * as MutationTransactionContext from "./MutationTransactionContext.js";
8
8
  export type Options = MutationTransactionContext.MutationOptions;
9
9
  export declare const MutationRunner: Context.Service<{
10
10
  runMutation: {
@@ -1 +1 @@
1
- {"version":3,"file":"MutationRunner.d.ts","sourceRoot":"","sources":["../src/MutationRunner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,0BAA0B,MAAM,8BAA8B,CAAC;AAE3E,MAAM,MAAM,OAAO,GAAG,0BAA0B,CAAC,eAAe,CAAC;AAmDjE,eAAO,MAAM,cAAc;;SA5CJ,QAAQ,SAAS,GAAG,CAAC,WAAW,YACzC,QAAQ,WACT,CAAC,GAAG,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,GAC5D,MAAM,CAAC,MAAM,CACd,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EACrB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,WAAW,CACzC;SACoB,QAAQ,SAAS,GAAG,CAAC,WAAW,YACzC,QAAQ,QACZ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,WACf,OAAO,GAAG,SAAS,GAC3B,MAAM,CAAC,MAAM,CACd,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,EACrB,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,WAAW,EACxC,0BAA0B,CAAC,0BAA0B,CACtD;;;;;;;EA+BF,CAAC;AACF,MAAM,MAAM,cAAc,G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0BAA0B,CAAC,0BAA0B,CACtD;;gBAmC+C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MutationRunner.js","names":["MutationTransactionContext.MutationTransactionContext"],"sources":["../src/MutationRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport type { GenericActionCtx } from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport type * as Schema from \"effect/Schema\";\nimport * as MutationTransactionContext from \"./MutationTransactionContext\";\n\nexport type Options = MutationTransactionContext.MutationOptions;\n\nconst run = Effect.fn(\"MutationRunner.runMutation\")(\n <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => effect,\n);\n\nconst make = (nativeRunMutation: GenericActionCtx<any>[\"runMutation\"]) => {\n function runMutation<Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n ...args: [...Ref.OptionalArgs<Mutation>, options?: undefined]\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | Schema.SchemaError\n >;\n function runMutation<Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n args: Ref.Args<Mutation>,\n options: Options | undefined,\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | Schema.SchemaError,\n MutationTransactionContext.MutationTransactionContext\n >;\n function runMutation<Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n args?: Ref.Args<Mutation>,\n options?: Options,\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | Schema.SchemaError,\n MutationTransactionContext.MutationTransactionContext\n > {\n return run(\n Effect.gen(function* () {\n const actualArgs = (args ?? {}) as Ref.Args<Mutation>;\n if (options !== undefined) {\n const controls =\n yield* MutationTransactionContext.MutationTransactionContext;\n return yield* controls.runMutation(mutation, actualArgs, options);\n }\n return yield* Ref.runWithCodec(\n mutation,\n actualArgs,\n (ref, encodedArgs) => nativeRunMutation(ref, encodedArgs),\n );\n }),\n );\n }\n return { runMutation };\n};\n\nexport const MutationRunner = Context.Service<ReturnType<typeof make>>(\n \"@confect/server/MutationRunner\",\n);\nexport type MutationRunner = typeof MutationRunner.Identifier;\n\nexport const layer = (runMutation: GenericActionCtx<any>[\"runMutation\"]) =>\n Layer.succeed(MutationRunner, make(runMutation));\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,MAAM,OAAO,GAAG,4BAA4B,CAAC,EACvC,WAA2D,MACvE;AAEA,MAAM,QAAQ,sBAA4D;CAiBxE,SAAS,YACP,UACA,MACA,SAKA;EACA,OAAO,IACL,OAAO,IAAI,aAAa;GACtB,MAAM,aAAc,QAAQ,CAAC;GAC7B,IAAI,YAAY,KAAA,GAGd,OAAO,QAAO,OADLA,2BAAAA,CACc,YAAY,UAAU,YAAY,OAAO;GAElE,OAAO,OAAO,IAAI,aAChB,UACA,aACC,KAAK,gBAAgB,kBAAkB,KAAK,WAAW,CAC1D;EACF,CAAC,CACH;CACF;CACA,OAAO,EAAE,YAAY;AACvB;AAEA,MAAa,iBAAiB,QAAQ,QACpC,gCACF;AAGA,MAAa,SAAS,gBACpB,MAAM,QAAQ,gBAAgB,KAAK,WAAW,CAAC"}
1
+ {"version":3,"file":"MutationRunner.js","names":["MutationTransactionContext.MutationTransactionContext"],"sources":["../src/MutationRunner.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport type { GenericActionCtx } from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport type * as Schema from \"effect/Schema\";\nimport * as MutationTransactionContext from \"./MutationTransactionContext.js\";\n\nexport type Options = MutationTransactionContext.MutationOptions;\n\nconst run = Effect.fn(\"MutationRunner.runMutation\")(\n <A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => effect,\n);\n\nconst make = (nativeRunMutation: GenericActionCtx<any>[\"runMutation\"]) => {\n function runMutation<Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n ...args: [...Ref.OptionalArgs<Mutation>, options?: undefined]\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | Schema.SchemaError\n >;\n function runMutation<Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n args: Ref.Args<Mutation>,\n options: Options | undefined,\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | Schema.SchemaError,\n MutationTransactionContext.MutationTransactionContext\n >;\n function runMutation<Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n args?: Ref.Args<Mutation>,\n options?: Options,\n ): Effect.Effect<\n Ref.Returns<Mutation>,\n Ref.Error<Mutation> | Schema.SchemaError,\n MutationTransactionContext.MutationTransactionContext\n > {\n return run(\n Effect.gen(function* () {\n const actualArgs = (args ?? {}) as Ref.Args<Mutation>;\n if (options !== undefined) {\n const controls =\n yield* MutationTransactionContext.MutationTransactionContext;\n return yield* controls.runMutation(mutation, actualArgs, options);\n }\n return yield* Ref.runWithCodec(\n mutation,\n actualArgs,\n (ref, encodedArgs) => nativeRunMutation(ref, encodedArgs),\n );\n }),\n );\n }\n return { runMutation };\n};\n\nexport const MutationRunner = Context.Service<ReturnType<typeof make>>(\n \"@confect/server/MutationRunner\",\n);\nexport type MutationRunner = typeof MutationRunner.Identifier;\n\nexport const layer = (runMutation: GenericActionCtx<any>[\"runMutation\"]) =>\n Layer.succeed(MutationRunner, make(runMutation));\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,MAAM,OAAO,GAAG,4BAA4B,CAAC,EACvC,WAA2D,MACvE;AAEA,MAAM,QAAQ,sBAA4D;CAiBxE,SAAS,YACP,UACA,MACA,SAKA;EACA,OAAO,IACL,OAAO,IAAI,aAAa;GACtB,MAAM,aAAc,QAAQ,CAAC;GAC7B,IAAI,YAAY,KAAA,GAGd,OAAO,QAAO,OADLA,2BAAAA,CACc,YAAY,UAAU,YAAY,OAAO;GAElE,OAAO,OAAO,IAAI,aAChB,UACA,aACC,KAAK,gBAAgB,kBAAkB,KAAK,WAAW,CAC1D;EACF,CAAC,CACH;CACF;CACA,OAAO,EAAE,YAAY;AACvB;AAEA,MAAa,iBAAiB,QAAQ,QACpC,gCACF;AAGA,MAAa,SAAS,gBACpB,MAAM,QAAQ,gBAAgB,KAAK,WAAW,CAAC"}
@@ -3,9 +3,9 @@ import type { AdvancedRunQueryOptions, GenericDataModel, GenericMutationCtx } fr
3
3
  import * as Context from "effect/Context";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as Layer from "effect/Layer";
6
- import type { Options as MutationOptions } from "./QueryTransactionContext";
6
+ import type { Options as MutationOptions } from "./QueryTransactionContext.js";
7
7
  export type { TransactionLimits } from "convex/server";
8
- export type { Options as MutationOptions } from "./QueryTransactionContext";
8
+ export type { Options as MutationOptions } from "./QueryTransactionContext.js";
9
9
  export type QueryOptions = AdvancedRunQueryOptions;
10
10
  declare const MutationTransactionContext_base: Context.ServiceClass<MutationTransactionContext, "@confect/server/MutationTransactionContext", {
11
11
  runQuery: <Query extends Ref.AnyQuery>(query: Query, args: Ref.Args<Query>, options: AdvancedRunQueryOptions) => Effect.Effect<Ref.Returns<Query>, import("effect/Schema").SchemaError | Ref.Error<Query>, never>;
@@ -1 +1 @@
1
- {"version":3,"file":"MutationTransactionContext.d.ts","sourceRoot":"","sources":["../src/MutationTransactionContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5E,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5E,MAAM,MAAM,YAAY,GAAG,uBAAuB,CAAC;;eAM9C,KAAK,SAAS,GAAG,CAAC,QAAQ;kBAU1B,QAAQ,SAAS,GAAG,CAAC,WAAW;;AAWrC,qBAAa,0BAA2B,SAAQ,+BAGC;CAAG;AAEpD,eAAO,MAAM,KAAK,QACX,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC,0DACpB,CAAC"}
1
+ {"version":3,"file":"MutationTransactionContext.d.ts","sourceRoot":"","sources":["../src/MutationTransactionContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/E,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/E,MAAM,MAAM,YAAY,GAAG,uBAAuB,CAAC;;eAM9C,KAAK,SAAS,GAAG,CAAC,QAAQ;kBAU1B,QAAQ,SAAS,GAAG,CAAC,WAAW;;AAWrC,qBAAa,0BAA2B,SAAQ,+BAGC;CAAG;AAEpD,eAAO,MAAM,KAAK,QACX,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC,0DACpB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"MutationTransactionContext.js","names":[],"sources":["../src/MutationTransactionContext.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport type {\n AdvancedRunQueryOptions,\n GenericDataModel,\n GenericMutationCtx,\n} from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport type { Options as MutationOptions } from \"./QueryTransactionContext\";\n\nexport type { TransactionLimits } from \"convex/server\";\nexport type { Options as MutationOptions } from \"./QueryTransactionContext\";\nexport type QueryOptions = AdvancedRunQueryOptions;\n\nconst make = (\n ctx: Pick<GenericMutationCtx<GenericDataModel>, \"runQuery\" | \"runMutation\">,\n) => ({\n runQuery: Effect.fn(\"MutationTransactionContext.runQuery\")(\n <Query extends Ref.AnyQuery>(\n query: Query,\n args: Ref.Args<Query>,\n options: QueryOptions,\n ) =>\n Ref.runWithCodec(query, args, (ref, encodedArgs) =>\n ctx.runQuery(ref, encodedArgs, options),\n ),\n ),\n runMutation: Effect.fn(\"MutationTransactionContext.runMutation\")(\n <Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n args: Ref.Args<Mutation>,\n options: MutationOptions,\n ) =>\n Ref.runWithCodec(mutation, args, (ref, encodedArgs) =>\n ctx.runMutation(ref, encodedArgs, options),\n ),\n ),\n});\n\nexport class MutationTransactionContext extends Context.Service<\n MutationTransactionContext,\n ReturnType<typeof make>\n>()(\"@confect/server/MutationTransactionContext\") {}\n\nexport const layer = (\n ctx: Pick<GenericMutationCtx<GenericDataModel>, \"runQuery\" | \"runMutation\">,\n) => Layer.succeed(MutationTransactionContext, make(ctx));\n"],"mappings":";;;;;;;;;;AAeA,MAAM,QACJ,SACI;CACJ,UAAU,OAAO,GAAG,qCAAqC,CAAC,EAEtD,OACA,MACA,YAEA,IAAI,aAAa,OAAO,OAAO,KAAK,gBAClC,IAAI,SAAS,KAAK,aAAa,OAAO,CACxC,CACJ;CACA,aAAa,OAAO,GAAG,wCAAwC,CAAC,EAE5D,UACA,MACA,YAEA,IAAI,aAAa,UAAU,OAAO,KAAK,gBACrC,IAAI,YAAY,KAAK,aAAa,OAAO,CAC3C,CACJ;AACF;AAEA,IAAa,6BAAb,cAAgD,QAAQ,QAGtD,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC;AAEnD,MAAa,SACX,QACG,MAAM,QAAQ,4BAA4B,KAAK,GAAG,CAAC"}
1
+ {"version":3,"file":"MutationTransactionContext.js","names":[],"sources":["../src/MutationTransactionContext.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport type {\n AdvancedRunQueryOptions,\n GenericDataModel,\n GenericMutationCtx,\n} from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport type { Options as MutationOptions } from \"./QueryTransactionContext.js\";\n\nexport type { TransactionLimits } from \"convex/server\";\nexport type { Options as MutationOptions } from \"./QueryTransactionContext.js\";\nexport type QueryOptions = AdvancedRunQueryOptions;\n\nconst make = (\n ctx: Pick<GenericMutationCtx<GenericDataModel>, \"runQuery\" | \"runMutation\">,\n) => ({\n runQuery: Effect.fn(\"MutationTransactionContext.runQuery\")(\n <Query extends Ref.AnyQuery>(\n query: Query,\n args: Ref.Args<Query>,\n options: QueryOptions,\n ) =>\n Ref.runWithCodec(query, args, (ref, encodedArgs) =>\n ctx.runQuery(ref, encodedArgs, options),\n ),\n ),\n runMutation: Effect.fn(\"MutationTransactionContext.runMutation\")(\n <Mutation extends Ref.AnyMutation>(\n mutation: Mutation,\n args: Ref.Args<Mutation>,\n options: MutationOptions,\n ) =>\n Ref.runWithCodec(mutation, args, (ref, encodedArgs) =>\n ctx.runMutation(ref, encodedArgs, options),\n ),\n ),\n});\n\nexport class MutationTransactionContext extends Context.Service<\n MutationTransactionContext,\n ReturnType<typeof make>\n>()(\"@confect/server/MutationTransactionContext\") {}\n\nexport const layer = (\n ctx: Pick<GenericMutationCtx<GenericDataModel>, \"runQuery\" | \"runMutation\">,\n) => Layer.succeed(MutationTransactionContext, make(ctx));\n"],"mappings":";;;;;;;;;;AAeA,MAAM,QACJ,SACI;CACJ,UAAU,OAAO,GAAG,qCAAqC,CAAC,EAEtD,OACA,MACA,YAEA,IAAI,aAAa,OAAO,OAAO,KAAK,gBAClC,IAAI,SAAS,KAAK,aAAa,OAAO,CACxC,CACJ;CACA,aAAa,OAAO,GAAG,wCAAwC,CAAC,EAE5D,UACA,MACA,YAEA,IAAI,aAAa,UAAU,OAAO,KAAK,gBACrC,IAAI,YAAY,KAAK,aAAa,OAAO,CAC3C,CACJ;AACF;AAEA,IAAa,6BAAb,cAAgD,QAAQ,QAGtD,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC;AAEnD,MAAa,SACX,QACG,MAAM,QAAQ,4BAA4B,KAAK,GAAG,CAAC"}
@@ -0,0 +1,50 @@
1
+ import * as Ref from "@confect/core/Ref";
2
+ import type { DefaultFunctionArgs, GenericActionCtx, GenericDataModel, GenericMutationCtx, GenericQueryCtx } from "convex/server";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Schema from "effect/Schema";
5
+ import type * as ActionRunner from "./ActionRunner.js";
6
+ import type * as MutationRunner from "./MutationRunner.js";
7
+ import type * as QueryRunner from "./QueryRunner.js";
8
+ declare const ComponentCallFailed_base: Schema.Class<ComponentCallFailed, Schema.TaggedStruct<"ComponentCallFailed", {
9
+ readonly component: Schema.String;
10
+ readonly method: Schema.String;
11
+ readonly cause: Schema.Defect;
12
+ }>, import("effect/Cause").YieldableError>;
13
+ /**
14
+ * An official component's method rejected. `cause` is the rejection as thrown.
15
+ */
16
+ export declare class ComponentCallFailed extends ComponentCallFailed_base {
17
+ }
18
+ declare const unsupported: unique symbol;
19
+ type Unsupported = typeof unsupported;
20
+ type Needs<Param> = [GenericActionCtx<GenericDataModel>] extends [Param] ? [GenericMutationCtx<GenericDataModel>] extends [Param] ? [GenericQueryCtx<GenericDataModel>] extends [Param] ? QueryRunner.QueryRunner : MutationRunner.MutationRunner : [GenericQueryCtx<GenericDataModel>] extends [Param] ? Unsupported : ActionRunner.ActionRunner : Unsupported;
21
+ type Method<Official> = {
22
+ [K in keyof Official & string]: Official[K] extends (ctx: infer Ctx, ...args: infer _Args) => Promise<unknown> ? Needs<Ctx> extends Unsupported ? never : K : never;
23
+ }[keyof Official & string];
24
+ type Call<F> = F extends (ctx: infer Ctx, ...args: infer Args) => Promise<infer A> ? (...args: Args) => Effect.Effect<A, never, Needs<Ctx>> : never;
25
+ type Lifted<Official> = <M extends Method<Official>>(method: M, ...args: Parameters<Call<Official[M]>>) => ReturnType<Call<Official[M]>>;
26
+ /**
27
+ * Lift official promise methods, deriving each capability from its ctx
28
+ * parameter. A rejection is caller misuse, a limit or a platform fault rather
29
+ * than a domain fact, so it dies.
30
+ */
31
+ export declare const make: <Official extends object>(component: string, official: Official) => Lifted<Official>;
32
+ /**
33
+ * A function reference with its encoded arguments, ready for an official method
34
+ * that takes both.
35
+ */
36
+ export interface Fn<R extends Ref.Any> {
37
+ readonly reference: Ref.FunctionReference<R>;
38
+ readonly args: DefaultFunctionArgs;
39
+ }
40
+ /**
41
+ * Encode a ref's arguments through its codecs to the wire record an official
42
+ * method expects.
43
+ */
44
+ export declare const encodeCall: <R extends Ref.Any>(ref: R, args: NoInfer<Ref.Args<R>>) => Effect.Effect<Fn<R>>;
45
+ /**
46
+ * Encode a callback's real field without fabricating the rest of its arguments.
47
+ */
48
+ export declare const encodeField: <R extends Ref.AnyConfect, K extends keyof Ref.Args<R> & keyof Ref.ArgsFields<R>>(ref: R, key: K, value: NoInfer<Ref.Args<R>[K]>) => Effect.Effect<unknown>;
49
+ export {};
50
+ //# sourceMappingURL=OfficialComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OfficialComponent.d.ts","sourceRoot":"","sources":["../src/OfficialComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,kBAA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OAEhD,CAAC,OACD,CAAC,SACC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,OAAO,CAMvB,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ import { ActionCtx } from "./ActionCtx.js";
3
+ import { MutationCtx } from "./MutationCtx.js";
4
+ import { QueryCtx } from "./QueryCtx.js";
5
+ import * as Ref from "@confect/core/Ref";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Schema from "effect/Schema";
8
+ import * as Option from "effect/Option";
9
+ //#region src/OfficialComponent.ts
10
+ var OfficialComponent_exports = /* @__PURE__ */ __exportAll({
11
+ ComponentCallFailed: () => ComponentCallFailed,
12
+ encodeCall: () => encodeCall,
13
+ encodeField: () => encodeField,
14
+ make: () => make
15
+ });
16
+ /**
17
+ * An official component's method rejected. `cause` is the rejection as thrown.
18
+ */
19
+ var ComponentCallFailed = class extends Schema.TaggedError()("ComponentCallFailed", {
20
+ component: Schema.String,
21
+ method: Schema.String,
22
+ cause: Schema.Defect()
23
+ }) {};
24
+ /**
25
+ * Lift official promise methods, deriving each capability from its ctx
26
+ * parameter. A rejection is caller misuse, a limit or a platform fault rather
27
+ * than a domain fact, so it dies.
28
+ */
29
+ const make = (component, official) => {
30
+ const context = Effect.gen(function* () {
31
+ const action = yield* Effect.serviceOption(ActionCtx());
32
+ if (Option.isSome(action)) return action.value;
33
+ const mutation = yield* Effect.serviceOption(MutationCtx());
34
+ if (Option.isSome(mutation)) return mutation.value;
35
+ const query = yield* Effect.serviceOption(QueryCtx());
36
+ if (Option.isSome(query)) return query.value;
37
+ return yield* Effect.die(/* @__PURE__ */ new Error(`${component} called outside a Confect handler`));
38
+ });
39
+ return Effect.fn(`${component}.call`)(function* (method, ...args) {
40
+ const ctx = yield* context;
41
+ const invoke = official[method];
42
+ return yield* Effect.tryPromise({
43
+ try: () => invoke.call(official, ctx, ...args),
44
+ catch: (cause) => ComponentCallFailed.make({
45
+ component,
46
+ method,
47
+ cause
48
+ })
49
+ }).pipe(Effect.orDie);
50
+ });
51
+ };
52
+ /**
53
+ * Encode a ref's arguments through its codecs to the wire record an official
54
+ * method expects.
55
+ */
56
+ const encodeCall = (ref, args) => Ref.encodeArgs(ref, args).pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.Record(Schema.String, Schema.Unknown))), Effect.map((encoded) => ({
57
+ reference: Ref.getFunctionReference(ref),
58
+ args: encoded
59
+ })), Effect.orDie);
60
+ /**
61
+ * Encode a callback's real field without fabricating the rest of its arguments.
62
+ */
63
+ const encodeField = (ref, key, value) => {
64
+ const fields = ref.args.fields;
65
+ return Schema.encodeUnknownEffect(fields[key])(value).pipe(Effect.orDie);
66
+ };
67
+ //#endregion
68
+ export { ComponentCallFailed, OfficialComponent_exports, encodeCall, encodeField, make };
69
+
70
+ //# sourceMappingURL=OfficialComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OfficialComponent.js","names":["ActionCtx.ActionCtx","MutationCtx.MutationCtx","QueryCtx.QueryCtx"],"sources":["../src/OfficialComponent.ts"],"sourcesContent":["import * as Ref from \"@confect/core/Ref\";\nimport type {\n DefaultFunctionArgs,\n GenericActionCtx,\n GenericDataModel,\n GenericMutationCtx,\n GenericQueryCtx,\n} from \"convex/server\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Schema from \"effect/Schema\";\nimport * as ActionCtx from \"./ActionCtx.js\";\nimport type * as ActionRunner from \"./ActionRunner.js\";\nimport * as MutationCtx from \"./MutationCtx.js\";\nimport type * as MutationRunner from \"./MutationRunner.js\";\nimport * as QueryCtx from \"./QueryCtx.js\";\nimport type * as QueryRunner from \"./QueryRunner.js\";\n\n/**\n * An official component's method rejected. `cause` is the rejection as thrown.\n */\nexport class ComponentCallFailed extends Schema.TaggedError<ComponentCallFailed>()(\n \"ComponentCallFailed\",\n { component: Schema.String, method: Schema.String, cause: Schema.Defect() },\n) {}\n\ndeclare const unsupported: unique symbol;\ntype Unsupported = typeof unsupported;\ntype Needs<Param> = [GenericActionCtx<GenericDataModel>] extends [Param]\n ? [GenericMutationCtx<GenericDataModel>] extends [Param]\n ? [GenericQueryCtx<GenericDataModel>] extends [Param]\n ? QueryRunner.QueryRunner\n : MutationRunner.MutationRunner\n : [GenericQueryCtx<GenericDataModel>] extends [Param]\n ? Unsupported\n : ActionRunner.ActionRunner\n : Unsupported;\n\ntype Method<Official> = {\n [K in keyof Official & string]: Official[K] extends (\n ctx: infer Ctx,\n ...args: infer _Args\n ) => Promise<unknown>\n ? Needs<Ctx> extends Unsupported\n ? never\n : K\n : never;\n}[keyof Official & string];\n\ntype Call<F> = F extends (\n ctx: infer Ctx,\n ...args: infer Args\n) => Promise<infer A>\n ? (...args: Args) => Effect.Effect<A, never, Needs<Ctx>>\n : never;\n\ntype Lifted<Official> = <M extends Method<Official>>(\n method: M,\n ...args: Parameters<Call<Official[M]>>\n) => ReturnType<Call<Official[M]>>;\n\n/**\n * Lift official promise methods, deriving each capability from its ctx\n * parameter. A rejection is caller misuse, a limit or a platform fault rather\n * than a domain fact, so it dies.\n */\nexport const make = <Official extends object>(\n component: string,\n official: Official,\n): Lifted<Official> => {\n const context = Effect.gen(function* () {\n const action = yield* Effect.serviceOption(\n ActionCtx.ActionCtx<GenericDataModel>(),\n );\n if (Option.isSome(action)) return action.value;\n const mutation = yield* Effect.serviceOption(\n MutationCtx.MutationCtx<GenericDataModel>(),\n );\n if (Option.isSome(mutation)) return mutation.value;\n const query = yield* Effect.serviceOption(\n QueryCtx.QueryCtx<GenericDataModel>(),\n );\n if (Option.isSome(query)) return query.value;\n return yield* Effect.die(\n new Error(`${component} called outside a Confect handler`),\n );\n });\n const call = Effect.fn(`${component}.call`)(function* (\n method: Method<Official>,\n ...args: unknown[]\n ) {\n const ctx = yield* context;\n // Method selects promise methods whose first argument accepts a native handler context.\n const invoke = official[method] as (\n native: typeof ctx,\n ...args: unknown[]\n ) => Promise<unknown>;\n return yield* Effect.tryPromise({\n try: () => invoke.call(official, ctx, ...args),\n catch: (cause) => ComponentCallFailed.make({ component, method, cause }),\n }).pipe(Effect.orDie);\n });\n // Confect installs the native ctx with the runner capability inferred by Needs.\n return call as unknown as Lifted<Official>;\n};\n\n/**\n * A function reference with its encoded arguments, ready for an official method\n * that takes both.\n */\nexport interface Fn<R extends Ref.Any> {\n readonly reference: Ref.FunctionReference<R>;\n readonly args: DefaultFunctionArgs;\n}\n\n/**\n * Encode a ref's arguments through its codecs to the wire record an official\n * method expects.\n */\nexport const encodeCall = <R extends Ref.Any>(\n ref: R,\n args: NoInfer<Ref.Args<R>>,\n): Effect.Effect<Fn<R>> =>\n Ref.encodeArgs(ref, args).pipe(\n Effect.flatMap(\n Schema.decodeUnknownEffect(Schema.Record(Schema.String, Schema.Unknown)),\n ),\n Effect.map((encoded) => ({\n reference: Ref.getFunctionReference(ref),\n args: encoded,\n })),\n Effect.orDie,\n );\n\n/**\n * Encode a callback's real field without fabricating the rest of its arguments.\n */\nexport const encodeField = <\n R extends Ref.AnyConfect,\n K extends keyof Ref.Args<R> & keyof Ref.ArgsFields<R>,\n>(\n ref: R,\n key: K,\n value: NoInfer<Ref.Args<R>[K]>,\n): Effect.Effect<unknown> => {\n const fields = ref.args.fields as Record<\n keyof Ref.ArgsFields<R>,\n Schema.Codec<unknown, unknown>\n >;\n return Schema.encodeUnknownEffect(fields[key])(value).pipe(Effect.orDie);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CAAE,WAAW,OAAO;CAAQ,QAAQ,OAAO;CAAQ,OAAO,OAAO,OAAO;AAAE,CAC5E,CAAC,CAAC,CAAC;;;;;;AA0CH,MAAa,QACX,WACA,aACqB;CACrB,MAAM,UAAU,OAAO,IAAI,aAAa;EACtC,MAAM,SAAS,OAAO,OAAO,cAC3BA,UAAsC,CACxC;EACA,IAAI,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO;EACzC,MAAM,WAAW,OAAO,OAAO,cAC7BC,YAA0C,CAC5C;EACA,IAAI,OAAO,OAAO,QAAQ,GAAG,OAAO,SAAS;EAC7C,MAAM,QAAQ,OAAO,OAAO,cAC1BC,SAAoC,CACtC;EACA,IAAI,OAAO,OAAO,KAAK,GAAG,OAAO,MAAM;EACvC,OAAO,OAAO,OAAO,oBACnB,IAAI,MAAM,GAAG,UAAU,kCAAkC,CAC3D;CACF,CAAC;CAiBD,OAhBa,OAAO,GAAG,GAAG,UAAU,MAAM,CAAC,CAAC,WAC1C,QACA,GAAG,MACH;EACA,MAAM,MAAM,OAAO;EAEnB,MAAM,SAAS,SAAS;EAIxB,OAAO,OAAO,OAAO,WAAW;GAC9B,WAAW,OAAO,KAAK,UAAU,KAAK,GAAG,IAAI;GAC7C,QAAQ,UAAU,oBAAoB,KAAK;IAAE;IAAW;IAAQ;GAAM,CAAC;EACzE,CAAC,CAAC,CAAC,KAAK,OAAO,KAAK;CACtB,CAEU;AACZ;;;;;AAeA,MAAa,cACX,KACA,SAEA,IAAI,WAAW,KAAK,IAAI,CAAC,CAAC,KACxB,OAAO,QACL,OAAO,oBAAoB,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,CAAC,CACzE,GACA,OAAO,KAAK,aAAa;CACvB,WAAW,IAAI,qBAAqB,GAAG;CACvC,MAAM;AACR,EAAE,GACF,OAAO,KACT;;;;AAKF,MAAa,eAIX,KACA,KACA,UAC2B;CAC3B,MAAM,SAAS,IAAI,KAAK;CAIxB,OAAO,OAAO,oBAAoB,OAAO,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,OAAO,KAAK;AACzE"}
@@ -3,10 +3,10 @@ import type { ExpressionOrValue, FilterBuilder, OrderedQuery as ConvexOrderedQue
3
3
  import type { Option } from "effect";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as Stream from "effect/Stream";
6
- import type * as DatabaseSchema from "./DatabaseSchema";
7
- import * as Document from "./Document";
8
- import type * as TableInfo from "./TableInfo";
9
- import type * as Table from "./Table";
6
+ import type * as DatabaseSchema from "./DatabaseSchema.js";
7
+ import * as Document from "./Document.js";
8
+ import type * as TableInfo from "./TableInfo.js";
9
+ import type * as Table from "./Table.js";
10
10
  type NativePaginate<TableInfo_ extends TableInfo.AnyWithProps, Doc> = (options: PaginationOptions, filter?: (q: FilterBuilder<TableInfo.ConvexTableInfo<TableInfo_>>) => ExpressionOrValue<boolean>) => Effect.Effect<PaginationResult<Doc>, Document.DocumentDecodeError>;
11
11
  export type OrderedQuery<TableInfo_ extends TableInfo.AnyWithProps, Doc = TableInfo_["document"], TargetKind extends DatabaseSchema.Target["kind"] = "app"> = {
12
12
  readonly first: () => Effect.Effect<Option.Option<Doc>, Document.DocumentDecodeError>;
@@ -1 +1 @@
1
- {"version":3,"file":"OrderedQuery.d.ts","sourceRoot":"","sources":["../src/OrderedQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EACV,iBAAiB,EACjB,aAAa,EACb,YAAY,IAAI,kBAAkB,EAClC,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,cAAc,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,QAAQ,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,KAAK,SAAS,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,CAAC;AAEtC,KAAK,cAAc,CAAC,UAAU,SAAS,SAAS,CAAC,YAAY,EAAE,GAAG,IAAI,CACpE,OAAO,EAAE,iBAAiB,EAC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CAAC;KACH,CAAC,UAAU,CAAC,CAAC;CACf,CAAC;AAEF,wBAAgB,IAAI,CAAC,MAAM,SAAS,KAAK,CAAC,YAAY,EACpD,KAAK,EAAE,kBAAkB,CACvB,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CACvD,EACD,KAAK,EAAE,MAAM,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAA;CAAE,GAC9C,YAAY,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7C,wBAAgB,IAAI,CAAC,MAAM,SAAS,KAAK,CAAC,YAAY,EACpD,KAAK,EAAE,kBAAkB,CACvB,SAAS,CAAC,eAAe,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CACvD,EACD,KAAK,EAAE,MAAM,GACZ,YAAY,CACb,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,EAC3B,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,EACvC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,OAAO,CAAC,GAAG,GAAG,KAAK,GAAG,WAAW,CAC9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"OrderedQuery.js","names":["Document.decode"],"sources":["../src/OrderedQuery.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport type {\n ExpressionOrValue,\n FilterBuilder,\n OrderedQuery as ConvexOrderedQuery,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { identity, pipe } from \"effect/Function\";\nimport type { Option } from \"effect\";\nimport * as Effect from \"effect/Effect\";\nimport * as Stream from \"effect/Stream\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as Document from \"./Document\";\nimport type * as TableInfo from \"./TableInfo\";\nimport type * as Table from \"./Table\";\n\ntype NativePaginate<TableInfo_ extends TableInfo.AnyWithProps, Doc> = (\n options: PaginationOptions,\n filter?: (\n q: FilterBuilder<TableInfo.ConvexTableInfo<TableInfo_>>,\n ) => ExpressionOrValue<boolean>,\n) => Effect.Effect<PaginationResult<Doc>, Document.DocumentDecodeError>;\n\nexport type OrderedQuery<\n TableInfo_ extends TableInfo.AnyWithProps,\n Doc = TableInfo_[\"document\"],\n TargetKind extends DatabaseSchema.Target[\"kind\"] = \"app\",\n> = {\n readonly first: () => Effect.Effect<\n Option.Option<Doc>,\n Document.DocumentDecodeError\n >;\n readonly take: (\n n: number,\n ) => Effect.Effect<ReadonlyArray<Doc>, Document.DocumentDecodeError>;\n readonly collect: () => Effect.Effect<\n ReadonlyArray<Doc>,\n Document.DocumentDecodeError\n >;\n readonly stream: () => Stream.Stream<Doc, Document.DocumentDecodeError>;\n /**\n * Native pagination is application-only. Use `QueryStream.paginate` for\n * component index queries.\n */\n readonly paginate: {\n readonly app: NativePaginate<TableInfo_, Doc>;\n readonly component: {\n readonly \"Native pagination is unavailable in components. Use QueryStream.paginate for index queries.\": never;\n };\n }[TargetKind];\n};\n\nexport function make<Table_ extends Table.AnyWithProps>(\n query: ConvexOrderedQuery<\n TableInfo.ConvexTableInfo<TableInfo.TableInfo<Table_>>\n >,\n table: Table_ & { readonly scope: IdScope.App },\n): OrderedQuery<TableInfo.TableInfo<Table_>>;\nexport function make<Table_ extends Table.AnyWithProps>(\n query: ConvexOrderedQuery<\n TableInfo.ConvexTableInfo<TableInfo.TableInfo<Table_>>\n >,\n table: Table_,\n): OrderedQuery<\n TableInfo.TableInfo<Table_>,\n TableInfo.TableInfo<Table_>[\"document\"],\n Table.Scope<Table_> extends IdScope.App ? \"app\" : \"component\"\n>;\nexport function make<Table_ extends Table.AnyWithProps>(\n query: ConvexOrderedQuery<\n TableInfo.ConvexTableInfo<TableInfo.TableInfo<Table_>>\n >,\n table: Table_,\n): OrderedQuery<\n TableInfo.TableInfo<Table_>,\n TableInfo.TableInfo<Table_>[\"document\"],\n DatabaseSchema.Target[\"kind\"]\n> {\n type TableInfo_ = TableInfo.TableInfo<Table_>;\n type OrderedQueryFunction<\n FunctionName extends keyof OrderedQuery<TableInfo_>,\n > = OrderedQuery<TableInfo_>[FunctionName];\n\n const streamEncoded = Stream.fromAsyncIterable(query, identity).pipe(\n Stream.orDie,\n );\n\n const stream: OrderedQueryFunction<\"stream\"> = () =>\n pipe(streamEncoded, Stream.mapEffect(Document.decode(table)));\n\n const first: OrderedQueryFunction<\"first\"> = () =>\n pipe(stream(), Stream.take(1), Stream.runHead);\n\n const take: OrderedQueryFunction<\"take\"> = (n: number) =>\n pipe(stream(), Stream.take(n), Stream.runCollect);\n\n const collect: OrderedQueryFunction<\"collect\"> = () =>\n pipe(stream(), Stream.runCollect);\n\n const paginate: NativePaginate<TableInfo_, TableInfo_[\"document\"]> =\n Effect.fn(\"OrderedQuery.paginate\")(function* (options, filter) {\n const filteredQuery = filter !== undefined ? query.filter(filter) : query;\n\n const paginationResult = yield* Effect.promise(() =>\n filteredQuery.paginate(options),\n );\n\n const parsedPage = yield* Effect.forEach(\n paginationResult.page,\n Document.decode(table),\n );\n\n return {\n page: parsedPage,\n isDone: paginationResult.isDone,\n continueCursor: paginationResult.continueCursor,\n /* v8 ignore start */\n ...(paginationResult.splitCursor\n ? { splitCursor: paginationResult.splitCursor }\n : {}),\n ...(paginationResult.pageStatus\n ? { pageStatus: paginationResult.pageStatus }\n : {}),\n /* v8 ignore stop */\n };\n });\n\n return {\n first,\n take,\n collect,\n paginate,\n stream,\n };\n}\n"],"mappings":";;;;;;;AAqEA,SAAgB,KACd,OAGA,OAKA;CAMA,MAAM,gBAAgB,OAAO,kBAAkB,OAAO,QAAQ,CAAC,CAAC,KAC9D,OAAO,KACT;CAEA,MAAM,eACJ,KAAK,eAAe,OAAO,UAAUA,OAAgB,KAAK,CAAC,CAAC;CAE9D,MAAM,cACJ,KAAK,OAAO,GAAG,OAAO,KAAK,CAAC,GAAG,OAAO,OAAO;CAE/C,MAAM,QAAsC,MAC1C,KAAK,OAAO,GAAG,OAAO,KAAK,CAAC,GAAG,OAAO,UAAU;CAElD,MAAM,gBACJ,KAAK,OAAO,GAAG,OAAO,UAAU;CA8BlC,OAAO;EACL;EACA;EACA;EACA,UA/BA,OAAO,GAAG,uBAAuB,CAAC,CAAC,WAAW,SAAS,QAAQ;GAC7D,MAAM,gBAAgB,WAAW,KAAA,IAAY,MAAM,OAAO,MAAM,IAAI;GAEpE,MAAM,mBAAmB,OAAO,OAAO,cACrC,cAAc,SAAS,OAAO,CAChC;GAOA,OAAO;IACL,MAAM,OANkB,OAAO,QAC/B,iBAAiB,MACjBA,OAAgB,KAAK,CACvB;IAIE,QAAQ,iBAAiB;IACzB,gBAAgB,iBAAiB;;IAEjC,GAAI,iBAAiB,cACjB,EAAE,aAAa,iBAAiB,YAAY,IAC5C,CAAC;IACL,GAAI,iBAAiB,aACjB,EAAE,YAAY,iBAAiB,WAAW,IAC1C,CAAC;GAEP;EACF,CAMO;EACP;CACF;AACF"}
1
+ {"version":3,"file":"OrderedQuery.js","names":["Document.decode"],"sources":["../src/OrderedQuery.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport type {\n ExpressionOrValue,\n FilterBuilder,\n OrderedQuery as ConvexOrderedQuery,\n PaginationOptions,\n PaginationResult,\n} from \"convex/server\";\nimport { identity, pipe } from \"effect/Function\";\nimport type { Option } from \"effect\";\nimport * as Effect from \"effect/Effect\";\nimport * as Stream from \"effect/Stream\";\nimport type * as DatabaseSchema from \"./DatabaseSchema.js\";\nimport * as Document from \"./Document.js\";\nimport type * as TableInfo from \"./TableInfo.js\";\nimport type * as Table from \"./Table.js\";\n\ntype NativePaginate<TableInfo_ extends TableInfo.AnyWithProps, Doc> = (\n options: PaginationOptions,\n filter?: (\n q: FilterBuilder<TableInfo.ConvexTableInfo<TableInfo_>>,\n ) => ExpressionOrValue<boolean>,\n) => Effect.Effect<PaginationResult<Doc>, Document.DocumentDecodeError>;\n\nexport type OrderedQuery<\n TableInfo_ extends TableInfo.AnyWithProps,\n Doc = TableInfo_[\"document\"],\n TargetKind extends DatabaseSchema.Target[\"kind\"] = \"app\",\n> = {\n readonly first: () => Effect.Effect<\n Option.Option<Doc>,\n Document.DocumentDecodeError\n >;\n readonly take: (\n n: number,\n ) => Effect.Effect<ReadonlyArray<Doc>, Document.DocumentDecodeError>;\n readonly collect: () => Effect.Effect<\n ReadonlyArray<Doc>,\n Document.DocumentDecodeError\n >;\n readonly stream: () => Stream.Stream<Doc, Document.DocumentDecodeError>;\n /**\n * Native pagination is application-only. Use `QueryStream.paginate` for\n * component index queries.\n */\n readonly paginate: {\n readonly app: NativePaginate<TableInfo_, Doc>;\n readonly component: {\n readonly \"Native pagination is unavailable in components. Use QueryStream.paginate for index queries.\": never;\n };\n }[TargetKind];\n};\n\nexport function make<Table_ extends Table.AnyWithProps>(\n query: ConvexOrderedQuery<\n TableInfo.ConvexTableInfo<TableInfo.TableInfo<Table_>>\n >,\n table: Table_ & { readonly scope: IdScope.App },\n): OrderedQuery<TableInfo.TableInfo<Table_>>;\nexport function make<Table_ extends Table.AnyWithProps>(\n query: ConvexOrderedQuery<\n TableInfo.ConvexTableInfo<TableInfo.TableInfo<Table_>>\n >,\n table: Table_,\n): OrderedQuery<\n TableInfo.TableInfo<Table_>,\n TableInfo.TableInfo<Table_>[\"document\"],\n Table.Scope<Table_> extends IdScope.App ? \"app\" : \"component\"\n>;\nexport function make<Table_ extends Table.AnyWithProps>(\n query: ConvexOrderedQuery<\n TableInfo.ConvexTableInfo<TableInfo.TableInfo<Table_>>\n >,\n table: Table_,\n): OrderedQuery<\n TableInfo.TableInfo<Table_>,\n TableInfo.TableInfo<Table_>[\"document\"],\n DatabaseSchema.Target[\"kind\"]\n> {\n type TableInfo_ = TableInfo.TableInfo<Table_>;\n type OrderedQueryFunction<\n FunctionName extends keyof OrderedQuery<TableInfo_>,\n > = OrderedQuery<TableInfo_>[FunctionName];\n\n const streamEncoded = Stream.fromAsyncIterable(query, identity).pipe(\n Stream.orDie,\n );\n\n const stream: OrderedQueryFunction<\"stream\"> = () =>\n pipe(streamEncoded, Stream.mapEffect(Document.decode(table)));\n\n const first: OrderedQueryFunction<\"first\"> = () =>\n pipe(stream(), Stream.take(1), Stream.runHead);\n\n const take: OrderedQueryFunction<\"take\"> = (n: number) =>\n pipe(stream(), Stream.take(n), Stream.runCollect);\n\n const collect: OrderedQueryFunction<\"collect\"> = () =>\n pipe(stream(), Stream.runCollect);\n\n const paginate: NativePaginate<TableInfo_, TableInfo_[\"document\"]> =\n Effect.fn(\"OrderedQuery.paginate\")(function* (options, filter) {\n const filteredQuery = filter !== undefined ? query.filter(filter) : query;\n\n const paginationResult = yield* Effect.promise(() =>\n filteredQuery.paginate(options),\n );\n\n const parsedPage = yield* Effect.forEach(\n paginationResult.page,\n Document.decode(table),\n );\n\n return {\n page: parsedPage,\n isDone: paginationResult.isDone,\n continueCursor: paginationResult.continueCursor,\n /* v8 ignore start */\n ...(paginationResult.splitCursor\n ? { splitCursor: paginationResult.splitCursor }\n : {}),\n ...(paginationResult.pageStatus\n ? { pageStatus: paginationResult.pageStatus }\n : {}),\n /* v8 ignore stop */\n };\n });\n\n return {\n first,\n take,\n collect,\n paginate,\n stream,\n };\n}\n"],"mappings":";;;;;;;AAqEA,SAAgB,KACd,OAGA,OAKA;CAMA,MAAM,gBAAgB,OAAO,kBAAkB,OAAO,QAAQ,CAAC,CAAC,KAC9D,OAAO,KACT;CAEA,MAAM,eACJ,KAAK,eAAe,OAAO,UAAUA,OAAgB,KAAK,CAAC,CAAC;CAE9D,MAAM,cACJ,KAAK,OAAO,GAAG,OAAO,KAAK,CAAC,GAAG,OAAO,OAAO;CAE/C,MAAM,QAAsC,MAC1C,KAAK,OAAO,GAAG,OAAO,KAAK,CAAC,GAAG,OAAO,UAAU;CAElD,MAAM,gBACJ,KAAK,OAAO,GAAG,OAAO,UAAU;CA8BlC,OAAO;EACL;EACA;EACA;EACA,UA/BA,OAAO,GAAG,uBAAuB,CAAC,CAAC,WAAW,SAAS,QAAQ;GAC7D,MAAM,gBAAgB,WAAW,KAAA,IAAY,MAAM,OAAO,MAAM,IAAI;GAEpE,MAAM,mBAAmB,OAAO,OAAO,cACrC,cAAc,SAAS,OAAO,CAChC;GAOA,OAAO;IACL,MAAM,OANkB,OAAO,QAC/B,iBAAiB,MACjBA,OAAgB,KAAK,CACvB;IAIE,QAAQ,iBAAiB;IACzB,gBAAgB,iBAAiB;;IAEjC,GAAI,iBAAiB,cACjB,EAAE,aAAa,iBAAiB,YAAY,IAC5C,CAAC;IACL,GAAI,iBAAiB,aACjB,EAAE,YAAY,iBAAiB,WAAW,IAC1C,CAAC;GAEP;EACF,CAMO;EACP;CACF;AACF"}
@@ -1,7 +1,7 @@
1
1
  import type * as IdScope from "@confect/core/IdScope";
2
2
  import type { GenericDataModel, GenericQueryCtx } from "convex/server";
3
3
  import * as Context from "effect/Context";
4
- import type * as ComponentCtx from "./ComponentCtx";
4
+ import type * as ComponentCtx from "./ComponentCtx.js";
5
5
  import * as Layer from "effect/Layer";
6
6
  export type QueryCtxTag<DataModel extends GenericDataModel, Scope extends IdScope.IdScope = IdScope.App> = Context.Service<QueryCtx<DataModel, Scope>, Scope extends IdScope.App ? GenericQueryCtx<DataModel> : ComponentCtx.Query<DataModel, Scope>>;
7
7
  export declare const QueryCtx: <DataModel extends GenericDataModel, Scope extends IdScope.IdScope = IdScope.App>() => QueryCtxTag<DataModel, Scope>;
@@ -1 +1 @@
1
- {"version":3,"file":"QueryCtx.d.ts","sourceRoot":"","sources":["../src/QueryCtx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,YAAY,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC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CACrB,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,IACzC,OAAO,CAAC,OAAO,CACjB,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,EAC1B,KAAK,SAAS,OAAO,CAAC,GAAG,GACrB,eAAe,CAAC,SAAS,CAAC,GAC1B,YAAY,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CACzC,CAAC;AAEF,eAAO,MAAM,QAAQ,GACnB,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,OACxC,WAAW,CAAC,SAAS,EAAE,KAAK,CACY,CAAC;AAE9C,MAAM,MAAM,QAAQ,CAClB,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,IACzC,KAAK,SAAS,OAAO,CAAC,GAAG,GACzB,eAAe,CAAC,SAAS,CAAC,GAC1B,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AAEvD,eAAO,MAAM,KAAK,GAChB,SAAS,SAAS,gBAAgB,EAClC,KAAK,SAAS,OAAO,CAAC,OAAO,OAExB,eAAe,CAAC,SAAS,CAAC,SACxB,KAAK,0DAUb,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"QueryCtx.js","names":[],"sources":["../src/QueryCtx.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport type { GenericDataModel, GenericQueryCtx } from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport type * as ComponentCtx from \"./ComponentCtx\";\nimport * as Layer from \"effect/Layer\";\n\nexport type QueryCtxTag<\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Context.Service<\n QueryCtx<DataModel, Scope>,\n Scope extends IdScope.App\n ? GenericQueryCtx<DataModel>\n : ComponentCtx.Query<DataModel, Scope>\n>;\n\nexport const QueryCtx = <\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n>(): QueryCtxTag<DataModel, Scope> =>\n Context.Service(\"@confect/server/QueryCtx\");\n\nexport type QueryCtx<\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Scope extends IdScope.App\n ? GenericQueryCtx<DataModel>\n : ComponentCtx.Identifier<\"query\", DataModel, Scope>;\n\nexport const layer = <\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope,\n>(\n ctx: GenericQueryCtx<DataModel>,\n scope: Scope,\n) => {\n const tag = QueryCtx<DataModel, Scope>();\n const { auth: _auth, ...componentCtx } = ctx;\n return Layer.succeed(\n tag,\n (scope === \"\" ? ctx : componentCtx) as unknown as Context.Service.Shape<\n typeof tag\n >,\n );\n};\n"],"mappings":";;;;;;;;AAgBA,MAAa,iBAIX,QAAQ,QAAQ,0BAA0B;AAS5C,MAAa,SAIX,KACA,UACG;CACH,MAAM,MAAM,SAA2B;CACvC,MAAM,EAAE,MAAM,OAAO,GAAG,iBAAiB;CACzC,OAAO,MAAM,QACX,KACC,UAAU,KAAK,MAAM,YAGxB;AACF"}
1
+ {"version":3,"file":"QueryCtx.js","names":[],"sources":["../src/QueryCtx.ts"],"sourcesContent":["import type * as IdScope from \"@confect/core/IdScope\";\nimport type { GenericDataModel, GenericQueryCtx } from \"convex/server\";\nimport * as Context from \"effect/Context\";\nimport type * as ComponentCtx from \"./ComponentCtx.js\";\nimport * as Layer from \"effect/Layer\";\n\nexport type QueryCtxTag<\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Context.Service<\n QueryCtx<DataModel, Scope>,\n Scope extends IdScope.App\n ? GenericQueryCtx<DataModel>\n : ComponentCtx.Query<DataModel, Scope>\n>;\n\nexport const QueryCtx = <\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n>(): QueryCtxTag<DataModel, Scope> =>\n Context.Service(\"@confect/server/QueryCtx\");\n\nexport type QueryCtx<\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope = IdScope.App,\n> = Scope extends IdScope.App\n ? GenericQueryCtx<DataModel>\n : ComponentCtx.Identifier<\"query\", DataModel, Scope>;\n\nexport const layer = <\n DataModel extends GenericDataModel,\n Scope extends IdScope.IdScope,\n>(\n ctx: GenericQueryCtx<DataModel>,\n scope: Scope,\n) => {\n const tag = QueryCtx<DataModel, Scope>();\n const { auth: _auth, ...componentCtx } = ctx;\n return Layer.succeed(\n tag,\n (scope === \"\" ? ctx : componentCtx) as unknown as Context.Service.Shape<\n typeof tag\n >,\n );\n};\n"],"mappings":";;;;;;;;AAgBA,MAAa,iBAIX,QAAQ,QAAQ,0BAA0B;AAS5C,MAAa,SAIX,KACA,UACG;CACH,MAAM,MAAM,SAA2B;CACvC,MAAM,EAAE,MAAM,OAAO,GAAG,iBAAiB;CACzC,OAAO,MAAM,QACX,KACC,UAAU,KAAK,MAAM,YAGxB;AACF"}