@gaganref/confect-core 10.3.1-fork.7 → 10.3.1-fork.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActionCall.d.ts +18 -0
- package/dist/ActionCall.d.ts.map +1 -0
- package/dist/ActionCall.js +21 -0
- package/dist/ActionCall.js.map +1 -0
- package/dist/App.d.ts +6 -8
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +2 -3
- package/dist/App.js.map +1 -1
- package/dist/Auth.d.ts +31 -6
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +15 -1
- package/dist/Auth.js.map +1 -1
- package/dist/Callback.d.ts +7 -2
- package/dist/Callback.d.ts.map +1 -1
- package/dist/Callback.js +11 -6
- package/dist/Callback.js.map +1 -1
- package/dist/Component.d.ts +1 -1
- package/dist/Component.d.ts.map +1 -1
- package/dist/Component.js +12 -12
- package/dist/Component.js.map +1 -1
- package/dist/FunctionSpec.d.ts +365 -2
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +66 -3
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GroupSpec.js +1 -1
- package/dist/Http.d.ts +4 -8
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js +14 -21
- package/dist/Http.js.map +1 -1
- package/dist/ManifestSection.d.ts +68 -0
- package/dist/ManifestSection.d.ts.map +1 -0
- package/dist/ManifestSection.js +7 -0
- package/dist/ManifestSection.js.map +1 -0
- package/dist/Profile.d.ts +95 -0
- package/dist/Profile.d.ts.map +1 -0
- package/dist/Profile.js +15 -0
- package/dist/Profile.js.map +1 -0
- package/dist/Ref.d.ts +4 -3
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +11 -17
- package/dist/Ref.js.map +1 -1
- package/dist/RefInternal.d.ts +3 -0
- package/dist/RefInternal.d.ts.map +1 -0
- package/dist/RefInternal.js +16 -0
- package/dist/RefInternal.js.map +1 -0
- package/dist/SchemaToValidator.d.ts +11 -2
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +40 -11
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/SystemFields.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -6
- package/dist/internal/annotations.d.ts +2 -0
- package/dist/internal/annotations.d.ts.map +1 -0
- package/dist/internal/annotations.js +6 -0
- package/dist/internal/annotations.js.map +1 -0
- package/dist/internal/scalarDocs.d.ts +5 -0
- package/dist/internal/scalarDocs.d.ts.map +1 -0
- package/dist/internal/scalarDocs.js +43 -0
- package/dist/internal/scalarDocs.js.map +1 -0
- package/package.json +3 -3
- package/src/ActionCall.ts +25 -0
- package/src/App.ts +7 -9
- package/src/Auth.ts +48 -6
- package/src/Callback.ts +17 -4
- package/src/Component.ts +8 -6
- package/src/FunctionSpec.ts +566 -5
- package/src/Http.ts +15 -37
- package/src/ManifestSection.ts +76 -0
- package/src/Profile.ts +141 -0
- package/src/Ref.ts +19 -26
- package/src/RefInternal.ts +26 -0
- package/src/SchemaToValidator.ts +47 -5
- package/src/index.ts +3 -0
- package/src/internal/annotations.ts +1 -0
- 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
|
/**
|
|
@@ -30,11 +31,7 @@ export type Bindings<E extends EnvDefinition> = {
|
|
|
30
31
|
readonly [K in Exclude<keyof E, RequiredKeys<E>>]?: Slot<E[K]>;
|
|
31
32
|
};
|
|
32
33
|
type HttpOptions = {
|
|
33
|
-
readonly httpPrefix?:
|
|
34
|
-
readonly api?: never;
|
|
35
|
-
} | {
|
|
36
|
-
readonly httpPrefix: HttpPrefix;
|
|
37
|
-
readonly api?: Api;
|
|
34
|
+
readonly httpPrefix?: HttpPrefix;
|
|
38
35
|
};
|
|
39
36
|
export type Options<D extends Definition> = HttpOptions & ([RequiredKeys<EnvOf<D>>] extends [never] ? {
|
|
40
37
|
readonly env?: Bindings<EnvOf<D>>;
|
|
@@ -42,7 +39,7 @@ export type Options<D extends Definition> = HttpOptions & ([RequiredKeys<EnvOf<D
|
|
|
42
39
|
readonly env: Bindings<EnvOf<D>>;
|
|
43
40
|
});
|
|
44
41
|
type Exact<D extends Definition, O> = {
|
|
45
|
-
readonly [K in Exclude<keyof O, "env" | "httpPrefix"
|
|
42
|
+
readonly [K in Exclude<keyof O, "env" | "httpPrefix">]: never;
|
|
46
43
|
} & (O extends {
|
|
47
44
|
readonly env: infer B;
|
|
48
45
|
} ? {
|
|
@@ -53,7 +50,6 @@ type Exact<D extends Definition, O> = {
|
|
|
53
50
|
export interface MountData {
|
|
54
51
|
readonly definition: Definition;
|
|
55
52
|
readonly httpPrefix: HttpPrefix | undefined;
|
|
56
|
-
readonly api: Api | undefined;
|
|
57
53
|
readonly env: Readonly<Record<string, string | Env.AnyEntry | undefined>>;
|
|
58
54
|
}
|
|
59
55
|
/**
|
|
@@ -75,7 +71,7 @@ export type AnyMount = Mount<Definition, unknown>;
|
|
|
75
71
|
* official or Confect-authored. `env` is typed against the component's own
|
|
76
72
|
* `defineComponent({ env })` declaration, so a missing required binding, an
|
|
77
73
|
* optional entry in a required slot, a wrong literal and an unknown slot fail
|
|
78
|
-
* to typecheck.
|
|
74
|
+
* to typecheck.
|
|
79
75
|
*/
|
|
80
76
|
export declare function mount<const D extends Definition>(definition: D & ([RequiredKeys<EnvOf<D>>] extends [never] ? unknown : "App.mount: this component declares required env; pass { env }")): Mount<D, {}>;
|
|
81
77
|
export declare function mount<const D extends Definition, const O extends Options<D>>(definition: D, options: O & Exact<NoInfer<D>, NoInfer<O>>): Mount<D, O>;
|
|
@@ -96,6 +92,7 @@ export interface App<E extends Env.Any, M extends Readonly<Record<string, AnyMou
|
|
|
96
92
|
readonly kind: K;
|
|
97
93
|
readonly env: E;
|
|
98
94
|
readonly mounts: M;
|
|
95
|
+
readonly requiresMiddleware: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;
|
|
99
96
|
}
|
|
100
97
|
export type Any = App<Env.Any, Readonly<Record<string, AnyMount>>>;
|
|
101
98
|
/**
|
|
@@ -120,6 +117,7 @@ export type Any = App<Env.Any, Readonly<Record<string, AnyMount>>>;
|
|
|
120
117
|
*/
|
|
121
118
|
export declare const make: <const E extends Env.Any, const M extends Readonly<Record<string, AnyMount>> = {}, const K extends Kind = "app">(options: {
|
|
122
119
|
readonly env: E;
|
|
120
|
+
readonly requiresMiddleware?: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;
|
|
123
121
|
readonly mounts?: M & OwnedBy<NoInfer<Env.Name<E>>, NoInfer<M>>;
|
|
124
122
|
} & ([K] extends ["app"] ? {
|
|
125
123
|
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;
|
|
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;AACrC,OAAO,KAAK,KAAK,cAAc,MAAM,qBAAqB,CAAC;AAE3D,QAAA,MAAM,MAAM,uBAAuB,CAAC;AACpC,QAAA,MAAM,WAAW,6BAA6B,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,mBAAmB,CAAC,GAAG,EAAE,G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MAAM,QACZ,GAAG,KACP,aAAa,CAAC,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAMjD,CAAC"}
|
package/dist/App.js
CHANGED
|
@@ -19,7 +19,6 @@ function mount(definition, options) {
|
|
|
19
19
|
},
|
|
20
20
|
definition,
|
|
21
21
|
httpPrefix: options?.httpPrefix,
|
|
22
|
-
api: options?.api,
|
|
23
22
|
env: options?.env ?? {}
|
|
24
23
|
};
|
|
25
24
|
}
|
|
@@ -47,7 +46,8 @@ const make = (options) => ({
|
|
|
47
46
|
[TypeId]: TypeId,
|
|
48
47
|
kind: options.kind ?? "app",
|
|
49
48
|
env: options.env,
|
|
50
|
-
mounts: options.mounts ?? {}
|
|
49
|
+
mounts: options.mounts ?? {},
|
|
50
|
+
requiresMiddleware: options.requiresMiddleware ?? []
|
|
51
51
|
});
|
|
52
52
|
const isApp = (u) => Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId && Predicate.hasProperty(u, "kind") && (u.kind === "app" || u.kind === "component");
|
|
53
53
|
const isMount = (u) => Predicate.hasProperty(u, MountTypeId);
|
|
@@ -59,7 +59,6 @@ const mounts = (app) => Object.entries(app.mounts).map(([name, installed]) => ({
|
|
|
59
59
|
name,
|
|
60
60
|
definition: installed.definition,
|
|
61
61
|
httpPrefix: installed.httpPrefix,
|
|
62
|
-
api: installed.api,
|
|
63
62
|
env: installed.env
|
|
64
63
|
}));
|
|
65
64
|
//#endregion
|
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
|
|
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 = { readonly httpPrefix?: HttpPrefix };\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\">]: 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 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.\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 env?: MountData[\"env\"];\n },\n): AnyMount {\n return {\n [MountTypeId]: { definition, options },\n definition,\n httpPrefix: options?.httpPrefix,\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 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 env: installed.env,\n }));\n"],"mappings":";;;;;;;;;;;AAOA,MAAM,SAAS;AACf,MAAM,cAAc;AA4FpB,SAAgB,MACd,YACA,SAIU;CACV,OAAO;GACJ,cAAc;GAAE;GAAY;EAAQ;EACrC;EACA,YAAY,SAAS;EACrB,KAAK,SAAS,OAAO,CAAC;CAExB;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;AACjB,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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
20
|
-
|
|
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
|
|
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;
|
package/dist/Auth.d.ts.map
CHANGED
|
@@ -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,C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B;IAAE,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;CAAE,KACvD,IAAI,CAAC,CAAC,CAA8D,CAAC;AAExE,eAAO,MAAM,MAAM,MAAO,OAAO,KAAG,CAAC,IAAI,GACiB,CAAC;AAE3D,eAAO,MAAM,SAAS,SAAU,GAAG,KAAG,aAAa,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
|
|
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;;;;AAkDtB,MAAa,YAAY,OAA0B,QAAkB;EAClE,iBAAiB;CAClB;AACF;;;;AAKA,MAAa,gBAAgB,MAC3B,UAAU,YAAY,GAAG,cAAc,KACvC,UAAU,YAAY,GAAG,MAAM,KAC/B,OAAO,EAAE,SAAS,WACd,EAAE,OACF,KAAA;AAmBN,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"}
|
package/dist/Callback.d.ts
CHANGED
|
@@ -66,9 +66,14 @@ export declare const action: <const Id_ extends Id, const ArgsFields_ extends Fu
|
|
|
66
66
|
}) => Contract<Id_, "action", ArgsFields_, Returns_, Error_>;
|
|
67
67
|
/**
|
|
68
68
|
* The schema of a handle for `contract`: a string on the wire, a runnable ref
|
|
69
|
-
* once decoded. Use it in a component's function args or tables.
|
|
69
|
+
* once decoded. Use it in a component's function args or tables. It lowers to
|
|
70
|
+
* Convex's `v.function` with the contract's encoded args and returns.
|
|
71
|
+
* `reservedArgument` opts mutation and action handles into context forwarding.
|
|
72
|
+
* The host target must reserve the same argument name.
|
|
70
73
|
*/
|
|
71
|
-
export declare const handle: <Contract_ extends Any>(contract: Contract_
|
|
74
|
+
export declare const handle: <Contract_ extends Any>(contract: Contract_, options?: {
|
|
75
|
+
readonly reservedArgument?: Contract_["functionType"] extends "query" ? never : string;
|
|
76
|
+
}) => Schema.Codec<Handle<Contract_>, string>;
|
|
72
77
|
type EncodedArgs<Ref_> = Ref_ extends {
|
|
73
78
|
readonly _tag: "Confect";
|
|
74
79
|
readonly args: {
|
package/dist/Callback.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Callback.d.ts","sourceRoot":"","sources":["../src/Callback.ts"],"names":[],"mappings":"AAAA,OAA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AAG,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,10 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { Confect } from "./FunctionProvenance.js";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import { getFunctionReference } from "./RefInternal.js";
|
|
4
|
+
import { fromProvenance, isRef } from "./Ref.js";
|
|
5
|
+
import { CallbackContract } from "./internal/annotations.js";
|
|
5
6
|
import * as Schema from "effect/Schema";
|
|
7
|
+
import * as Predicate from "effect/Predicate";
|
|
6
8
|
import * as SchemaGetter from "effect/SchemaGetter";
|
|
7
9
|
//#region src/Callback.ts
|
|
8
10
|
var Callback_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -27,13 +29,16 @@ const query = make("query");
|
|
|
27
29
|
const mutation = make("mutation");
|
|
28
30
|
const action = make("action");
|
|
29
31
|
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 });
|
|
32
|
+
const fromText = (contract, text, reservedArgument) => Object.assign(fromProvenance(text, contract.functionProvenance, [], text, contract.functionType, contract.functionType === "query" ? void 0 : reservedArgument), { [HandleTypeId]: contract.id });
|
|
31
33
|
/**
|
|
32
34
|
* The schema of a handle for `contract`: a string on the wire, a runnable ref
|
|
33
|
-
* once decoded. Use it in a component's function args or tables.
|
|
35
|
+
* once decoded. Use it in a component's function args or tables. It lowers to
|
|
36
|
+
* Convex's `v.function` with the contract's encoded args and returns.
|
|
37
|
+
* `reservedArgument` opts mutation and action handles into context forwarding.
|
|
38
|
+
* The host target must reserve the same argument name.
|
|
34
39
|
*/
|
|
35
|
-
const handle = (contract) => Schema.String.pipe(Schema.decodeTo(Schema.declare(isHandleOf(contract), { identifier: `Callback.Handle<${contract.id}>` }), {
|
|
36
|
-
decode: SchemaGetter.transform((text) => fromText(contract, text)),
|
|
40
|
+
const handle = (contract, options) => Schema.String.annotate({ [CallbackContract]: contract }).pipe(Schema.decodeTo(Schema.declare(isHandleOf(contract), { identifier: `Callback.Handle<${contract.id}>` }), {
|
|
41
|
+
decode: SchemaGetter.transform((text) => fromText(contract, text, options?.reservedArgument)),
|
|
37
42
|
encode: SchemaGetter.transform((ref) => ref.convexFunctionName)
|
|
38
43
|
}));
|
|
39
44
|
/**
|
package/dist/Callback.js.map
CHANGED
|
@@ -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 { CallbackContract } from \"./internal/annotations.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 reservedArgument?: 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 contract.functionType === \"query\" ? undefined : reservedArgument,\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. It lowers to\n * Convex's `v.function` with the contract's encoded args and returns.\n * `reservedArgument` opts mutation and action handles into context forwarding.\n * The host target must reserve the same argument name.\n */\nexport const handle = <Contract_ extends Any>(\n contract: Contract_,\n options?: {\n readonly reservedArgument?: Contract_[\"functionType\"] extends \"query\"\n ? never\n : string;\n },\n): Schema.Codec<Handle<Contract_>, string> =>\n Schema.String.annotate({ [CallbackContract]: contract }).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, options?.reservedArgument),\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":";;;;;;;;;;;;;;;;;;AAcA,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,MACA,qBAEA,OAAO,OACLC,eACE,MACA,SAAS,oBACT,CAAC,GAED,MACA,SAAS,cACT,SAAS,iBAAiB,UAAU,KAAA,IAAY,gBAClD,GACA,GAAG,eAAe,SAAS,GAAG,CAChC;;;;;;;;AASF,MAAa,UACX,UACA,YAMA,OAAO,OAAO,SAAS,GAAG,mBAAmB,SAAS,CAAC,CAAC,CAAC,KACvD,OAAO,SACL,OAAO,QAAQ,WAAW,QAAQ,GAAG,EACnC,YAAY,mBAAmB,SAAS,GAAG,GAC7C,CAAC,GACD;CACE,QAAQ,aAAa,WAAW,SAC9B,SAAS,UAAU,MAAM,SAAS,gBAAgB,CACpD;CACA,QAAQ,aAAa,WAClB,QAA2B,IAAI,kBAClC;AACF,CACF,CACF;;;;;AA4HF,MAAa,YACX,QAMG,qBAAqB,GAAG"}
|
package/dist/Component.d.ts
CHANGED
|
@@ -88,7 +88,7 @@ export type Bound<Spec_ extends Spec.AnyWithProps, From extends IdScope.IdScope,
|
|
|
88
88
|
/**
|
|
89
89
|
* Build a publishable contract containing only exported functions and codecs.
|
|
90
90
|
*/
|
|
91
|
-
export declare const
|
|
91
|
+
export declare const contract: <Spec_ extends Spec.AnyWithProps, const Scope extends IdScope.IdScope, const Tables extends string>(spec: Spec_, scope: Scope, tables: ReadonlyArray<Tables>) => Component<Spec_, Scope, Tables>;
|
|
92
92
|
/**
|
|
93
93
|
* Bind the published contract to an actual installed component reference.
|
|
94
94
|
*/
|
package/dist/Component.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../src/Component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAQ5E,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,KAAK,YAAY,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,KAAK,SAAS,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,KAAK,GAAG,MAAM,UAAU,C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AC;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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { defineProperty } from "./Lazy.js";
|
|
3
|
-
import { fromProvenance, isRef, make
|
|
3
|
+
import { fromProvenance, isRef, make } from "./Ref.js";
|
|
4
4
|
import { app, instance } from "./IdScope.js";
|
|
5
5
|
import { GenericId, rebase } from "./GenericId.js";
|
|
6
6
|
import { groups } from "./Spec.js";
|
|
@@ -18,8 +18,8 @@ var Component_exports = /* @__PURE__ */ __exportAll({
|
|
|
18
18
|
EmptyComponentScopeError: () => EmptyComponentScopeError,
|
|
19
19
|
UninstalledComponentReferenceError: () => UninstalledComponentReferenceError,
|
|
20
20
|
bind: () => bind,
|
|
21
|
+
contract: () => contract,
|
|
21
22
|
id: () => id,
|
|
22
|
-
make: () => make,
|
|
23
23
|
schema: () => schema
|
|
24
24
|
});
|
|
25
25
|
var EmptyComponentScopeError = class extends Data.TaggedError("EmptyComponentScopeError") {
|
|
@@ -55,14 +55,14 @@ const BoundTypeId = "~@confect/core/BoundComponent";
|
|
|
55
55
|
/**
|
|
56
56
|
* Build a publishable contract containing only exported functions and codecs.
|
|
57
57
|
*/
|
|
58
|
-
const
|
|
58
|
+
const contract = (spec, scope, tables) => {
|
|
59
59
|
const specGroups = groups(spec);
|
|
60
60
|
Result.getOrThrow(validateContract(scope, specGroups));
|
|
61
61
|
const collect = (groups, prefix = "") => pipe(groups, Record.map((group, name) => {
|
|
62
62
|
const path = prefix === "" ? name : `${prefix}/${name}`;
|
|
63
63
|
const functions = pipe(group.functions, Record.filter((functionSpec) => {
|
|
64
64
|
return Match.value(functionSpec.functionVisibility).pipe(Match.when("public", () => true), Match.when("internal", () => false), Match.exhaustive);
|
|
65
|
-
}), Record.map((functionSpec) => make
|
|
65
|
+
}), Record.map((functionSpec) => make(path, functionSpec, group.middlewareAttachments)));
|
|
66
66
|
return {
|
|
67
67
|
...collect(group.groups, path),
|
|
68
68
|
...functions
|
|
@@ -78,11 +78,11 @@ const make = (spec, scope, tables) => {
|
|
|
78
78
|
* Bind the published contract to an actual installed component reference.
|
|
79
79
|
*/
|
|
80
80
|
const bind = (component, native, options) => {
|
|
81
|
-
const
|
|
81
|
+
const published = component[TypeId];
|
|
82
82
|
const address = getFunctionAddress(native);
|
|
83
|
-
const installedReference = Result.getOrThrow(Result.fromNullishOr(address.reference, () => new UninstalledComponentReferenceError({ definitionScope:
|
|
83
|
+
const installedReference = Result.getOrThrow(Result.fromNullishOr(address.reference, () => new UninstalledComponentReferenceError({ definitionScope: published.scope })));
|
|
84
84
|
const scope = instance(options?.parentScope ?? app, installedReference);
|
|
85
|
-
const rebase$1 = (schema) => rebase(schema,
|
|
85
|
+
const rebase$1 = (schema) => rebase(schema, published.scope, scope);
|
|
86
86
|
const rebaseMiddleware = memoize((middleware) => {
|
|
87
87
|
if (!("error" in middleware)) return middleware;
|
|
88
88
|
const boundMiddleware = Object.create(middleware);
|
|
@@ -119,15 +119,15 @@ 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
|
});
|
|
126
|
-
const refs = visit(
|
|
126
|
+
const refs = visit(published.refs, native);
|
|
127
127
|
Object.defineProperty(refs, BoundTypeId, { value: {
|
|
128
|
-
from:
|
|
128
|
+
from: published.scope,
|
|
129
129
|
scope,
|
|
130
|
-
tables:
|
|
130
|
+
tables: published.tables
|
|
131
131
|
} });
|
|
132
132
|
return refs;
|
|
133
133
|
};
|
|
@@ -141,6 +141,6 @@ const id = (component, table) => GenericId(table, component[BoundTypeId].scope);
|
|
|
141
141
|
*/
|
|
142
142
|
const schema = (component, codec) => rebase(codec, component[BoundTypeId].from, component[BoundTypeId].scope);
|
|
143
143
|
//#endregion
|
|
144
|
-
export { ComponentNameCollisionError, Component_exports, EmptyComponentScopeError, UninstalledComponentReferenceError, bind,
|
|
144
|
+
export { ComponentNameCollisionError, Component_exports, EmptyComponentScopeError, UninstalledComponentReferenceError, bind, contract, id, schema };
|
|
145
145
|
|
|
146
146
|
//# sourceMappingURL=Component.js.map
|