@gaganref/confect-core 10.3.1-fork.6 → 10.3.1-fork.60

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 (69) hide show
  1. package/dist/ActionCall.d.ts +18 -0
  2. package/dist/ActionCall.d.ts.map +1 -0
  3. package/dist/ActionCall.js +21 -0
  4. package/dist/ActionCall.js.map +1 -0
  5. package/dist/App.d.ts +13 -2
  6. package/dist/App.d.ts.map +1 -1
  7. package/dist/App.js +6 -3
  8. package/dist/App.js.map +1 -1
  9. package/dist/Auth.d.ts +31 -6
  10. package/dist/Auth.d.ts.map +1 -1
  11. package/dist/Auth.js +15 -1
  12. package/dist/Auth.js.map +1 -1
  13. package/dist/Callback.d.ts.map +1 -1
  14. package/dist/Callback.js +4 -3
  15. package/dist/Callback.js.map +1 -1
  16. package/dist/Component.d.ts.map +1 -1
  17. package/dist/Component.js +1 -1
  18. package/dist/Component.js.map +1 -1
  19. package/dist/FunctionSpec.d.ts +365 -2
  20. package/dist/FunctionSpec.d.ts.map +1 -1
  21. package/dist/FunctionSpec.js +66 -3
  22. package/dist/FunctionSpec.js.map +1 -1
  23. package/dist/GroupSpec.js +1 -1
  24. package/dist/Http.d.ts.map +1 -1
  25. package/dist/Http.js +2 -2
  26. package/dist/Http.js.map +1 -1
  27. package/dist/ManifestSection.d.ts +66 -0
  28. package/dist/ManifestSection.d.ts.map +1 -0
  29. package/dist/ManifestSection.js +7 -0
  30. package/dist/ManifestSection.js.map +1 -0
  31. package/dist/Profile.d.ts +95 -0
  32. package/dist/Profile.d.ts.map +1 -0
  33. package/dist/Profile.js +15 -0
  34. package/dist/Profile.js.map +1 -0
  35. package/dist/Ref.d.ts +4 -3
  36. package/dist/Ref.d.ts.map +1 -1
  37. package/dist/Ref.js +11 -17
  38. package/dist/Ref.js.map +1 -1
  39. package/dist/RefInternal.d.ts +3 -0
  40. package/dist/RefInternal.d.ts.map +1 -0
  41. package/dist/RefInternal.js +16 -0
  42. package/dist/RefInternal.js.map +1 -0
  43. package/dist/SchemaToValidator.d.ts +10 -1
  44. package/dist/SchemaToValidator.d.ts.map +1 -1
  45. package/dist/SchemaToValidator.js +19 -4
  46. package/dist/SchemaToValidator.js.map +1 -1
  47. package/dist/SystemFields.js +1 -1
  48. package/dist/index.d.ts +3 -0
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/index.js +9 -6
  51. package/dist/internal/scalarDocs.d.ts +5 -0
  52. package/dist/internal/scalarDocs.d.ts.map +1 -0
  53. package/dist/internal/scalarDocs.js +43 -0
  54. package/dist/internal/scalarDocs.js.map +1 -0
  55. package/package.json +3 -3
  56. package/src/ActionCall.ts +25 -0
  57. package/src/App.ts +19 -3
  58. package/src/Auth.ts +48 -6
  59. package/src/Callback.ts +3 -1
  60. package/src/Component.ts +2 -0
  61. package/src/FunctionSpec.ts +566 -5
  62. package/src/Http.ts +2 -5
  63. package/src/ManifestSection.ts +74 -0
  64. package/src/Profile.ts +141 -0
  65. package/src/Ref.ts +19 -26
  66. package/src/RefInternal.ts +26 -0
  67. package/src/SchemaToValidator.ts +22 -1
  68. package/src/index.ts +3 -0
  69. package/src/internal/scalarDocs.ts +72 -0
@@ -0,0 +1,18 @@
1
+ import * as Context from "effect/Context";
2
+ import type * as Effect from "effect/Effect";
3
+ import type * as Schema from "effect/Schema";
4
+ import * as FunctionSpec from "./FunctionSpec.js";
5
+ import * as MiddlewareSpec from "./MiddlewareSpec.js";
6
+ import type * as Ref from "./Ref.js";
7
+ export interface Call {
8
+ <Target extends Ref.AnyQuery | Ref.AnyMutation>(target: Target, ...args: Ref.OptionalArgs<NoInfer<Target>>): Effect.Effect<Ref.Returns<Target>, Ref.Error<Target> | Schema.SchemaError>;
9
+ }
10
+ declare const ActionCall_base: Context.ServiceClass<ActionCall, "@confect/core/ActionCall", Call>;
11
+ export declare class ActionCall extends ActionCall_base {
12
+ }
13
+ declare const Middleware_base: MiddlewareSpec.MiddlewareSpec<Middleware, "@confect/core/ActionCall/Middleware", ActionCall, never, never, "action", never>;
14
+ export declare class Middleware extends Middleware_base {
15
+ }
16
+ export declare const profile: FunctionSpec.Extended<import("./Profile.js").NoFields, typeof Middleware, [{}]>;
17
+ export {};
18
+ //# sourceMappingURL=ActionCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionCall.d.ts","sourceRoot":"","sources":["../src/ActionCall.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AAErC,MAAM,WAAW,IAAI;IACnB,CAAC,MAAM,SAAS,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,WAAW,EAC5C,MAAM,EAAE,MAAM,EACd,GAAG,IAAI,EAAE,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GACzC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;CAC/E;;AAED,qBAAa,UAAW,SAAQ,eAE/B;CAAG;;AACJ,qBAAa,UAAW,SAAQ,eAK9B;CAAG;AAEL,eAAO,MAAM,OAAO,iFAAsD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ import { MiddlewareSpec } from "./MiddlewareSpec.js";
3
+ import { extend } from "./FunctionSpec.js";
4
+ import * as Context from "effect/Context";
5
+ //#region src/ActionCall.ts
6
+ var ActionCall_exports = /* @__PURE__ */ __exportAll({
7
+ ActionCall: () => ActionCall,
8
+ Middleware: () => Middleware,
9
+ profile: () => profile
10
+ });
11
+ var ActionCall = class extends Context.Service()("@confect/core/ActionCall") {};
12
+ var Middleware = class extends MiddlewareSpec()("@confect/core/ActionCall/Middleware", { functionTypes: {
13
+ query: false,
14
+ mutation: false,
15
+ action: true
16
+ } }) {};
17
+ const profile = extend()({ middleware: [Middleware] });
18
+ //#endregion
19
+ export { ActionCall, ActionCall_exports, Middleware, profile };
20
+
21
+ //# sourceMappingURL=ActionCall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionCall.js","names":["MiddlewareSpec.MiddlewareSpec","FunctionSpec.extend"],"sources":["../src/ActionCall.ts"],"sourcesContent":["import * as Context from \"effect/Context\";\nimport type * as Effect from \"effect/Effect\";\nimport type * as Schema from \"effect/Schema\";\nimport * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport type * as Ref from \"./Ref.js\";\n\nexport interface Call {\n <Target extends Ref.AnyQuery | Ref.AnyMutation>(\n target: Target,\n ...args: Ref.OptionalArgs<NoInfer<Target>>\n ): Effect.Effect<Ref.Returns<Target>, Ref.Error<Target> | Schema.SchemaError>;\n}\n\nexport class ActionCall extends Context.Service<ActionCall, Call>()(\n \"@confect/core/ActionCall\",\n) {}\nexport class Middleware extends MiddlewareSpec.MiddlewareSpec<\n Middleware,\n { provides: ActionCall }\n>()(\"@confect/core/ActionCall/Middleware\", {\n functionTypes: { query: false, mutation: false, action: true },\n}) {}\n\nexport const profile = FunctionSpec.extend()({ middleware: [Middleware] });\n"],"mappings":";;;;;;;;;;AAcA,IAAa,aAAb,cAAgC,QAAQ,QAA0B,CAAC,CACjE,0BACF,CAAC,CAAC,CAAC;AACH,IAAa,aAAb,cAAgCA,eAG9B,CAAC,CAAC,uCAAuC,EACzC,eAAe;CAAE,OAAO;CAAO,UAAU;CAAO,QAAQ;AAAK,EAC/D,CAAC,CAAC,CAAC,CAAC;AAEJ,MAAa,UAAUC,OAAoB,CAAC,CAAC,EAAE,YAAY,CAAC,UAAU,EAAE,CAAC"}
package/dist/App.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { ComponentDefinition, EnvDefinition } from "convex/server";
2
2
  import type { Infer, Validator } from "convex/values";
3
3
  import type * as HttpApi from "effect/http-api/HttpApi";
4
4
  import type * as Env from "./Env.js";
5
+ import type * as MiddlewareSpec from "./MiddlewareSpec.js";
5
6
  declare const TypeId = "~@confect/core/App";
6
7
  declare const MountTypeId = "~@confect/core/App/Mount";
7
8
  /**
@@ -36,13 +37,20 @@ type HttpOptions = {
36
37
  readonly httpPrefix: HttpPrefix;
37
38
  readonly api?: Api;
38
39
  };
39
- export type Options<D extends Definition> = HttpOptions & ([RequiredKeys<EnvOf<D>>] extends [never] ? {
40
+ export type Options<D extends Definition> = HttpOptions & {
41
+ /**
42
+ * The package specifier of the module whose `register(t, name)` the generated
43
+ * test registry calls for this mount, in place of the component package's own
44
+ * `<package>/test`. The kit registers the mount's children.
45
+ */
46
+ readonly testing?: string;
47
+ } & ([RequiredKeys<EnvOf<D>>] extends [never] ? {
40
48
  readonly env?: Bindings<EnvOf<D>>;
41
49
  } : {
42
50
  readonly env: Bindings<EnvOf<D>>;
43
51
  });
44
52
  type Exact<D extends Definition, O> = {
45
- readonly [K in Exclude<keyof O, "env" | "httpPrefix" | "api">]: never;
53
+ readonly [K in Exclude<keyof O, "env" | "httpPrefix" | "api" | "testing">]: never;
46
54
  } & (O extends {
47
55
  readonly env: infer B;
48
56
  } ? {
@@ -55,6 +63,7 @@ export interface MountData {
55
63
  readonly httpPrefix: HttpPrefix | undefined;
56
64
  readonly api: Api | undefined;
57
65
  readonly env: Readonly<Record<string, string | Env.AnyEntry | undefined>>;
66
+ readonly testing: string | undefined;
58
67
  }
59
68
  /**
60
69
  * A mounted Convex component. `O` keeps the options as written, so {@link make}
@@ -96,6 +105,7 @@ export interface App<E extends Env.Any, M extends Readonly<Record<string, AnyMou
96
105
  readonly kind: K;
97
106
  readonly env: E;
98
107
  readonly mounts: M;
108
+ readonly requiresMiddleware: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;
99
109
  }
100
110
  export type Any = App<Env.Any, Readonly<Record<string, AnyMount>>>;
101
111
  /**
@@ -120,6 +130,7 @@ export type Any = App<Env.Any, Readonly<Record<string, AnyMount>>>;
120
130
  */
121
131
  export declare const make: <const E extends Env.Any, const M extends Readonly<Record<string, AnyMount>> = {}, const K extends Kind = "app">(options: {
122
132
  readonly env: E;
133
+ readonly requiresMiddleware?: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;
123
134
  readonly mounts?: M & OwnedBy<NoInfer<Env.Name<E>>, NoInfer<M>>;
124
135
  } & ([K] extends ["app"] ? {
125
136
  readonly kind?: K;
package/dist/App.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,KAAK,OAAO,MAAM,yBAAyB,CAAC;AAExD,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AAErC,QAAA,MAAM,MAAM,uBAAuB,CAAC;AACpC,QAAA,MAAM,WAAW,6BAA6B,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEvD,MAAM,MAAM,UAAU,GAAG,IAAI,MAAM,EAAE,CAAC;AAEtC;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE/C,KAAK,KAAK,CAAC,CAAC,SAAS,UAAU,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC;AAE9C,KAAK,UAAU,CAA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E,CAAC,CAAC;IAChB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IAC9E,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;CACjE,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,KACvE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAMZ,CAAC;AAEH,eAAO,MAAM,KAAK,MAAO,OAAO,KAAG,CAAC,IAAI,GAIM,CAAC;AAE/C,eAAO,MAAM,OAAO,MAAO,OAAO,KAAG,CAAC,IAAI,QACH,CAAC;AAExC,eAAO,MAAM,GAAG,GAAI,CAAC,SAAS,GAAG,OAAO,CAAC,KAAG,CAAC,CAAC,KAAK,CAAY,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,MAAM,QACZ,GAAG,KACP,aAAa,CAAC,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAQjD,CAAC"}
package/dist/App.js CHANGED
@@ -20,7 +20,8 @@ function mount(definition, options) {
20
20
  definition,
21
21
  httpPrefix: options?.httpPrefix,
22
22
  api: options?.api,
23
- env: options?.env ?? {}
23
+ env: options?.env ?? {},
24
+ testing: options?.testing
24
25
  };
25
26
  }
26
27
  /**
@@ -47,7 +48,8 @@ const make = (options) => ({
47
48
  [TypeId]: TypeId,
48
49
  kind: options.kind ?? "app",
49
50
  env: options.env,
50
- mounts: options.mounts ?? {}
51
+ mounts: options.mounts ?? {},
52
+ requiresMiddleware: options.requiresMiddleware ?? []
51
53
  });
52
54
  const isApp = (u) => Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId && Predicate.hasProperty(u, "kind") && (u.kind === "app" || u.kind === "component");
53
55
  const isMount = (u) => Predicate.hasProperty(u, MountTypeId);
@@ -60,7 +62,8 @@ const mounts = (app) => Object.entries(app.mounts).map(([name, installed]) => ({
60
62
  definition: installed.definition,
61
63
  httpPrefix: installed.httpPrefix,
62
64
  api: installed.api,
63
- env: installed.env
65
+ env: installed.env,
66
+ testing: installed.testing
64
67
  }));
65
68
  //#endregion
66
69
  export { App_exports, env, isApp, isMount, make, mount, mounts };
package/dist/App.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"App.js","names":[],"sources":["../src/App.ts"],"sourcesContent":["import type { ComponentDefinition, EnvDefinition } from \"convex/server\";\nimport type { Infer, Validator } from \"convex/values\";\nimport type * as HttpApi from \"effect/http-api/HttpApi\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Env from \"./Env.js\";\n\nconst TypeId = \"~@confect/core/App\";\nconst MountTypeId = \"~@confect/core/App/Mount\";\n\n/**\n * The default export of a Convex component's `convex.config` module.\n */\nexport type Definition = ComponentDefinition<any, any>;\n\nexport type HttpPrefix = `/${string}`;\n\n/**\n * Any `HttpApi`, with its identifier and groups erased.\n */\nexport type Api = HttpApi.HttpApi<string, any>;\n\ntype EnvOf<D extends Definition> = D[\"__env\"];\n\ntype IsOptional<V> = V extends Validator<any, \"optional\", any> ? true : false;\n\ntype RequiredKeys<E extends EnvDefinition> = {\n [K in keyof E]: IsOptional<E[K]> extends true ? never : K;\n}[keyof E];\n\ntype SlotValue<V extends Validator<any, any, any>> = Extract<Infer<V>, string>;\n\n/**\n * What one component env slot accepts: a constant, or an entry whose Convex\n * value fits. A required slot takes only a required entry.\n */\ntype Slot<V extends Validator<any, any, any>> =\n IsOptional<V> extends true\n ? SlotValue<V> | undefined | Env.Entry<string, any, SlotValue<V>, boolean>\n : SlotValue<V> | Env.Entry<string, any, SlotValue<V>, false>;\n\nexport type Bindings<E extends EnvDefinition> = {\n readonly [K in RequiredKeys<E>]: Slot<E[K]>;\n} & {\n readonly [K in Exclude<keyof E, RequiredKeys<E>>]?: Slot<E[K]>;\n};\n\ntype HttpOptions =\n | { readonly httpPrefix?: never; readonly api?: never }\n | { readonly httpPrefix: HttpPrefix; readonly api?: Api };\n\nexport type Options<D extends Definition> = HttpOptions &\n ([RequiredKeys<EnvOf<D>>] extends [never]\n ? { readonly env?: Bindings<EnvOf<D>> }\n : { readonly env: Bindings<EnvOf<D>> });\n\ntype Exact<D extends Definition, O> = {\n readonly [K in Exclude<keyof O, \"env\" | \"httpPrefix\" | \"api\">]: never;\n} & (O extends { readonly env: infer B }\n ? {\n readonly env: { readonly [K in Exclude<keyof B, keyof EnvOf<D>>]: never };\n }\n : unknown);\n\nexport interface MountData {\n readonly definition: Definition;\n readonly httpPrefix: HttpPrefix | undefined;\n readonly api: Api | undefined;\n readonly env: Readonly<Record<string, string | Env.AnyEntry | undefined>>;\n}\n\n/**\n * A mounted Convex component. `O` keeps the options as written, so {@link make}\n * can see which backends the bound entries come from.\n */\nexport interface Mount<out D extends Definition, out O> extends MountData {\n readonly [MountTypeId]: { readonly definition: D; readonly options: O };\n readonly httpPrefix: O extends {\n readonly httpPrefix: infer P extends HttpPrefix;\n }\n ? P\n : undefined;\n}\n\nexport type AnyMount = Mount<Definition, unknown>;\n\n/**\n * Mount a Convex component: the default export of its `convex.config` module,\n * official or Confect-authored. `env` is typed against the component's own\n * `defineComponent({ env })` declaration, so a missing required binding, an\n * optional entry in a required slot, a wrong literal and an unknown slot fail\n * to typecheck. `api` is the component's `HttpApi`, for route checks.\n */\nexport function mount<const D extends Definition>(\n definition: D &\n ([RequiredKeys<EnvOf<D>>] extends [never]\n ? unknown\n : \"App.mount: this component declares required env; pass { env }\"),\n): Mount<D, {}>;\nexport function mount<const D extends Definition, const O extends Options<D>>(\n definition: D,\n options: O & Exact<NoInfer<D>, NoInfer<O>>,\n): Mount<D, O>;\nexport function mount(\n definition: Definition,\n options?: {\n readonly httpPrefix?: HttpPrefix;\n readonly api?: Api;\n readonly env?: MountData[\"env\"];\n },\n): AnyMount {\n return {\n [MountTypeId]: { definition, options },\n definition,\n httpPrefix: options?.httpPrefix,\n api: options?.api,\n env: options?.env ?? {},\n // The overloads above carry the precise types; this body serves both.\n } as AnyMount;\n}\n\ntype OwnerOf<V> = V extends Env.Entry<infer N, any, any, any> ? N : never;\n\ntype Owners<M> =\n M extends Mount<Definition, infer O>\n ? O extends { readonly env: infer B }\n ? { [K in keyof B]: OwnerOf<B[K]> }[keyof B]\n : never\n : never;\n\ntype OwnedBy<N extends string, M> = {\n readonly [K in keyof M]: [Exclude<Owners<M[K]>, N>] extends [never]\n ? unknown\n : { readonly foreignEnvBackend: Exclude<Owners<M[K]>, N> };\n};\n\nexport type Kind = \"app\" | \"component\";\n\nexport interface App<\n E extends Env.Any,\n M extends Readonly<Record<string, AnyMount>>,\n K extends Kind = Kind,\n> {\n readonly [TypeId]: typeof TypeId;\n readonly kind: K;\n readonly env: E;\n readonly mounts: M;\n}\n\nexport type Any = App<Env.Any, Readonly<Record<string, AnyMount>>>;\n\n/**\n * Declare a backend, in `confect/app.ts`: its env and its mounted Convex\n * components by name. Set `kind: \"component\"` when declaring a component; the\n * default is `\"app\"`. Codegen rejects a kind that differs from its target.\n * Codegen writes `convex/convex.config.ts` from it. A mount that binds another\n * backend's env entry fails to typecheck.\n *\n * ```ts\n * export default App.make({\n * env,\n * mounts: {\n * email: App.mount(email, {\n * httpPrefix: \"/email\",\n * env: { FROM: env.EMAIL_FROM, KEY: env.RESEND_API_KEY },\n * }),\n * importsPool: App.mount(workpool),\n * },\n * });\n * ```\n */\nexport const make = <\n const E extends Env.Any,\n const M extends Readonly<Record<string, AnyMount>> = {},\n const K extends Kind = \"app\",\n>(\n options: {\n readonly env: E;\n readonly mounts?: M & OwnedBy<NoInfer<Env.Name<E>>, NoInfer<M>>;\n } & ([K] extends [\"app\"] ? { readonly kind?: K } : { readonly kind: K }),\n): App<E, M, K> => ({\n [TypeId]: TypeId,\n kind: options.kind ?? (\"app\" as K),\n env: options.env,\n mounts: options.mounts ?? ({} as M),\n});\n\nexport const isApp = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) &&\n u[TypeId] === TypeId &&\n Predicate.hasProperty(u, \"kind\") &&\n (u.kind === \"app\" || u.kind === \"component\");\n\nexport const isMount = (u: unknown): u is AnyMount =>\n Predicate.hasProperty(u, MountTypeId);\n\nexport const env = <A extends Any>(app: A): A[\"env\"] => app.env;\n\n/**\n * Every mount with its name, in declaration order.\n */\nexport const mounts = (\n app: Any,\n): ReadonlyArray<MountData & { readonly name: string }> =>\n Object.entries(app.mounts).map(([name, installed]) => ({\n name,\n definition: installed.definition,\n httpPrefix: installed.httpPrefix,\n api: installed.api,\n env: installed.env,\n }));\n"],"mappings":";;;;;;;;;;;AAMA,MAAM,SAAS;AACf,MAAM,cAAc;AA+FpB,SAAgB,MACd,YACA,SAKU;CACV,OAAO;GACJ,cAAc;GAAE;GAAY;EAAQ;EACrC;EACA,YAAY,SAAS;EACrB,KAAK,SAAS;EACd,KAAK,SAAS,OAAO,CAAC;CAExB;AACF;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAa,QAKX,aAIkB;EACjB,SAAS;CACV,MAAM,QAAQ,QAAS;CACvB,KAAK,QAAQ;CACb,QAAQ,QAAQ,UAAW,CAAC;AAC9B;AAEA,MAAa,SAAS,MACpB,UAAU,YAAY,GAAG,MAAM,KAC/B,EAAE,YAAY,UACd,UAAU,YAAY,GAAG,MAAM,MAC9B,EAAE,SAAS,SAAS,EAAE,SAAS;AAElC,MAAa,WAAW,MACtB,UAAU,YAAY,GAAG,WAAW;AAEtC,MAAa,OAAsB,QAAqB,IAAI;;;;AAK5D,MAAa,UACX,QAEA,OAAO,QAAQ,IAAI,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,gBAAgB;CACrD;CACA,YAAY,UAAU;CACtB,YAAY,UAAU;CACtB,KAAK,UAAU;CACf,KAAK,UAAU;AACjB,EAAE"}
1
+ {"version":3,"file":"App.js","names":[],"sources":["../src/App.ts"],"sourcesContent":["import type { ComponentDefinition, EnvDefinition } from \"convex/server\";\nimport type { Infer, Validator } from \"convex/values\";\nimport type * as HttpApi from \"effect/http-api/HttpApi\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Env from \"./Env.js\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.js\";\n\nconst TypeId = \"~@confect/core/App\";\nconst MountTypeId = \"~@confect/core/App/Mount\";\n\n/**\n * The default export of a Convex component's `convex.config` module.\n */\nexport type Definition = ComponentDefinition<any, any>;\n\nexport type HttpPrefix = `/${string}`;\n\n/**\n * Any `HttpApi`, with its identifier and groups erased.\n */\nexport type Api = HttpApi.HttpApi<string, any>;\n\ntype EnvOf<D extends Definition> = D[\"__env\"];\n\ntype IsOptional<V> = V extends Validator<any, \"optional\", any> ? true : false;\n\ntype RequiredKeys<E extends EnvDefinition> = {\n [K in keyof E]: IsOptional<E[K]> extends true ? never : K;\n}[keyof E];\n\ntype SlotValue<V extends Validator<any, any, any>> = Extract<Infer<V>, string>;\n\n/**\n * What one component env slot accepts: a constant, or an entry whose Convex\n * value fits. A required slot takes only a required entry.\n */\ntype Slot<V extends Validator<any, any, any>> =\n IsOptional<V> extends true\n ? SlotValue<V> | undefined | Env.Entry<string, any, SlotValue<V>, boolean>\n : SlotValue<V> | Env.Entry<string, any, SlotValue<V>, false>;\n\nexport type Bindings<E extends EnvDefinition> = {\n readonly [K in RequiredKeys<E>]: Slot<E[K]>;\n} & {\n readonly [K in Exclude<keyof E, RequiredKeys<E>>]?: Slot<E[K]>;\n};\n\ntype HttpOptions =\n | { readonly httpPrefix?: never; readonly api?: never }\n | { readonly httpPrefix: HttpPrefix; readonly api?: Api };\n\nexport type Options<D extends Definition> = HttpOptions & {\n /**\n * The package specifier of the module whose `register(t, name)` the generated\n * test registry calls for this mount, in place of the component package's own\n * `<package>/test`. The kit registers the mount's children.\n */\n readonly testing?: string;\n} & ([RequiredKeys<EnvOf<D>>] extends [never]\n ? { readonly env?: Bindings<EnvOf<D>> }\n : { readonly env: Bindings<EnvOf<D>> });\n\ntype Exact<D extends Definition, O> = {\n readonly [\n K in Exclude<keyof O, \"env\" | \"httpPrefix\" | \"api\" | \"testing\">\n ]: never;\n} & (O extends { readonly env: infer B }\n ? {\n readonly env: { readonly [K in Exclude<keyof B, keyof EnvOf<D>>]: never };\n }\n : unknown);\n\nexport interface MountData {\n readonly definition: Definition;\n readonly httpPrefix: HttpPrefix | undefined;\n readonly api: Api | undefined;\n readonly env: Readonly<Record<string, string | Env.AnyEntry | undefined>>;\n readonly testing: string | undefined;\n}\n\n/**\n * A mounted Convex component. `O` keeps the options as written, so {@link make}\n * can see which backends the bound entries come from.\n */\nexport interface Mount<out D extends Definition, out O> extends MountData {\n readonly [MountTypeId]: { readonly definition: D; readonly options: O };\n readonly httpPrefix: O extends {\n readonly httpPrefix: infer P extends HttpPrefix;\n }\n ? P\n : undefined;\n}\n\nexport type AnyMount = Mount<Definition, unknown>;\n\n/**\n * Mount a Convex component: the default export of its `convex.config` module,\n * official or Confect-authored. `env` is typed against the component's own\n * `defineComponent({ env })` declaration, so a missing required binding, an\n * optional entry in a required slot, a wrong literal and an unknown slot fail\n * to typecheck. `api` is the component's `HttpApi`, for route checks.\n */\nexport function mount<const D extends Definition>(\n definition: D &\n ([RequiredKeys<EnvOf<D>>] extends [never]\n ? unknown\n : \"App.mount: this component declares required env; pass { env }\"),\n): Mount<D, {}>;\nexport function mount<const D extends Definition, const O extends Options<D>>(\n definition: D,\n options: O & Exact<NoInfer<D>, NoInfer<O>>,\n): Mount<D, O>;\nexport function mount(\n definition: Definition,\n options?: {\n readonly httpPrefix?: HttpPrefix;\n readonly api?: Api;\n readonly env?: MountData[\"env\"];\n readonly testing?: string;\n },\n): AnyMount {\n return {\n [MountTypeId]: { definition, options },\n definition,\n httpPrefix: options?.httpPrefix,\n api: options?.api,\n env: options?.env ?? {},\n testing: options?.testing,\n // The overloads above carry the precise types; this body serves both.\n } as AnyMount;\n}\n\ntype OwnerOf<V> = V extends Env.Entry<infer N, any, any, any> ? N : never;\n\ntype Owners<M> =\n M extends Mount<Definition, infer O>\n ? O extends { readonly env: infer B }\n ? { [K in keyof B]: OwnerOf<B[K]> }[keyof B]\n : never\n : never;\n\ntype OwnedBy<N extends string, M> = {\n readonly [K in keyof M]: [Exclude<Owners<M[K]>, N>] extends [never]\n ? unknown\n : { readonly foreignEnvBackend: Exclude<Owners<M[K]>, N> };\n};\n\nexport type Kind = \"app\" | \"component\";\n\nexport interface App<\n E extends Env.Any,\n M extends Readonly<Record<string, AnyMount>>,\n K extends Kind = Kind,\n> {\n readonly [TypeId]: typeof TypeId;\n readonly kind: K;\n readonly env: E;\n readonly mounts: M;\n readonly requiresMiddleware: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n}\n\nexport type Any = App<Env.Any, Readonly<Record<string, AnyMount>>>;\n\n/**\n * Declare a backend, in `confect/app.ts`: its env and its mounted Convex\n * components by name. Set `kind: \"component\"` when declaring a component; the\n * default is `\"app\"`. Codegen rejects a kind that differs from its target.\n * Codegen writes `convex/convex.config.ts` from it. A mount that binds another\n * backend's env entry fails to typecheck.\n *\n * ```ts\n * export default App.make({\n * env,\n * mounts: {\n * email: App.mount(email, {\n * httpPrefix: \"/email\",\n * env: { FROM: env.EMAIL_FROM, KEY: env.RESEND_API_KEY },\n * }),\n * importsPool: App.mount(workpool),\n * },\n * });\n * ```\n */\nexport const make = <\n const E extends Env.Any,\n const M extends Readonly<Record<string, AnyMount>> = {},\n const K extends Kind = \"app\",\n>(\n options: {\n readonly env: E;\n readonly requiresMiddleware?: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly mounts?: M & OwnedBy<NoInfer<Env.Name<E>>, NoInfer<M>>;\n } & ([K] extends [\"app\"] ? { readonly kind?: K } : { readonly kind: K }),\n): App<E, M, K> => ({\n [TypeId]: TypeId,\n kind: options.kind ?? (\"app\" as K),\n env: options.env,\n mounts: options.mounts ?? ({} as M),\n requiresMiddleware: options.requiresMiddleware ?? [],\n});\n\nexport const isApp = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) &&\n u[TypeId] === TypeId &&\n Predicate.hasProperty(u, \"kind\") &&\n (u.kind === \"app\" || u.kind === \"component\");\n\nexport const isMount = (u: unknown): u is AnyMount =>\n Predicate.hasProperty(u, MountTypeId);\n\nexport const env = <A extends Any>(app: A): A[\"env\"] => app.env;\n\n/**\n * Every mount with its name, in declaration order.\n */\nexport const mounts = (\n app: Any,\n): ReadonlyArray<MountData & { readonly name: string }> =>\n Object.entries(app.mounts).map(([name, installed]) => ({\n name,\n definition: installed.definition,\n httpPrefix: installed.httpPrefix,\n api: installed.api,\n env: installed.env,\n testing: installed.testing,\n }));\n"],"mappings":";;;;;;;;;;;AAOA,MAAM,SAAS;AACf,MAAM,cAAc;AAwGpB,SAAgB,MACd,YACA,SAMU;CACV,OAAO;GACJ,cAAc;GAAE;GAAY;EAAQ;EACrC;EACA,YAAY,SAAS;EACrB,KAAK,SAAS;EACd,KAAK,SAAS,OAAO,CAAC;EACtB,SAAS,SAAS;CAEpB;AACF;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAa,QAKX,aAKkB;EACjB,SAAS;CACV,MAAM,QAAQ,QAAS;CACvB,KAAK,QAAQ;CACb,QAAQ,QAAQ,UAAW,CAAC;CAC5B,oBAAoB,QAAQ,sBAAsB,CAAC;AACrD;AAEA,MAAa,SAAS,MACpB,UAAU,YAAY,GAAG,MAAM,KAC/B,EAAE,YAAY,UACd,UAAU,YAAY,GAAG,MAAM,MAC9B,EAAE,SAAS,SAAS,EAAE,SAAS;AAElC,MAAa,WAAW,MACtB,UAAU,YAAY,GAAG,WAAW;AAEtC,MAAa,OAAsB,QAAqB,IAAI;;;;AAK5D,MAAa,UACX,QAEA,OAAO,QAAQ,IAAI,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,gBAAgB;CACrD;CACA,YAAY,UAAU;CACtB,YAAY,UAAU;CACtB,KAAK,UAAU;CACf,KAAK,UAAU;CACf,SAAS,UAAU;AACrB,EAAE"}
package/dist/Auth.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import type { AuthProvider } from "convex/server";
2
2
  import type * as App from "./App.js";
3
+ import type * as Env from "./Env.js";
3
4
  import type { TypeError } from "./Types.js";
4
5
  declare const TypeId = "~@confect/core/Auth";
6
+ declare const CloudUrlTypeId = "~@confect/core/Auth/CloudUrl";
5
7
  declare const SiteUrlTypeId = "~@confect/core/Auth/SiteUrl";
6
8
  /**
7
9
  * The deployment's site URL (`CONVEX_SITE_URL`) plus a path, resolved when
@@ -11,15 +13,38 @@ export interface SiteUrl {
11
13
  readonly [SiteUrlTypeId]: typeof SiteUrlTypeId;
12
14
  readonly path: string;
13
15
  }
14
- type Url = string | SiteUrl;
15
- type WithSiteUrl<P> = P extends unknown ? {
16
- [K in keyof P]: K extends "domain" | "issuer" | "jwks" ? Url : P[K];
16
+ /**
17
+ * The deployment's cloud URL (`CONVEX_CLOUD_URL`) plus a path.
18
+ */
19
+ export interface CloudUrl {
20
+ readonly [CloudUrlTypeId]: typeof CloudUrlTypeId;
21
+ readonly path: string;
22
+ }
23
+ type Url = string | SiteUrl | CloudUrl | Env.Entry<string, string, string, false>;
24
+ type WithUrls<P> = P extends unknown ? {
25
+ [K in keyof P]: K extends "domain" | "issuer" | "jwks" | "applicationID" ? Url : P[K];
17
26
  } : never;
18
27
  /**
19
- * Convex's `AuthProvider`, with `domain`, `issuer` and `jwks` also taking a
20
- * {@link SiteUrl}.
28
+ * Convex's provider list with deployment URLs and required, public env strings.
29
+ */
30
+ export type Provider = WithUrls<AuthProvider> & {
31
+ /**
32
+ * Application-defined token family, copied to the runtime provider data.
33
+ */
34
+ readonly family?: string;
35
+ /**
36
+ * Application-defined issuer name, for example a trusted service.
37
+ */
38
+ readonly name?: string;
39
+ };
40
+ /**
41
+ * The cloud URL, or a path under it, resolved when Convex loads auth config.
42
+ */
43
+ export declare const cloudUrl: (path?: `/${string}` | "") => CloudUrl;
44
+ /**
45
+ * The path of a cloud URL placeholder, or `undefined` for another value.
21
46
  */
22
- export type Provider = WithSiteUrl<AuthProvider>;
47
+ export declare const cloudUrlPath: (u: unknown) => string | undefined;
23
48
  export interface Auth<A extends App.Any> {
24
49
  readonly [TypeId]: typeof TypeId;
25
50
  readonly app: A;
@@ -1 +1 @@
1
- {"version":3,"file":"Auth.d.ts","sourceRoot":"","sources":["../src/Auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,QAAA,MAAM,MAAM,wBAAwB,CAAC;AACrC,QAAA,MAAM,aAAa,gCAAgC,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,CAAC,aAAa,CAAC,EAAE,OAAO,aAAa,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,KAAK,GAAG,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5B,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,GACnC;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;CACpE,GACD,KAAK,CAAC;AAEV;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;AAEjD,MAAM,WAAW,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,GAAG;IACrC,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAC;IACjC,QAAQ,CAAC,GAAG,EAA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AAa,CAAC,QAAQ,CAAmB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,WAAW,MAAO,OAAO,KAAG,MAAM,GAAG,SAKnC,CAAC"}
package/dist/Auth.js CHANGED
@@ -2,6 +2,8 @@ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import * as Predicate from "effect/Predicate";
3
3
  //#region src/Auth.ts
4
4
  var Auth_exports = /* @__PURE__ */ __exportAll({
5
+ cloudUrl: () => cloudUrl,
6
+ cloudUrlPath: () => cloudUrlPath,
5
7
  isAuth: () => isAuth,
6
8
  make: () => make,
7
9
  providers: () => providers,
@@ -9,7 +11,19 @@ var Auth_exports = /* @__PURE__ */ __exportAll({
9
11
  siteUrlPath: () => siteUrlPath
10
12
  });
11
13
  const TypeId = "~@confect/core/Auth";
14
+ const CloudUrlTypeId = "~@confect/core/Auth/CloudUrl";
12
15
  const SiteUrlTypeId = "~@confect/core/Auth/SiteUrl";
16
+ /**
17
+ * The cloud URL, or a path under it, resolved when Convex loads auth config.
18
+ */
19
+ const cloudUrl = (path = "") => ({
20
+ [CloudUrlTypeId]: CloudUrlTypeId,
21
+ path
22
+ });
23
+ /**
24
+ * The path of a cloud URL placeholder, or `undefined` for another value.
25
+ */
26
+ const cloudUrlPath = (u) => Predicate.hasProperty(u, CloudUrlTypeId) && Predicate.hasProperty(u, "path") && typeof u.path === "string" ? u.path : void 0;
13
27
  function siteUrl(pathOrMount, path = "") {
14
28
  return {
15
29
  [SiteUrlTypeId]: SiteUrlTypeId,
@@ -41,6 +55,6 @@ const providers = (auth) => auth.providers;
41
55
  */
42
56
  const siteUrlPath = (u) => Predicate.hasProperty(u, SiteUrlTypeId) && Predicate.hasProperty(u, "path") && typeof u.path === "string" ? u.path : void 0;
43
57
  //#endregion
44
- export { Auth_exports, isAuth, make, providers, siteUrl, siteUrlPath };
58
+ export { Auth_exports, cloudUrl, cloudUrlPath, isAuth, make, providers, siteUrl, siteUrlPath };
45
59
 
46
60
  //# sourceMappingURL=Auth.js.map
package/dist/Auth.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Auth.js","names":[],"sources":["../src/Auth.ts"],"sourcesContent":["import type { AuthProvider } from \"convex/server\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as App from \"./App.js\";\nimport type { TypeError } from \"./Types.js\";\n\nconst TypeId = \"~@confect/core/Auth\";\nconst SiteUrlTypeId = \"~@confect/core/Auth/SiteUrl\";\n\n/**\n * The deployment's site URL (`CONVEX_SITE_URL`) plus a path, resolved when\n * Convex loads `auth.config.ts`.\n */\nexport interface SiteUrl {\n readonly [SiteUrlTypeId]: typeof SiteUrlTypeId;\n readonly path: string;\n}\n\ntype Url = string | SiteUrl;\n\ntype WithSiteUrl<P> = P extends unknown\n ? {\n [K in keyof P]: K extends \"domain\" | \"issuer\" | \"jwks\" ? Url : P[K];\n }\n : never;\n\n/**\n * Convex's `AuthProvider`, with `domain`, `issuer` and `jwks` also taking a\n * {@link SiteUrl}.\n */\nexport type Provider = WithSiteUrl<AuthProvider>;\n\nexport interface Auth<A extends App.Any> {\n readonly [TypeId]: typeof TypeId;\n readonly app: A;\n readonly providers: ReadonlyArray<Provider>;\n}\n\nexport type Any = Auth<App.Any>;\n\n/**\n * The site URL, or a path under it. Pass a mount to point at that mounted\n * component's HTTP routes.\n */\nexport function siteUrl(path?: `/${string}`): SiteUrl;\nexport function siteUrl(\n mount: { readonly httpPrefix: App.HttpPrefix },\n path?: `/${string}`,\n): SiteUrl;\nexport function siteUrl(\n pathOrMount?: `/${string}` | { readonly httpPrefix: App.HttpPrefix },\n path: string = \"\",\n): SiteUrl {\n return {\n [SiteUrlTypeId]: SiteUrlTypeId,\n path:\n typeof pathOrMount === \"object\"\n ? pathOrMount.httpPrefix.replace(/\\/+$/, \"\") + path\n : (pathOrMount ?? \"\"),\n };\n}\n\nexport type AppOnlyError = TypeError<\n \"Auth.make accepts only app declarations; components receive identity through function arguments\",\n never\n>;\n\ntype AppOnly<A extends App.Any> = [A[\"kind\"]] extends [\"app\"]\n ? unknown\n : AppOnlyError;\n\n/**\n * Declare the identity providers whose tokens the backend accepts, in\n * `confect/auth.ts`. This is Convex's own provider list; codegen writes it to\n * `convex/auth.config.ts`.\n *\n * ```ts\n * export default Auth.make(app, {\n * providers: [\n * { domain: \"https://login.example.edu\", applicationID: \"tenant\" },\n * ],\n * });\n * ```\n */\nexport const make = <A extends App.Any>(\n app: A & AppOnly<NoInfer<A>>,\n options: { readonly providers: ReadonlyArray<Provider> },\n): Auth<A> => ({ [TypeId]: TypeId, app, providers: options.providers });\n\nexport const isAuth = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId;\n\nexport const providers = (auth: Any): ReadonlyArray<Provider> => auth.providers;\n\n/**\n * The path of a {@link SiteUrl}, or `undefined` for any other value.\n */\nexport const siteUrlPath = (u: unknown): string | undefined =>\n Predicate.hasProperty(u, SiteUrlTypeId) &&\n Predicate.hasProperty(u, \"path\") &&\n typeof u.path === \"string\"\n ? u.path\n : undefined;\n"],"mappings":";;;;;;;;;;AAKA,MAAM,SAAS;AACf,MAAM,gBAAgB;AA0CtB,SAAgB,QACd,aACA,OAAe,IACN;CACT,OAAO;GACJ,gBAAgB;EACjB,MACE,OAAO,gBAAgB,WACnB,YAAY,WAAW,QAAQ,QAAQ,EAAE,IAAI,OAC5C,eAAe;CACxB;AACF;;;;;;;;;;;;;;AAwBA,MAAa,QACX,KACA,aACa;EAAG,SAAS;CAAQ;CAAK,WAAW,QAAQ;AAAU;AAErE,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,MAAM,KAAK,EAAE,YAAY;AAEpD,MAAa,aAAa,SAAuC,KAAK;;;;AAKtE,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,aAAa,KACtC,UAAU,YAAY,GAAG,MAAM,KAC/B,OAAO,EAAE,SAAS,WACd,EAAE,OACF,KAAA"}
1
+ {"version":3,"file":"Auth.js","names":[],"sources":["../src/Auth.ts"],"sourcesContent":["import type { AuthProvider } from \"convex/server\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as App from \"./App.js\";\nimport type * as Env from \"./Env.js\";\nimport type { TypeError } from \"./Types.js\";\n\nconst TypeId = \"~@confect/core/Auth\";\nconst CloudUrlTypeId = \"~@confect/core/Auth/CloudUrl\";\nconst SiteUrlTypeId = \"~@confect/core/Auth/SiteUrl\";\n\n/**\n * The deployment's site URL (`CONVEX_SITE_URL`) plus a path, resolved when\n * Convex loads `auth.config.ts`.\n */\nexport interface SiteUrl {\n readonly [SiteUrlTypeId]: typeof SiteUrlTypeId;\n readonly path: string;\n}\n\n/**\n * The deployment's cloud URL (`CONVEX_CLOUD_URL`) plus a path.\n */\nexport interface CloudUrl {\n readonly [CloudUrlTypeId]: typeof CloudUrlTypeId;\n readonly path: string;\n}\n\ntype Url =\n | string\n | SiteUrl\n | CloudUrl\n | Env.Entry<string, string, string, false>;\n\ntype WithUrls<P> = P extends unknown\n ? {\n [K in keyof P]: K extends \"domain\" | \"issuer\" | \"jwks\" | \"applicationID\"\n ? Url\n : P[K];\n }\n : never;\n\n/**\n * Convex's provider list with deployment URLs and required, public env strings.\n */\nexport type Provider = WithUrls<AuthProvider> & {\n /**\n * Application-defined token family, copied to the runtime provider data.\n */\n readonly family?: string;\n /**\n * Application-defined issuer name, for example a trusted service.\n */\n readonly name?: string;\n};\n\n/**\n * The cloud URL, or a path under it, resolved when Convex loads auth config.\n */\nexport const cloudUrl = (path: `/${string}` | \"\" = \"\"): CloudUrl => ({\n [CloudUrlTypeId]: CloudUrlTypeId,\n path,\n});\n\n/**\n * The path of a cloud URL placeholder, or `undefined` for another value.\n */\nexport const cloudUrlPath = (u: unknown): string | undefined =>\n Predicate.hasProperty(u, CloudUrlTypeId) &&\n Predicate.hasProperty(u, \"path\") &&\n typeof u.path === \"string\"\n ? u.path\n : undefined;\n\nexport interface Auth<A extends App.Any> {\n readonly [TypeId]: typeof TypeId;\n readonly app: A;\n readonly providers: ReadonlyArray<Provider>;\n}\n\nexport type Any = Auth<App.Any>;\n\n/**\n * The site URL, or a path under it. Pass a mount to point at that mounted\n * component's HTTP routes.\n */\nexport function siteUrl(path?: `/${string}`): SiteUrl;\nexport function siteUrl(\n mount: { readonly httpPrefix: App.HttpPrefix },\n path?: `/${string}`,\n): SiteUrl;\nexport function siteUrl(\n pathOrMount?: `/${string}` | { readonly httpPrefix: App.HttpPrefix },\n path: string = \"\",\n): SiteUrl {\n return {\n [SiteUrlTypeId]: SiteUrlTypeId,\n path:\n typeof pathOrMount === \"object\"\n ? pathOrMount.httpPrefix.replace(/\\/+$/, \"\") + path\n : (pathOrMount ?? \"\"),\n };\n}\n\nexport type AppOnlyError = TypeError<\n \"Auth.make accepts only app declarations; components receive identity through function arguments\",\n never\n>;\n\ntype AppOnly<A extends App.Any> = [A[\"kind\"]] extends [\"app\"]\n ? unknown\n : AppOnlyError;\n\n/**\n * Declare the identity providers whose tokens the backend accepts, in\n * `confect/auth.ts`. This is Convex's own provider list; codegen writes it to\n * `convex/auth.config.ts`.\n *\n * ```ts\n * export default Auth.make(app, {\n * providers: [\n * { domain: \"https://login.example.edu\", applicationID: \"tenant\" },\n * ],\n * });\n * ```\n */\nexport const make = <A extends App.Any>(\n app: A & AppOnly<NoInfer<A>>,\n options: { readonly providers: ReadonlyArray<Provider> },\n): Auth<A> => ({ [TypeId]: TypeId, app, providers: options.providers });\n\nexport const isAuth = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId;\n\nexport const providers = (auth: Any): ReadonlyArray<Provider> => auth.providers;\n\n/**\n * The path of a {@link SiteUrl}, or `undefined` for any other value.\n */\nexport const siteUrlPath = (u: unknown): string | undefined =>\n Predicate.hasProperty(u, SiteUrlTypeId) &&\n Predicate.hasProperty(u, \"path\") &&\n typeof u.path === \"string\"\n ? u.path\n : undefined;\n"],"mappings":";;;;;;;;;;;;AAMA,MAAM,SAAS;AACf,MAAM,iBAAiB;AACvB,MAAM,gBAAgB;;;;AAkDt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AAI;IAC/D,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;CAC1B,SAAS,CAAC,KAAK,CAAC,GACb,OAAO,GACP;IAAE,QAAQ,CAAC,mBAAmB,EAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;CAAE,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,SAAS,GAAG,CAAC,GAAG,OACtC,IAAI,KACR,wBAAwB,CACzB,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,EACzB,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAC/B,WAAW,CAAC,IAAI,CAAC,EACjB,cAAc,CAAC,IAAI,CAAC,CACiB,CAAC"}
package/dist/Callback.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
2
  import { Confect } from "./FunctionProvenance.js";
3
- import { fromProvenance, getFunctionReference, isRef } from "./Ref.js";
4
- import * as Predicate from "effect/Predicate";
3
+ import { getFunctionReference } from "./RefInternal.js";
4
+ import { fromProvenance, isRef } from "./Ref.js";
5
5
  import * as Schema from "effect/Schema";
6
+ import * as Predicate from "effect/Predicate";
6
7
  import * as SchemaGetter from "effect/SchemaGetter";
7
8
  //#region src/Callback.ts
8
9
  var Callback_exports = /* @__PURE__ */ __exportAll({
@@ -27,7 +28,7 @@ const query = make("query");
27
28
  const mutation = make("mutation");
28
29
  const action = make("action");
29
30
  const isHandleOf = (contract) => (value) => isRef(value) && Predicate.hasProperty(value, HandleTypeId) && value[HandleTypeId] === contract.id;
30
- const fromText = (contract, text) => Object.assign(fromProvenance(text, contract.functionProvenance, [], text), { [HandleTypeId]: contract.id });
31
+ const fromText = (contract, text) => Object.assign(fromProvenance(text, contract.functionProvenance, [], text, contract.functionType), { [HandleTypeId]: contract.id });
31
32
  /**
32
33
  * The schema of a handle for `contract`: a string on the wire, a runnable ref
33
34
  * once decoded. Use it in a component's function args or tables.
@@ -1 +1 @@
1
- {"version":3,"file":"Callback.js","names":["FunctionProvenance.Confect","Ref.isRef","Ref.fromProvenance","Ref.getFunctionReference"],"sources":["../src/Callback.ts"],"sourcesContent":["import type {\n FunctionReference,\n FunctionReference_future,\n FunctionType,\n} from \"convex/server\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\nimport * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport * as Ref from \"./Ref.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/Callback\";\nexport type TypeId = typeof TypeId;\n\nconst HandleTypeId = \"~@confect/core/Callback/Handle\";\n\n/**\n * A contract's id, `\"<component>/<event>\"`.\n */\nexport type Id = `${string}/${string}`;\n\n/**\n * A function a component calls back into its host, declared by the component:\n * the args it sends and the returns and errors it accepts. A host proves that\n * one of its functions satisfies the contract when it creates a handle.\n */\nexport interface Contract<\n Id_ extends Id,\n FunctionType_ extends FunctionType,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n> {\n readonly [TypeId]: TypeId;\n readonly id: Id_;\n readonly functionType: FunctionType_;\n readonly functionProvenance: FunctionProvenance.Confect<\n ArgsFields_,\n Returns_,\n Error_,\n FunctionProvenance.Standard\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n readonly id: Id;\n readonly functionType: FunctionType;\n readonly functionProvenance: FunctionProvenance.AnyConfect;\n}\n\nexport const isContract = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId;\n\ntype ArgsFields<Contract_ extends Any> =\n Contract_[\"functionProvenance\"] extends {\n readonly \"~ArgsFields\": infer ArgsFields_ extends\n FunctionProvenance.ArgsFields;\n }\n ? ArgsFields_\n : never;\n\ntype ReturnsSchema<Contract_ extends Any> =\n Contract_[\"functionProvenance\"][\"returns\"];\n\ntype ErrorSchema<Contract_ extends Any> =\n Contract_[\"functionProvenance\"] extends {\n readonly error?: infer ErrorSchema_;\n }\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\n : never;\n\nexport type Args<Contract_ extends Any> = Schema.Struct.Type<\n ArgsFields<Contract_>\n>;\n\nexport type Returns<Contract_ extends Any> = ReturnsSchema<Contract_>[\"Type\"];\n\nexport type Error<Contract_ extends Any> = ErrorSchema<Contract_>[\"Type\"];\n\n/**\n * A host function a component received for a contract. It is a ref, so the\n * runners and the scheduler run it with the contract's codecs, and declared\n * errors arrive by tag.\n */\nexport type Handle<Contract_ extends Any> = Ref.ConfectRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n {\n readonly runtime: \"Convex\";\n readonly functionType: Contract_[\"functionType\"];\n }\n >,\n \"internal\",\n ArgsFields<Contract_>,\n ReturnsSchema<Contract_>,\n ErrorSchema<Contract_>\n> & { readonly [HandleTypeId]: Contract_[\"id\"] };\n\nconst make =\n <FunctionType_ extends FunctionType>(functionType: FunctionType_) =>\n <\n const Id_ extends Id,\n const ArgsFields_ extends FunctionProvenance.ArgsFields = {},\n Returns_ extends Schema.Codec<any, any> = never,\n Error_ extends Schema.Codec<any, any> = never,\n >(\n id: Id_,\n options: {\n readonly args?: () => ArgsFields_;\n readonly returns: () => Returns_;\n readonly error?: () => Error_;\n },\n ): Contract<Id_, FunctionType_, ArgsFields_, Returns_, Error_> => ({\n [TypeId]: TypeId,\n id,\n functionType,\n functionProvenance: FunctionProvenance.Confect(\n options.args ?? (() => ({}) as ArgsFields_),\n options.returns,\n options.error,\n ),\n });\n\nexport const query = make(\"query\");\nexport const mutation = make(\"mutation\");\nexport const action = make(\"action\");\n\nconst isHandleOf =\n <Contract_ extends Any>(contract: Contract_) =>\n (value: unknown): value is Handle<Contract_> =>\n Ref.isRef(value) &&\n Predicate.hasProperty(value, HandleTypeId) &&\n value[HandleTypeId] === contract.id;\n\nconst fromText = <Contract_ extends Any>(\n contract: Contract_,\n text: string,\n): Handle<Contract_> =>\n Object.assign(\n Ref.fromProvenance(\n text,\n contract.functionProvenance,\n [],\n // Convex types a handle as a string that is also a function reference.\n text as unknown as FunctionReference<any, any>,\n ),\n { [HandleTypeId]: contract.id },\n ) as unknown as Handle<Contract_>;\n\n/**\n * The schema of a handle for `contract`: a string on the wire, a runnable ref\n * once decoded. Use it in a component's function args or tables.\n */\nexport const handle = <Contract_ extends Any>(\n contract: Contract_,\n): Schema.Codec<Handle<Contract_>, string> =>\n Schema.String.pipe(\n Schema.decodeTo(\n Schema.declare(isHandleOf(contract), {\n identifier: `Callback.Handle<${contract.id}>`,\n }),\n {\n decode: SchemaGetter.transform((text: string) =>\n fromText(contract, text),\n ),\n encode: SchemaGetter.transform(\n (ref: Handle<Contract_>) => ref.convexFunctionName,\n ),\n },\n ),\n );\n\ntype EncodedArgs<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? Schema.Struct.Encoded<ArgsFields_>\n : Ref.Args<Ref_>;\n\ntype EncodedReturns<Ref_> = Ref_ extends { readonly _tag: \"Confect\" }\n ? Ref.ReturnsSchema<Ref_>[\"Encoded\"]\n : Ref.Returns<Ref_>;\n\ntype IsAny<A> = 0 extends 1 & A ? true : false;\n\n/**\n * A Confect ref typed from values alone, such as a bound component's ref, has\n * no codec types left to compare, and middleware attachments typed without\n * their specs erase their errors. True when any variant of `Ref_` is erased.\n */\ntype IsErased<Ref_> = true extends (\n Ref_ extends { readonly _tag: \"Confect\" }\n ? IsAny<Ref.ReturnsSchema<Ref_>[\"Encoded\"]> | IsAny<Ref.EncodedError<Ref_>>\n : false\n)\n ? true\n : false;\n\n/**\n * The shape a value has on the wire: a component's ID brands become `string`,\n * since the contract cannot name the host's scope, while the host's own IDs\n * keep their table. Arrays and tuples lose `readonly`, and an optional field is\n * the same whether or not it admits `undefined`, which Convex never transmits.\n * `unknown` stays `unknown`.\n */\ntype WireShape<A> = unknown extends A\n ? A\n : A extends { readonly \"~@confect/core/ScopedId\": unknown }\n ? string\n : A extends\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | ArrayBuffer\n ? A\n : { -readonly [Key in keyof A]: WireShape<Exclude<A[Key], undefined>> };\n\ntype Identical<A, B> =\n (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2\n ? true\n : false;\n\ntype FirstOf<Checks extends ReadonlyArray<unknown>> = Checks extends readonly [\n infer Head,\n ...infer Rest,\n]\n ? [Head] extends [never]\n ? FirstOf<Rest>\n : Head\n : never;\n\n/**\n * Every obligation a host ref owes a contract, in the order they are reported.\n * Each is `never` when it holds.\n */\ntype Obligations<Contract_ extends Any, Ref_ extends Ref.Any> = [\n IsErased<Ref_> extends true\n ? `the ref's codecs are erased, so its encoding cannot be checked against \"${Contract_[\"id\"]}\"; pass the host's generated ref`\n : never,\n [Ref.GetFunctionType<Ref_>] extends [Contract_[\"functionType\"]]\n ? never\n : `\"${Contract_[\"id\"]}\" needs a ${Contract_[\"functionType\"]}, not a ${Ref.GetFunctionType<Ref_>}`,\n Identical<\n WireShape<EncodedArgs<Handle<Contract_>>>,\n WireShape<EncodedArgs<Ref_>>\n > extends true\n ? never\n : `the ref's encoded args differ from the args \"${Contract_[\"id\"]}\" sends`,\n Identical<\n WireShape<EncodedReturns<Handle<Contract_>>>,\n WireShape<EncodedReturns<Ref_>>\n > extends true\n ? never\n : `the ref's returns are encoded differently from the returns of \"${Contract_[\"id\"]}\"`,\n [Ref.Error<Ref_>] extends [Error<Contract_>]\n ? never\n : `the ref fails with errors \"${Contract_[\"id\"]}\" does not declare`,\n [WireShape<Ref.EncodedError<Ref_>>] extends [\n WireShape<Ref.EncodedError<Handle<Contract_>>>,\n ]\n ? never\n : `the ref's errors are encoded differently from the errors of \"${Contract_[\"id\"]}\"`,\n];\n\ntype Mismatch<Contract_ extends Any, Ref_ extends Ref.Any> = FirstOf<\n Obligations<Contract_, Ref_>\n>;\n\n/**\n * `unknown` when host ref `Ref_` satisfies `Contract_` as far as its types\n * show, otherwise an object type naming the first mismatch. The check compares\n * the types that cross the wire, with a component's IDs compared as strings.\n * The host's encoded args and returns must equal the contract's, and its\n * encoded errors (middleware errors included) must be ones the contract's\n * codecs decode. A ref whose codecs are erased cannot be checked and is\n * refused. Types miss what only the validators show, such as field names behind\n * a `Record` type, so `Callback.create` in `@confect/server` also compares the\n * compiled validators before it creates a handle.\n */\nexport type Check<Contract_ extends Any, Ref_ extends Ref.Any> = [\n Mismatch<Contract_, Ref_>,\n] extends [never]\n ? unknown\n : { readonly \"~CallbackMismatch\": Mismatch<Contract_, Ref_> };\n\n/**\n * View a ref as Convex's `FunctionReference_future`, typed with its wire args\n * and returns, for `createFunctionHandle` and clients that accept it.\n */\nexport const toFuture = <Ref_ extends Ref.Any>(\n ref: Ref_,\n): FunctionReference_future<\n Ref.GetFunctionType<Ref_>,\n Ref.GetFunctionVisibility<Ref_>,\n EncodedArgs<Ref_>,\n EncodedReturns<Ref_>\n> => Ref.getFunctionReference(ref) as never;\n"],"mappings":";;;;;;;;;;;;;;;;AAYA,MAAa,SAAS;AAGtB,MAAM,eAAe;AAqCrB,MAAa,cAAc,MACzB,UAAU,YAAY,GAAA,yBAAS,KAAK,EAAA,+BAAA;AA+CtC,MAAM,QACiC,kBAOnC,IACA,aAKiE;EAChE,SAAS;CACV;CACA;CACA,oBAAoBA,QAClB,QAAQ,gBAAgB,CAAC,KACzB,QAAQ,SACR,QAAQ,KACV;AACF;AAEF,MAAa,QAAQ,KAAK,OAAO;AACjC,MAAa,WAAW,KAAK,UAAU;AACvC,MAAa,SAAS,KAAK,QAAQ;AAEnC,MAAM,cACoB,cACvB,UACCC,MAAU,KAAK,KACf,UAAU,YAAY,OAAO,YAAY,KACzC,MAAM,kBAAkB,SAAS;AAErC,MAAM,YACJ,UACA,SAEA,OAAO,OACLC,eACE,MACA,SAAS,oBACT,CAAC,GAED,IACF,GACA,GAAG,eAAe,SAAS,GAAG,CAChC;;;;;AAMF,MAAa,UACX,aAEA,OAAO,OAAO,KACZ,OAAO,SACL,OAAO,QAAQ,WAAW,QAAQ,GAAG,EACnC,YAAY,mBAAmB,SAAS,GAAG,GAC7C,CAAC,GACD;CACE,QAAQ,aAAa,WAAW,SAC9B,SAAS,UAAU,IAAI,CACzB;CACA,QAAQ,aAAa,WAClB,QAA2B,IAAI,kBAClC;AACF,CACF,CACF;;;;;AA4HF,MAAa,YACX,QAMGC,qBAAyB,GAAG"}
1
+ {"version":3,"file":"Callback.js","names":["FunctionProvenance.Confect","Ref.isRef","Ref.fromProvenance"],"sources":["../src/Callback.ts"],"sourcesContent":["import type {\n FunctionReference,\n FunctionReference_future,\n FunctionType,\n} from \"convex/server\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Schema from \"effect/Schema\";\nimport * as SchemaGetter from \"effect/SchemaGetter\";\nimport * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport * as Ref from \"./Ref.js\";\nimport { getFunctionReference } from \"./RefInternal.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\n\nexport const TypeId = \"~@confect/core/Callback\";\nexport type TypeId = typeof TypeId;\n\nconst HandleTypeId = \"~@confect/core/Callback/Handle\";\n\n/**\n * A contract's id, `\"<component>/<event>\"`.\n */\nexport type Id = `${string}/${string}`;\n\n/**\n * A function a component calls back into its host, declared by the component:\n * the args it sends and the returns and errors it accepts. A host proves that\n * one of its functions satisfies the contract when it creates a handle.\n */\nexport interface Contract<\n Id_ extends Id,\n FunctionType_ extends FunctionType,\n ArgsFields_ extends FunctionProvenance.ArgsFields,\n Returns_ extends Schema.Codec<any, any>,\n Error_ extends Schema.Codec<any, any> = never,\n> {\n readonly [TypeId]: TypeId;\n readonly id: Id_;\n readonly functionType: FunctionType_;\n readonly functionProvenance: FunctionProvenance.Confect<\n ArgsFields_,\n Returns_,\n Error_,\n FunctionProvenance.Standard\n >;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n readonly id: Id;\n readonly functionType: FunctionType;\n readonly functionProvenance: FunctionProvenance.AnyConfect;\n}\n\nexport const isContract = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId;\n\ntype ArgsFields<Contract_ extends Any> =\n Contract_[\"functionProvenance\"] extends {\n readonly \"~ArgsFields\": infer ArgsFields_ extends\n FunctionProvenance.ArgsFields;\n }\n ? ArgsFields_\n : never;\n\ntype ReturnsSchema<Contract_ extends Any> =\n Contract_[\"functionProvenance\"][\"returns\"];\n\ntype ErrorSchema<Contract_ extends Any> =\n Contract_[\"functionProvenance\"] extends {\n readonly error?: infer ErrorSchema_;\n }\n ? Extract<ErrorSchema_, Schema.Codec<any, any>>\n : never;\n\nexport type Args<Contract_ extends Any> = Schema.Struct.Type<\n ArgsFields<Contract_>\n>;\n\nexport type Returns<Contract_ extends Any> = ReturnsSchema<Contract_>[\"Type\"];\n\nexport type Error<Contract_ extends Any> = ErrorSchema<Contract_>[\"Type\"];\n\n/**\n * A host function a component received for a contract. It is a ref, so the\n * runners and the scheduler run it with the contract's codecs, and declared\n * errors arrive by tag.\n */\nexport type Handle<Contract_ extends Any> = Ref.ConfectRef<\n Extract<\n RuntimeAndFunctionType.RuntimeAndFunctionType,\n {\n readonly runtime: \"Convex\";\n readonly functionType: Contract_[\"functionType\"];\n }\n >,\n \"internal\",\n ArgsFields<Contract_>,\n ReturnsSchema<Contract_>,\n ErrorSchema<Contract_>\n> & { readonly [HandleTypeId]: Contract_[\"id\"] };\n\nconst make =\n <FunctionType_ extends FunctionType>(functionType: FunctionType_) =>\n <\n const Id_ extends Id,\n const ArgsFields_ extends FunctionProvenance.ArgsFields = {},\n Returns_ extends Schema.Codec<any, any> = never,\n Error_ extends Schema.Codec<any, any> = never,\n >(\n id: Id_,\n options: {\n readonly args?: () => ArgsFields_;\n readonly returns: () => Returns_;\n readonly error?: () => Error_;\n },\n ): Contract<Id_, FunctionType_, ArgsFields_, Returns_, Error_> => ({\n [TypeId]: TypeId,\n id,\n functionType,\n functionProvenance: FunctionProvenance.Confect(\n options.args ?? (() => ({}) as ArgsFields_),\n options.returns,\n options.error,\n ),\n });\n\nexport const query = make(\"query\");\nexport const mutation = make(\"mutation\");\nexport const action = make(\"action\");\n\nconst isHandleOf =\n <Contract_ extends Any>(contract: Contract_) =>\n (value: unknown): value is Handle<Contract_> =>\n Ref.isRef(value) &&\n Predicate.hasProperty(value, HandleTypeId) &&\n value[HandleTypeId] === contract.id;\n\nconst fromText = <Contract_ extends Any>(\n contract: Contract_,\n text: string,\n): Handle<Contract_> =>\n Object.assign(\n Ref.fromProvenance(\n text,\n contract.functionProvenance,\n [],\n // Convex types a handle as a string that is also a function reference.\n text as unknown as FunctionReference<any, any>,\n contract.functionType,\n ),\n { [HandleTypeId]: contract.id },\n ) as unknown as Handle<Contract_>;\n\n/**\n * The schema of a handle for `contract`: a string on the wire, a runnable ref\n * once decoded. Use it in a component's function args or tables.\n */\nexport const handle = <Contract_ extends Any>(\n contract: Contract_,\n): Schema.Codec<Handle<Contract_>, string> =>\n Schema.String.pipe(\n Schema.decodeTo(\n Schema.declare(isHandleOf(contract), {\n identifier: `Callback.Handle<${contract.id}>`,\n }),\n {\n decode: SchemaGetter.transform((text: string) =>\n fromText(contract, text),\n ),\n encode: SchemaGetter.transform(\n (ref: Handle<Contract_>) => ref.convexFunctionName,\n ),\n },\n ),\n );\n\ntype EncodedArgs<Ref_> = Ref_ extends {\n readonly _tag: \"Confect\";\n readonly args: {\n readonly fields: infer ArgsFields_ extends FunctionProvenance.ArgsFields;\n };\n}\n ? Schema.Struct.Encoded<ArgsFields_>\n : Ref.Args<Ref_>;\n\ntype EncodedReturns<Ref_> = Ref_ extends { readonly _tag: \"Confect\" }\n ? Ref.ReturnsSchema<Ref_>[\"Encoded\"]\n : Ref.Returns<Ref_>;\n\ntype IsAny<A> = 0 extends 1 & A ? true : false;\n\n/**\n * A Confect ref typed from values alone, such as a bound component's ref, has\n * no codec types left to compare, and middleware attachments typed without\n * their specs erase their errors. True when any variant of `Ref_` is erased.\n */\ntype IsErased<Ref_> = true extends (\n Ref_ extends { readonly _tag: \"Confect\" }\n ? IsAny<Ref.ReturnsSchema<Ref_>[\"Encoded\"]> | IsAny<Ref.EncodedError<Ref_>>\n : false\n)\n ? true\n : false;\n\n/**\n * The shape a value has on the wire: a component's ID brands become `string`,\n * since the contract cannot name the host's scope, while the host's own IDs\n * keep their table. Arrays and tuples lose `readonly`, and an optional field is\n * the same whether or not it admits `undefined`, which Convex never transmits.\n * `unknown` stays `unknown`.\n */\ntype WireShape<A> = unknown extends A\n ? A\n : A extends { readonly \"~@confect/core/ScopedId\": unknown }\n ? string\n : A extends\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | ArrayBuffer\n ? A\n : { -readonly [Key in keyof A]: WireShape<Exclude<A[Key], undefined>> };\n\ntype Identical<A, B> =\n (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2\n ? true\n : false;\n\ntype FirstOf<Checks extends ReadonlyArray<unknown>> = Checks extends readonly [\n infer Head,\n ...infer Rest,\n]\n ? [Head] extends [never]\n ? FirstOf<Rest>\n : Head\n : never;\n\n/**\n * Every obligation a host ref owes a contract, in the order they are reported.\n * Each is `never` when it holds.\n */\ntype Obligations<Contract_ extends Any, Ref_ extends Ref.Any> = [\n IsErased<Ref_> extends true\n ? `the ref's codecs are erased, so its encoding cannot be checked against \"${Contract_[\"id\"]}\"; pass the host's generated ref`\n : never,\n [Ref.GetFunctionType<Ref_>] extends [Contract_[\"functionType\"]]\n ? never\n : `\"${Contract_[\"id\"]}\" needs a ${Contract_[\"functionType\"]}, not a ${Ref.GetFunctionType<Ref_>}`,\n Identical<\n WireShape<EncodedArgs<Handle<Contract_>>>,\n WireShape<EncodedArgs<Ref_>>\n > extends true\n ? never\n : `the ref's encoded args differ from the args \"${Contract_[\"id\"]}\" sends`,\n Identical<\n WireShape<EncodedReturns<Handle<Contract_>>>,\n WireShape<EncodedReturns<Ref_>>\n > extends true\n ? never\n : `the ref's returns are encoded differently from the returns of \"${Contract_[\"id\"]}\"`,\n [Ref.Error<Ref_>] extends [Error<Contract_>]\n ? never\n : `the ref fails with errors \"${Contract_[\"id\"]}\" does not declare`,\n [WireShape<Ref.EncodedError<Ref_>>] extends [\n WireShape<Ref.EncodedError<Handle<Contract_>>>,\n ]\n ? never\n : `the ref's errors are encoded differently from the errors of \"${Contract_[\"id\"]}\"`,\n];\n\ntype Mismatch<Contract_ extends Any, Ref_ extends Ref.Any> = FirstOf<\n Obligations<Contract_, Ref_>\n>;\n\n/**\n * `unknown` when host ref `Ref_` satisfies `Contract_` as far as its types\n * show, otherwise an object type naming the first mismatch. The check compares\n * the types that cross the wire, with a component's IDs compared as strings.\n * The host's encoded args and returns must equal the contract's, and its\n * encoded errors (middleware errors included) must be ones the contract's\n * codecs decode. A ref whose codecs are erased cannot be checked and is\n * refused. Types miss what only the validators show, such as field names behind\n * a `Record` type, so `Callback.create` in `@confect/server` also compares the\n * compiled validators before it creates a handle.\n */\nexport type Check<Contract_ extends Any, Ref_ extends Ref.Any> = [\n Mismatch<Contract_, Ref_>,\n] extends [never]\n ? unknown\n : { readonly \"~CallbackMismatch\": Mismatch<Contract_, Ref_> };\n\n/**\n * View a ref as Convex's `FunctionReference_future`, typed with its wire args\n * and returns, for `createFunctionHandle` and clients that accept it.\n */\nexport const toFuture = <Ref_ extends Ref.Any>(\n ref: Ref_,\n): FunctionReference_future<\n Ref.GetFunctionType<Ref_>,\n Ref.GetFunctionVisibility<Ref_>,\n EncodedArgs<Ref_>,\n EncodedReturns<Ref_>\n> => getFunctionReference(ref) as never;\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,MAAa,SAAS;AAGtB,MAAM,eAAe;AAqCrB,MAAa,cAAc,MACzB,UAAU,YAAY,GAAA,yBAAS,KAAK,EAAA,+BAAA;AA+CtC,MAAM,QACiC,kBAOnC,IACA,aAKiE;EAChE,SAAS;CACV;C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,OAAO,CAAC,OAAO,EAC5B,EAAE,SAAS,OAAO,CAAC,OAAO,EAC1B,MAAM,SAAS,MAAM,EACrB,KAAK,CAAC,KAAK,SAAS,MAAM,aAEf;IACT,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE;QACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QACpB,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;QACnB,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KACxC,CAAC;CACH,SACM,KAAK,+FAC+C,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,MAAM,GACjB,IAAI,SAAS,OAAO,CAAC,OAAO,EAC5B,EAAE,SAAS,OAAO,CAAC,OAAO,EAC1B,OAAO,SAAS,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,aAE3B;IACT,QAAQ,CAAC,CAAC,WAAW,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAA;KAAE,CAAC;CACrE,SACM,OAAO,8CAMb,CAAC"}
package/dist/Component.js CHANGED
@@ -119,7 +119,7 @@ const bind = (component, native, options) => {
119
119
  return fromProvenance(ref.convexFunctionName, provenance, Array.map(ref.middlewareAttachments, (attachment) => ({
120
120
  ...attachment,
121
121
  spec: rebaseMiddleware(attachment.spec)
122
- })), nativeRef);
122
+ })), nativeRef, ref.functionType, ref.reservedArgument);
123
123
  }), Match.exhaustive);
124
124
  } else return visit(child, reference);
125
125
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Component.js","names":["Spec.groups","Ref.make","IdScope.instance","IdScope.app","rebase","GenericId.rebase","Ref.isRef","Ref.fromProvenance","GenericId.GenericId"],"sources":["../src/Component.ts"],"sourcesContent":["import type { DefaultFunctionArgs, FunctionReference } from \"convex/server\";\nimport { getFunctionAddress } from \"convex/server\";\nimport * as Array from \"effect/Array\";\nimport * as Data from \"effect/Data\";\nimport * as Result from \"effect/Result\";\nimport { memoize, pipe } from \"effect/Function\";\nimport * as Match from \"effect/Match\";\nimport * as Record from \"effect/Record\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport type * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as GenericId from \"./GenericId.js\";\nimport type * as GroupSpec from \"./GroupSpec.js\";\nimport * as IdScope from \"./IdScope.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport * as Ref from \"./Ref.js\";\nimport type * as Refs from \"./Refs.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\nimport * as Spec from \"./Spec.js\";\n\nexport class EmptyComponentScopeError extends Data.TaggedError(\n \"EmptyComponentScopeError\",\n)<{\n readonly definitionScope: IdScope.IdScope;\n}> {\n override get message(): string {\n return \"A component contract requires a nonempty definition scope.\";\n }\n}\n\nexport class ComponentNameCollisionError extends Data.TaggedError(\n \"ComponentNameCollisionError\",\n)<{\n readonly groupPath: string;\n readonly functionName: string;\n}> {\n override get message(): string {\n return `Group and function at same level have same name ('${this.groupPath}:${this.functionName}')`;\n }\n}\n\nexport class UninstalledComponentReferenceError extends Data.TaggedError(\n \"UninstalledComponentReferenceError\",\n)<{\n readonly definitionScope: IdScope.IdScope;\n}> {\n override get message(): string {\n return \"Component.bind expects an installed component from the generated components registry.\";\n }\n}\n\nconst validateNames = (\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n prefix = \"\",\n): Result.Result<void, ComponentNameCollisionError> => {\n for (const [name, group] of Record.toEntries(groups)) {\n const path = prefix === \"\" ? name : `${prefix}/${name}`;\n for (const functionSpec of Record.values(group.functions)) {\n if (Record.has(group.groups, functionSpec.name)) {\n return Result.fail(\n new ComponentNameCollisionError({\n groupPath: path,\n functionName: functionSpec.name,\n }),\n );\n }\n }\n const nested = validateNames(group.groups, path);\n if (Result.isFailure(nested)) return nested;\n }\n return Result.succeed(undefined);\n};\n\nconst validateContract = (\n scope: IdScope.IdScope,\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n): Result.Result<\n void,\n EmptyComponentScopeError | ComponentNameCollisionError\n> =>\n scope === \"\"\n ? Result.fail(new EmptyComponentScopeError({ definitionScope: scope }))\n : validateNames(groups);\n\nconst TypeId = \"~@confect/core/Component\";\nconst BoundTypeId = \"~@confect/core/BoundComponent\";\n\n/**\n * Convex's generated ComponentApi erases database ID brands at the boundary.\n */\ntype Wire<A> = A extends { readonly __tableName: string }\n ? string\n : A extends\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | ArrayBuffer\n ? A\n : { [K in keyof A]: Wire<A[K]> };\n\ntype OmitEmpty<A> = {\n [K in keyof A as keyof A[K] extends never ? never : K]: A[K];\n};\ntype ApiGroups<\n GroupSpec_ extends GroupSpec.AnyWithProps,\n Name extends string | undefined,\n> = OmitEmpty<{\n [GroupName in GroupSpec.Name<GroupSpec_>]: ApiGroup<\n GroupSpec.WithName<GroupSpec_, GroupName>,\n Name\n >;\n}>;\ntype ApiGroup<\n GroupSpec_ extends GroupSpec.AnyWithProps,\n Name extends string | undefined,\n> = ApiGroups<GroupSpec.Groups<GroupSpec_>, Name> & {\n [\n FunctionSpec_ in GroupSpec.Functions<GroupSpec_> as FunctionSpec.GetFunctionVisibility<FunctionSpec_> extends \"public\"\n ? FunctionSpec.Name<FunctionSpec_>\n : never\n ]: FunctionReference<\n RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n >,\n \"internal\",\n Extract<Wire<FunctionSpec.EncodedArgs<FunctionSpec_>>, DefaultFunctionArgs>,\n Wire<FunctionSpec.EncodedReturns<FunctionSpec_>>,\n Name\n >;\n};\n\nexport type Api<\n Spec_ extends Spec.AnyWithProps,\n Name extends string | undefined = string | undefined,\n> = ApiGroups<Spec.Groups<Spec_>, Name>;\n\ninterface Tree {\n readonly [key: string]: Tree | Ref.Any;\n}\n\nexport interface Component<\n Spec_ extends Spec.AnyWithProps,\n Scope extends IdScope.IdScope,\n Tables extends string = string,\n> {\n readonly [TypeId]: {\n readonly refs: Tree;\n readonly scope: Scope;\n readonly tables: ReadonlyArray<Tables>;\n };\n readonly \"~Spec\": Spec_;\n}\n\n/**\n * An opaque identity: its string representation is not part of the API.\n */\nexport type MountScope<\n Parent extends IdScope.IdScope,\n Name extends string | undefined,\n> = IdScope.Mount<Parent, Name>;\n\ntype MountName<ComponentApi> =\n ComponentApi extends FunctionReference<any, any, any, any, infer Name>\n ? Name\n : ComponentApi extends object\n ? {\n [Key in keyof ComponentApi]: MountName<ComponentApi[Key]>;\n }[keyof ComponentApi]\n : never;\n\ntype BindRefs<\n RefTree,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n> = RefTree extends Ref.Any\n ? RefTree extends { readonly _tag: \"Convex\" }\n ? Ref.ConvexRef<\n Ref.GetRuntimeAndFunctionType<RefTree>,\n \"internal\",\n Extract<Wire<Ref.Args<RefTree>>, DefaultFunctionArgs>,\n Wire<Ref.Returns<RefTree>>\n >\n : Extract<\n Ref.Ref<\n Ref.GetRuntimeAndFunctionType<RefTree>,\n \"internal\",\n Extract<\n GenericId.Rebase<Ref.Args<RefTree>, From, To>,\n DefaultFunctionArgs\n >,\n GenericId.Rebase<Ref.Returns<RefTree>, From, To>,\n GenericId.Rebase<Ref.Error<RefTree>, From, To>\n >,\n { readonly _tag: RefTree[\"_tag\"] }\n >\n : { [Key in keyof RefTree]: BindRefs<RefTree[Key], From, To> };\n\nexport type Bound<\n Spec_ extends Spec.AnyWithProps,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Tables extends string,\n> = BindRefs<Refs.Refs<Spec_, Ref.AnyPublic>, From, To> & {\n readonly [BoundTypeId]: {\n readonly from: From;\n readonly scope: To;\n readonly tables: ReadonlyArray<Tables>;\n };\n};\n\n/**\n * Build a publishable contract containing only exported functions and codecs.\n */\nexport const make = <\n Spec_ extends Spec.AnyWithProps,\n const Scope extends IdScope.IdScope,\n const Tables extends string,\n>(\n spec: Spec_,\n scope: Scope,\n tables: ReadonlyArray<Tables>,\n): Component<Spec_, Scope, Tables> => {\n const specGroups = Spec.groups(spec);\n Result.getOrThrow(validateContract(scope, specGroups));\n const collect = (\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n prefix = \"\",\n ): Tree =>\n pipe(\n groups,\n Record.map((group, name) => {\n const path = prefix === \"\" ? name : `${prefix}/${name}`;\n const functions = pipe(\n group.functions,\n Record.filter((functionSpec) => {\n return Match.value(functionSpec.functionVisibility).pipe(\n Match.when(\"public\", () => true),\n Match.when(\"internal\", () => false),\n Match.exhaustive,\n );\n }),\n Record.map((functionSpec) =>\n Ref.make(path, functionSpec, group.middlewareAttachments),\n ),\n );\n return { ...collect(group.groups, path), ...functions };\n }),\n Record.filter((children) => !Record.isEmptyRecord(children)),\n );\n return {\n [TypeId]: { refs: collect(specGroups), scope, tables },\n } as Component<Spec_, Scope, Tables>;\n};\n\n/**\n * Bind the published contract to an actual installed component reference.\n */\nexport const bind = <\n Spec_ extends Spec.AnyWithProps,\n From extends IdScope.IdScope,\n Tables extends string,\n Native extends Api<NoInfer<Spec_>>,\n const Parent extends IdScope.IdScope = IdScope.App,\n>(\n component: Component<Spec_, From, Tables>,\n native: Native,\n options?: { readonly parentScope: Parent },\n): Bound<\n Spec_,\n From,\n MountScope<Parent, Extract<MountName<Native>, string | undefined>>,\n Tables\n> => {\n const contract = component[TypeId];\n const address = getFunctionAddress(native);\n const installedReference = Result.getOrThrow(\n Result.fromNullishOr(\n address.reference,\n () =>\n new UninstalledComponentReferenceError({\n definitionScope: contract.scope,\n }),\n ),\n );\n // Preserve the opaque address as an identity only. Calls retain the native\n // references; no component address is constructed or parsed for routing.\n const scope = IdScope.instance(\n options?.parentScope ?? IdScope.app,\n installedReference,\n );\n const rebase = (schema: Schema.ConstraintCodec<any, any, never, never>) =>\n GenericId.rebase(schema, contract.scope, scope);\n const rebaseMiddleware = memoize(\n (middleware: MiddlewareSpec.AnyMiddlewareSpec) => {\n if (!(\"error\" in middleware)) return middleware;\n const boundMiddleware = Object.create(\n middleware,\n ) as MiddlewareSpec.AnyMiddlewareSpec;\n Lazy.defineProperty(boundMiddleware, \"error\", () => {\n const error = middleware.error;\n return error === undefined ? undefined : rebase(error);\n });\n return boundMiddleware;\n },\n );\n const visit = (tree: Tree, references: unknown): Tree =>\n Record.map(tree, (child, key) => {\n const reference = (references as Record<string, unknown>)[key];\n if (Ref.isRef(child)) {\n const nativeRef = reference as FunctionReference<any, any>;\n return Match.value(child).pipe(\n Match.tag(\"Convex\", (ref) => ({\n ...ref,\n functionReference: nativeRef,\n })),\n Match.tag(\"Confect\", (ref) => {\n const provenance = {\n _tag: \"Confect\" as const,\n kind: Match.value(ref.kind).pipe(\n Match.tag(\"Standard\", (kind) => kind),\n Match.tag(\"Paginated\", (kind) => {\n const boundKind = { _tag: \"Paginated\" as const };\n Lazy.defineProperty(boundKind, \"userArgs\", () =>\n Schema.Struct(Record.map(kind.userArgs.fields, rebase)),\n );\n Lazy.defineProperty(boundKind, \"item\", () =>\n rebase(kind.item),\n );\n Lazy.defineProperty(boundKind, \"page\", () =>\n rebase(kind.page),\n );\n return boundKind as FunctionProvenance.Paginated;\n }),\n Match.exhaustive,\n ),\n };\n Lazy.defineProperty(provenance, \"args\", () =>\n Schema.Struct(Record.map(ref.args.fields, rebase)),\n );\n Lazy.defineProperty(provenance, \"returns\", () =>\n rebase(ref.returns),\n );\n if (\"error\" in ref) {\n Lazy.defineProperty(provenance, \"error\", () => {\n const error = ref.error;\n return error === undefined ? undefined : rebase(error);\n });\n }\n return Ref.fromProvenance(\n ref.convexFunctionName,\n provenance as FunctionProvenance.AnyConfect,\n Array.map(ref.middlewareAttachments, (attachment) => ({\n ...attachment,\n spec: rebaseMiddleware(attachment.spec),\n })),\n nativeRef,\n );\n }),\n Match.exhaustive,\n );\n } else {\n return visit(child, reference);\n }\n });\n const refs = visit(contract.refs, native);\n Object.defineProperty(refs, BoundTypeId, {\n value: { from: contract.scope, scope, tables: contract.tables },\n });\n return refs as Bound<\n Spec_,\n From,\n MountScope<Parent, Extract<MountName<Native>, string | undefined>>,\n Tables\n >;\n};\n\n/**\n * Reference an installed component's table ID in host schemas.\n */\nexport const id = <\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Tables extends string,\n const Table extends Tables,\n>(\n component: {\n readonly [BoundTypeId]: {\n readonly from: From;\n readonly scope: To;\n readonly tables: ReadonlyArray<Tables>;\n };\n },\n table: Table,\n) => GenericId.GenericId(table, component[BoundTypeId].scope);\n\n/**\n * Reuse a component's codec in a host function or table without losing its\n * scope.\n */\nexport const schema = <\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Schema_ extends Schema.Codec<any, any>,\n>(\n component: {\n readonly [BoundTypeId]: { readonly from: From; readonly scope: To };\n },\n codec: Schema_,\n) =>\n GenericId.rebase(\n codec,\n component[BoundTypeId].from,\n component[BoundTypeId].scope,\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,2BAAb,cAA8C,KAAK,YACjD,0BACF,CAAC,CAEE;CACD,IAAa,UAAkB;EAC7B,OAAO;CACT;AACF;AAEA,IAAa,8BAAb,cAAiD,KAAK,YACpD,6BACF,CAAC,CAGE;CACD,IAAa,UAAkB;EAC7B,OAAO,qDAAqD,KAAK,UAAU,GAAG,KAAK,aAAa;CAClG;AACF;AAEA,IAAa,qCAAb,cAAwD,KAAK,YAC3D,oCACF,CAAC,CAEE;CACD,IAAa,UAAkB;EAC7B,OAAO;CACT;AACF;AAEA,MAAM,iBACJ,QACA,SAAS,OAC4C;CACrD,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,UAAU,MAAM,GAAG;EACpD,MAAM,OAAO,WAAW,KAAK,OAAO,GAAG,OAAO,GAAG;EACjD,KAAK,MAAM,gBAAgB,OAAO,OAAO,MAAM,SAAS,GACtD,IAAI,OAAO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A,QAAM,CAAC,CACnD;IACA,eAAoB,YAAY,iBAC9BA,SAAO,IAAI,OAAO,CACpB;IACA,IAAI,WAAW,KACb,eAAoB,YAAY,eAAe;KAC7C,MAAM,QAAQ,IAAI;KAClB,OAAO,UAAU,KAAA,IAAY,KAAA,IAAYA,SAAO,KAAK;IACvD,CAAC;IAEH,OAAOG,eACL,IAAI,oBACJ,YACA,MAAM,IAAI,IAAI,wBAAwB,gBAAgB;KACpD,GAAG;KACH,MAAM,iBAAiB,WAAW,IAAI;IACxC,EAAE,GACF,SACF;GACF,CAAC,GACD,MAAM,UACR;EACF,OACE,OAAO,MAAM,OAAO,SAAS;CAEjC,CAAC;CACH,MAAM,OAAO,MAAM,SAAS,MAAM,MAAM;CACxC,OAAO,eAAe,MAAM,aAAa,EACvC,OAAO;EAAE,MAAM,SAAS;EAAO;EAAO,QAAQ,SAAS;CAAO,EAChE,CAAC;CACD,OAAO;AAMT;;;;AAKA,MAAa,MAMX,WAOA,UACGC,UAAoB,OAAO,UAAU,YAAY,CAAC,KAAK;;;;;AAM5D,MAAa,UAKX,WAGA,UAEAH,OACE,OACA,UAAU,YAAY,CAAC,MACvB,UAAU,YAAY,CAAC,KACzB"}
1
+ {"version":3,"file":"Component.js","names":["Spec.groups","Ref.make","IdScope.instance","IdScope.app","rebase","GenericId.rebase","Ref.isRef","Ref.fromProvenance","GenericId.GenericId"],"sources":["../src/Component.ts"],"sourcesContent":["import type { DefaultFunctionArgs, FunctionReference } from \"convex/server\";\nimport { getFunctionAddress } from \"convex/server\";\nimport * as Array from \"effect/Array\";\nimport * as Data from \"effect/Data\";\nimport * as Result from \"effect/Result\";\nimport { memoize, pipe } from \"effect/Function\";\nimport * as Match from \"effect/Match\";\nimport * as Record from \"effect/Record\";\nimport * as Schema from \"effect/Schema\";\nimport type * as FunctionProvenance from \"./FunctionProvenance.js\";\nimport type * as FunctionSpec from \"./FunctionSpec.js\";\nimport * as GenericId from \"./GenericId.js\";\nimport type * as GroupSpec from \"./GroupSpec.js\";\nimport * as IdScope from \"./IdScope.js\";\nimport * as Lazy from \"./Lazy.js\";\nimport type * as MiddlewareSpec from \"./MiddlewareSpec.js\";\nimport * as Ref from \"./Ref.js\";\nimport type * as Refs from \"./Refs.js\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType.js\";\nimport * as Spec from \"./Spec.js\";\n\nexport class EmptyComponentScopeError extends Data.TaggedError(\n \"EmptyComponentScopeError\",\n)<{\n readonly definitionScope: IdScope.IdScope;\n}> {\n override get message(): string {\n return \"A component contract requires a nonempty definition scope.\";\n }\n}\n\nexport class ComponentNameCollisionError extends Data.TaggedError(\n \"ComponentNameCollisionError\",\n)<{\n readonly groupPath: string;\n readonly functionName: string;\n}> {\n override get message(): string {\n return `Group and function at same level have same name ('${this.groupPath}:${this.functionName}')`;\n }\n}\n\nexport class UninstalledComponentReferenceError extends Data.TaggedError(\n \"UninstalledComponentReferenceError\",\n)<{\n readonly definitionScope: IdScope.IdScope;\n}> {\n override get message(): string {\n return \"Component.bind expects an installed component from the generated components registry.\";\n }\n}\n\nconst validateNames = (\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n prefix = \"\",\n): Result.Result<void, ComponentNameCollisionError> => {\n for (const [name, group] of Record.toEntries(groups)) {\n const path = prefix === \"\" ? name : `${prefix}/${name}`;\n for (const functionSpec of Record.values(group.functions)) {\n if (Record.has(group.groups, functionSpec.name)) {\n return Result.fail(\n new ComponentNameCollisionError({\n groupPath: path,\n functionName: functionSpec.name,\n }),\n );\n }\n }\n const nested = validateNames(group.groups, path);\n if (Result.isFailure(nested)) return nested;\n }\n return Result.succeed(undefined);\n};\n\nconst validateContract = (\n scope: IdScope.IdScope,\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n): Result.Result<\n void,\n EmptyComponentScopeError | ComponentNameCollisionError\n> =>\n scope === \"\"\n ? Result.fail(new EmptyComponentScopeError({ definitionScope: scope }))\n : validateNames(groups);\n\nconst TypeId = \"~@confect/core/Component\";\nconst BoundTypeId = \"~@confect/core/BoundComponent\";\n\n/**\n * Convex's generated ComponentApi erases database ID brands at the boundary.\n */\ntype Wire<A> = A extends { readonly __tableName: string }\n ? string\n : A extends\n | string\n | number\n | bigint\n | boolean\n | null\n | undefined\n | ArrayBuffer\n ? A\n : { [K in keyof A]: Wire<A[K]> };\n\ntype OmitEmpty<A> = {\n [K in keyof A as keyof A[K] extends never ? never : K]: A[K];\n};\ntype ApiGroups<\n GroupSpec_ extends GroupSpec.AnyWithProps,\n Name extends string | undefined,\n> = OmitEmpty<{\n [GroupName in GroupSpec.Name<GroupSpec_>]: ApiGroup<\n GroupSpec.WithName<GroupSpec_, GroupName>,\n Name\n >;\n}>;\ntype ApiGroup<\n GroupSpec_ extends GroupSpec.AnyWithProps,\n Name extends string | undefined,\n> = ApiGroups<GroupSpec.Groups<GroupSpec_>, Name> & {\n [\n FunctionSpec_ in GroupSpec.Functions<GroupSpec_> as FunctionSpec.GetFunctionVisibility<FunctionSpec_> extends \"public\"\n ? FunctionSpec.Name<FunctionSpec_>\n : never\n ]: FunctionReference<\n RuntimeAndFunctionType.GetFunctionType<\n FunctionSpec_[\"runtimeAndFunctionType\"]\n >,\n \"internal\",\n Extract<Wire<FunctionSpec.EncodedArgs<FunctionSpec_>>, DefaultFunctionArgs>,\n Wire<FunctionSpec.EncodedReturns<FunctionSpec_>>,\n Name\n >;\n};\n\nexport type Api<\n Spec_ extends Spec.AnyWithProps,\n Name extends string | undefined = string | undefined,\n> = ApiGroups<Spec.Groups<Spec_>, Name>;\n\ninterface Tree {\n readonly [key: string]: Tree | Ref.Any;\n}\n\nexport interface Component<\n Spec_ extends Spec.AnyWithProps,\n Scope extends IdScope.IdScope,\n Tables extends string = string,\n> {\n readonly [TypeId]: {\n readonly refs: Tree;\n readonly scope: Scope;\n readonly tables: ReadonlyArray<Tables>;\n };\n readonly \"~Spec\": Spec_;\n}\n\n/**\n * An opaque identity: its string representation is not part of the API.\n */\nexport type MountScope<\n Parent extends IdScope.IdScope,\n Name extends string | undefined,\n> = IdScope.Mount<Parent, Name>;\n\ntype MountName<ComponentApi> =\n ComponentApi extends FunctionReference<any, any, any, any, infer Name>\n ? Name\n : ComponentApi extends object\n ? {\n [Key in keyof ComponentApi]: MountName<ComponentApi[Key]>;\n }[keyof ComponentApi]\n : never;\n\ntype BindRefs<\n RefTree,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n> = RefTree extends Ref.Any\n ? RefTree extends { readonly _tag: \"Convex\" }\n ? Ref.ConvexRef<\n Ref.GetRuntimeAndFunctionType<RefTree>,\n \"internal\",\n Extract<Wire<Ref.Args<RefTree>>, DefaultFunctionArgs>,\n Wire<Ref.Returns<RefTree>>\n >\n : Extract<\n Ref.Ref<\n Ref.GetRuntimeAndFunctionType<RefTree>,\n \"internal\",\n Extract<\n GenericId.Rebase<Ref.Args<RefTree>, From, To>,\n DefaultFunctionArgs\n >,\n GenericId.Rebase<Ref.Returns<RefTree>, From, To>,\n GenericId.Rebase<Ref.Error<RefTree>, From, To>\n >,\n { readonly _tag: RefTree[\"_tag\"] }\n >\n : { [Key in keyof RefTree]: BindRefs<RefTree[Key], From, To> };\n\nexport type Bound<\n Spec_ extends Spec.AnyWithProps,\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Tables extends string,\n> = BindRefs<Refs.Refs<Spec_, Ref.AnyPublic>, From, To> & {\n readonly [BoundTypeId]: {\n readonly from: From;\n readonly scope: To;\n readonly tables: ReadonlyArray<Tables>;\n };\n};\n\n/**\n * Build a publishable contract containing only exported functions and codecs.\n */\nexport const make = <\n Spec_ extends Spec.AnyWithProps,\n const Scope extends IdScope.IdScope,\n const Tables extends string,\n>(\n spec: Spec_,\n scope: Scope,\n tables: ReadonlyArray<Tables>,\n): Component<Spec_, Scope, Tables> => {\n const specGroups = Spec.groups(spec);\n Result.getOrThrow(validateContract(scope, specGroups));\n const collect = (\n groups: Readonly<Record<string, GroupSpec.AnyWithProps>>,\n prefix = \"\",\n ): Tree =>\n pipe(\n groups,\n Record.map((group, name) => {\n const path = prefix === \"\" ? name : `${prefix}/${name}`;\n const functions = pipe(\n group.functions,\n Record.filter((functionSpec) => {\n return Match.value(functionSpec.functionVisibility).pipe(\n Match.when(\"public\", () => true),\n Match.when(\"internal\", () => false),\n Match.exhaustive,\n );\n }),\n Record.map((functionSpec) =>\n Ref.make(path, functionSpec, group.middlewareAttachments),\n ),\n );\n return { ...collect(group.groups, path), ...functions };\n }),\n Record.filter((children) => !Record.isEmptyRecord(children)),\n );\n return {\n [TypeId]: { refs: collect(specGroups), scope, tables },\n } as Component<Spec_, Scope, Tables>;\n};\n\n/**\n * Bind the published contract to an actual installed component reference.\n */\nexport const bind = <\n Spec_ extends Spec.AnyWithProps,\n From extends IdScope.IdScope,\n Tables extends string,\n Native extends Api<NoInfer<Spec_>>,\n const Parent extends IdScope.IdScope = IdScope.App,\n>(\n component: Component<Spec_, From, Tables>,\n native: Native,\n options?: { readonly parentScope: Parent },\n): Bound<\n Spec_,\n From,\n MountScope<Parent, Extract<MountName<Native>, string | undefined>>,\n Tables\n> => {\n const contract = component[TypeId];\n const address = getFunctionAddress(native);\n const installedReference = Result.getOrThrow(\n Result.fromNullishOr(\n address.reference,\n () =>\n new UninstalledComponentReferenceError({\n definitionScope: contract.scope,\n }),\n ),\n );\n // Preserve the opaque address as an identity only. Calls retain the native\n // references; no component address is constructed or parsed for routing.\n const scope = IdScope.instance(\n options?.parentScope ?? IdScope.app,\n installedReference,\n );\n const rebase = (schema: Schema.ConstraintCodec<any, any, never, never>) =>\n GenericId.rebase(schema, contract.scope, scope);\n const rebaseMiddleware = memoize(\n (middleware: MiddlewareSpec.AnyMiddlewareSpec) => {\n if (!(\"error\" in middleware)) return middleware;\n const boundMiddleware = Object.create(\n middleware,\n ) as MiddlewareSpec.AnyMiddlewareSpec;\n Lazy.defineProperty(boundMiddleware, \"error\", () => {\n const error = middleware.error;\n return error === undefined ? undefined : rebase(error);\n });\n return boundMiddleware;\n },\n );\n const visit = (tree: Tree, references: unknown): Tree =>\n Record.map(tree, (child, key) => {\n const reference = (references as Record<string, unknown>)[key];\n if (Ref.isRef(child)) {\n const nativeRef = reference as FunctionReference<any, any>;\n return Match.value(child).pipe(\n Match.tag(\"Convex\", (ref) => ({\n ...ref,\n functionReference: nativeRef,\n })),\n Match.tag(\"Confect\", (ref) => {\n const provenance = {\n _tag: \"Confect\" as const,\n kind: Match.value(ref.kind).pipe(\n Match.tag(\"Standard\", (kind) => kind),\n Match.tag(\"Paginated\", (kind) => {\n const boundKind = { _tag: \"Paginated\" as const };\n Lazy.defineProperty(boundKind, \"userArgs\", () =>\n Schema.Struct(Record.map(kind.userArgs.fields, rebase)),\n );\n Lazy.defineProperty(boundKind, \"item\", () =>\n rebase(kind.item),\n );\n Lazy.defineProperty(boundKind, \"page\", () =>\n rebase(kind.page),\n );\n return boundKind as FunctionProvenance.Paginated;\n }),\n Match.exhaustive,\n ),\n };\n Lazy.defineProperty(provenance, \"args\", () =>\n Schema.Struct(Record.map(ref.args.fields, rebase)),\n );\n Lazy.defineProperty(provenance, \"returns\", () =>\n rebase(ref.returns),\n );\n if (\"error\" in ref) {\n Lazy.defineProperty(provenance, \"error\", () => {\n const error = ref.error;\n return error === undefined ? undefined : rebase(error);\n });\n }\n return Ref.fromProvenance(\n ref.convexFunctionName,\n provenance as FunctionProvenance.AnyConfect,\n Array.map(ref.middlewareAttachments, (attachment) => ({\n ...attachment,\n spec: rebaseMiddleware(attachment.spec),\n })),\n nativeRef,\n ref.functionType,\n ref.reservedArgument,\n );\n }),\n Match.exhaustive,\n );\n } else {\n return visit(child, reference);\n }\n });\n const refs = visit(contract.refs, native);\n Object.defineProperty(refs, BoundTypeId, {\n value: { from: contract.scope, scope, tables: contract.tables },\n });\n return refs as Bound<\n Spec_,\n From,\n MountScope<Parent, Extract<MountName<Native>, string | undefined>>,\n Tables\n >;\n};\n\n/**\n * Reference an installed component's table ID in host schemas.\n */\nexport const id = <\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Tables extends string,\n const Table extends Tables,\n>(\n component: {\n readonly [BoundTypeId]: {\n readonly from: From;\n readonly scope: To;\n readonly tables: ReadonlyArray<Tables>;\n };\n },\n table: Table,\n) => GenericId.GenericId(table, component[BoundTypeId].scope);\n\n/**\n * Reuse a component's codec in a host function or table without losing its\n * scope.\n */\nexport const schema = <\n From extends IdScope.IdScope,\n To extends IdScope.IdScope,\n Schema_ extends Schema.Codec<any, any>,\n>(\n component: {\n readonly [BoundTypeId]: { readonly from: From; readonly scope: To };\n },\n codec: Schema_,\n) =>\n GenericId.rebase(\n codec,\n component[BoundTypeId].from,\n component[BoundTypeId].scope,\n );\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,2BAAb,cAA8C,KAAK,YACjD,0BACF,CAAC,CAEE;CACD,IAAa,UAAkB;EAC7B,OAAO;CACT;AACF;AAEA,IAAa,8BAAb,cAAiD,KAAK,YACpD,6BACF,CAAC,CAGE;CACD,IAAa,UAAkB;EAC7B,OAAO,qDAAqD,KAAK,UAAU,GAAG,KAAK,aAAa;CAClG;AACF;AAEA,IAAa,qCAAb,cAAwD,KAAK,YAC3D,oCACF,CAAC,CAEE;CACD,IAAa,UAAkB;EAC7B,OAAO;CACT;AACF;AAEA,MAAM,iBACJ,QACA,SAAS,OAC4C;CACrD,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,UAAU,MAAM,GAAG;EACpD,MAAM,OAAO,WAAW,KAAK,OAAO,GAAG,OAAO,GAAG;EACjD,KAAK,MAAM,gBAAgB,OAAO,OAAO,MAAM,SAAS,GACtD,IAAI,OAAO,IAAI,MAAM,QAAQ,aAAa,IAAI,GAC5C,OAAO,OAAO,KACZ,IAAI,4BAA4B;GAC9B,WAAW;GACX,cAAc,aAAa;EAC7B,CAAC,CACH;EAGJ,MAAM,SAAS,cAAc,MAAM,QAAQ,IAAI;EAC/C,IAAI,OAAO,UAAU,MAAM,GAAG,OAAO;CACvC;CACA,OAA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