@gaganref/confect-core 10.3.1-fork.72 → 10.3.1-fork.73
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/App.d.ts +27 -88
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +23 -36
- package/dist/App.js.map +1 -1
- package/dist/Auth.d.ts +2 -3
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +2 -1
- package/dist/Auth.js.map +1 -1
- package/dist/Component.d.ts +39 -0
- package/dist/Component.d.ts.map +1 -1
- package/dist/Component.js +22 -4
- package/dist/Component.js.map +1 -1
- package/dist/GenericId.js +3 -3
- package/dist/Http.js +1 -1
- package/dist/Mount.d.ts +182 -0
- package/dist/Mount.d.ts.map +1 -0
- package/dist/Mount.js +57 -0
- package/dist/Mount.js.map +1 -0
- package/dist/PaginationError.js +1 -1
- package/dist/Ref.js +2 -2
- package/dist/Refs.js +1 -1
- package/dist/SchemaToValidator.js +6 -6
- package/dist/SystemFields.js +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -5
- package/package.json +1 -1
- package/src/App.ts +32 -130
- package/src/Auth.ts +6 -5
- package/src/Component.ts +50 -0
- package/src/Mount.ts +284 -0
- package/src/index.ts +1 -0
package/dist/App.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { ComponentDefinition
|
|
2
|
-
import type { Infer, Validator } from "convex/values";
|
|
1
|
+
import type { ComponentDefinition } from "convex/server";
|
|
3
2
|
import type * as HttpApi from "effect/http-api/HttpApi";
|
|
4
3
|
import type * as Env from "./Env.js";
|
|
5
4
|
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
5
|
+
import * as Mount from "./Mount.js";
|
|
6
6
|
declare const TypeId = "~@confect/core/App";
|
|
7
|
-
declare const MountTypeId = "~@confect/core/App/Mount";
|
|
8
7
|
/**
|
|
9
8
|
* The default export of a Convex component's `convex.config` module.
|
|
10
9
|
*/
|
|
@@ -14,110 +13,49 @@ export type HttpPrefix = `/${string}`;
|
|
|
14
13
|
* Any `HttpApi`, with its identifier and groups erased.
|
|
15
14
|
*/
|
|
16
15
|
export type Api = HttpApi.HttpApi<string, any>;
|
|
17
|
-
type EnvOf<D extends Definition> = D["__env"];
|
|
18
|
-
type IsOptional<V> = V extends Validator<any, "optional", any> ? true : false;
|
|
19
|
-
type RequiredKeys<E extends EnvDefinition> = {
|
|
20
|
-
[K in keyof E]: IsOptional<E[K]> extends true ? never : K;
|
|
21
|
-
}[keyof E];
|
|
22
|
-
type SlotValue<V extends Validator<any, any, any>> = Extract<Infer<V>, string>;
|
|
23
|
-
/**
|
|
24
|
-
* What one component env slot accepts: a constant, or an entry whose Convex
|
|
25
|
-
* value fits. A required slot takes only a required entry.
|
|
26
|
-
*/
|
|
27
|
-
type Slot<V extends Validator<any, any, any>> = IsOptional<V> extends true ? SlotValue<V> | undefined | Env.Entry<string, any, SlotValue<V>, boolean> : SlotValue<V> | Env.Entry<string, any, SlotValue<V>, false>;
|
|
28
|
-
export type Bindings<E extends EnvDefinition> = {
|
|
29
|
-
readonly [K in RequiredKeys<E>]: Slot<E[K]>;
|
|
30
|
-
} & {
|
|
31
|
-
readonly [K in Exclude<keyof E, RequiredKeys<E>>]?: Slot<E[K]>;
|
|
32
|
-
};
|
|
33
|
-
type HttpOptions = {
|
|
34
|
-
readonly httpPrefix?: HttpPrefix;
|
|
35
|
-
};
|
|
36
|
-
export type Options<D extends Definition> = HttpOptions & ([RequiredKeys<EnvOf<D>>] extends [never] ? {
|
|
37
|
-
readonly env?: Bindings<EnvOf<D>>;
|
|
38
|
-
} : {
|
|
39
|
-
readonly env: Bindings<EnvOf<D>>;
|
|
40
|
-
});
|
|
41
|
-
type Exact<D extends Definition, O> = {
|
|
42
|
-
readonly [K in Exclude<keyof O, "env" | "httpPrefix">]: never;
|
|
43
|
-
} & (O extends {
|
|
44
|
-
readonly env: infer B;
|
|
45
|
-
} ? {
|
|
46
|
-
readonly env: {
|
|
47
|
-
readonly [K in Exclude<keyof B, keyof EnvOf<D>>]: never;
|
|
48
|
-
};
|
|
49
|
-
} : unknown);
|
|
50
|
-
export interface MountData {
|
|
51
|
-
readonly definition: Definition;
|
|
52
|
-
readonly httpPrefix: HttpPrefix | undefined;
|
|
53
|
-
readonly env: Readonly<Record<string, string | Env.AnyEntry | undefined>>;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* A mounted Convex component. `O` keeps the options as written, so {@link make}
|
|
57
|
-
* can see which backends the bound entries come from.
|
|
58
|
-
*/
|
|
59
|
-
export interface Mount<out D extends Definition, out O> extends MountData {
|
|
60
|
-
readonly [MountTypeId]: {
|
|
61
|
-
readonly definition: D;
|
|
62
|
-
readonly options: O;
|
|
63
|
-
};
|
|
64
|
-
readonly httpPrefix: O extends {
|
|
65
|
-
readonly httpPrefix: infer P extends HttpPrefix;
|
|
66
|
-
} ? P : undefined;
|
|
67
|
-
}
|
|
68
|
-
export type AnyMount = Mount<Definition, unknown>;
|
|
69
|
-
/**
|
|
70
|
-
* Mount a Convex component: the default export of its `convex.config` module,
|
|
71
|
-
* official or Confect-authored. `env` is typed against the component's own
|
|
72
|
-
* `defineComponent({ env })` declaration, so a missing required binding, an
|
|
73
|
-
* optional entry in a required slot, a wrong literal and an unknown slot fail
|
|
74
|
-
* to typecheck.
|
|
75
|
-
*/
|
|
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, {}>;
|
|
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>;
|
|
78
16
|
type OwnerOf<V> = V extends Env.Entry<infer N, any, any, any> ? N : never;
|
|
79
|
-
type Owners<M> = M extends Mount<
|
|
80
|
-
readonly env: infer B;
|
|
81
|
-
} ? {
|
|
17
|
+
type Owners<M> = M extends Mount.Mount<any, any, Mount.Declared<any, infer B>> ? {
|
|
82
18
|
[K in keyof B]: OwnerOf<B[K]>;
|
|
83
|
-
}[keyof B] : never
|
|
19
|
+
}[keyof B] : never;
|
|
84
20
|
type OwnedBy<N extends string, M> = {
|
|
85
21
|
readonly [K in keyof M]: [Exclude<Owners<M[K]>, N>] extends [never] ? unknown : {
|
|
86
22
|
readonly foreignEnvBackend: Exclude<Owners<M[K]>, N>;
|
|
87
23
|
};
|
|
88
24
|
};
|
|
89
25
|
export type Kind = "app" | "component";
|
|
90
|
-
export interface App<E extends Env.Any, M extends
|
|
26
|
+
export interface App<E extends Env.Any, M extends ReadonlyArray<Mount.Any>, K extends Kind = Kind> {
|
|
91
27
|
readonly [TypeId]: typeof TypeId;
|
|
92
28
|
readonly kind: K;
|
|
93
29
|
readonly env: E;
|
|
30
|
+
readonly components: ReadonlyArray<Definition>;
|
|
94
31
|
readonly mounts: M;
|
|
95
32
|
readonly requiresMiddleware: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;
|
|
96
33
|
}
|
|
97
|
-
export type Any = App<Env.Any,
|
|
34
|
+
export type Any = App<Env.Any, ReadonlyArray<Mount.Any>>;
|
|
98
35
|
/**
|
|
99
|
-
* Declare a backend, in `confect/app.ts`: its env
|
|
100
|
-
* components
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
36
|
+
* Declare a backend, in `confect/app.ts`: its env, the `convex.config`
|
|
37
|
+
* definitions of the Convex components it mounts, and its mounts. Set `kind:
|
|
38
|
+
* "component"` when declaring a component; the default is `"app"`. Codegen
|
|
39
|
+
* rejects a kind that differs from its target, and writes
|
|
40
|
+
* `convex/convex.config.ts` with one `app.use` per mount, in list order, using
|
|
41
|
+
* the definition whose `defineComponent` name is the mount's component name. A
|
|
42
|
+
* mount that binds another backend's env entry fails to typecheck.
|
|
104
43
|
*
|
|
105
44
|
* ```ts
|
|
45
|
+
* import email from "@acme/email/convex.config";
|
|
46
|
+
* import workpool from "@convex-dev/workpool/convex.config";
|
|
47
|
+
*
|
|
106
48
|
* export default App.make({
|
|
107
49
|
* env,
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* httpPrefix: "/email",
|
|
111
|
-
* env: { FROM: env.EMAIL_FROM, KEY: env.RESEND_API_KEY },
|
|
112
|
-
* }),
|
|
113
|
-
* importsPool: App.mount(workpool),
|
|
114
|
-
* },
|
|
50
|
+
* components: [email, workpool],
|
|
51
|
+
* mounts: [BulkEmail, TransactionalEmail, ImportsPool],
|
|
115
52
|
* });
|
|
116
53
|
* ```
|
|
117
54
|
*/
|
|
118
|
-
export declare const make: <const E extends Env.Any, const M extends
|
|
55
|
+
export declare const make: <const E extends Env.Any, const M extends ReadonlyArray<Mount.Any> = [], const K extends Kind = "app">(options: {
|
|
119
56
|
readonly env: E;
|
|
120
57
|
readonly requiresMiddleware?: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;
|
|
58
|
+
readonly components?: ReadonlyArray<Definition>;
|
|
121
59
|
readonly mounts?: M & OwnedBy<NoInfer<Env.Name<E>>, NoInfer<M>>;
|
|
122
60
|
} & ([K] extends ["app"] ? {
|
|
123
61
|
readonly kind?: K;
|
|
@@ -125,13 +63,14 @@ export declare const make: <const E extends Env.Any, const M extends Readonly<Re
|
|
|
125
63
|
readonly kind: K;
|
|
126
64
|
})) => App<E, M, K>;
|
|
127
65
|
export declare const isApp: (u: unknown) => u is Any;
|
|
128
|
-
export declare const isMount: (u: unknown) => u is AnyMount;
|
|
129
66
|
export declare const env: <A extends Any>(app: A) => A["env"];
|
|
130
67
|
/**
|
|
131
|
-
*
|
|
68
|
+
* The `convex.config` definitions the backend lists, in list order.
|
|
69
|
+
*/
|
|
70
|
+
export declare const components: (app: Any) => ReadonlyArray<Definition>;
|
|
71
|
+
/**
|
|
72
|
+
* What each mount was declared with, in list order.
|
|
132
73
|
*/
|
|
133
|
-
export declare const mounts: (app: Any) => ReadonlyArray<
|
|
134
|
-
readonly name: string;
|
|
135
|
-
}>;
|
|
74
|
+
export declare const mounts: (app: Any) => ReadonlyArray<Mount.Data>;
|
|
136
75
|
export {};
|
|
137
76
|
//# sourceMappingURL=App.d.ts.map
|
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,
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,KAAK,OAAO,MAAM,yBAAyB,CAAC;AAExD,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,KAAK,cAAc,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AAEpC,QAAA,MAAM,MAAM,uBAAuB,CAAC;AAEpC;;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,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE1E,KAAK,MAAM,CAAC,CAAC,IACX,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,GACzD;KAAG,CAAC,IAAI,MAAM,C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Predicate";
|
|
3
4
|
//#region src/App.ts
|
|
4
5
|
var App_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
components: () => components,
|
|
5
7
|
env: () => env,
|
|
6
8
|
isApp: () => isApp,
|
|
7
|
-
isMount: () => isMount,
|
|
8
9
|
make: () => make,
|
|
9
|
-
mount: () => mount,
|
|
10
10
|
mounts: () => mounts
|
|
11
11
|
});
|
|
12
12
|
const TypeId = "~@confect/core/App";
|
|
13
|
-
const MountTypeId = "~@confect/core/App/Mount";
|
|
14
|
-
function mount(definition, options) {
|
|
15
|
-
return {
|
|
16
|
-
[MountTypeId]: {
|
|
17
|
-
definition,
|
|
18
|
-
options
|
|
19
|
-
},
|
|
20
|
-
definition,
|
|
21
|
-
httpPrefix: options?.httpPrefix,
|
|
22
|
-
env: options?.env ?? {}
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
13
|
/**
|
|
26
|
-
* Declare a backend, in `confect/app.ts`: its env
|
|
27
|
-
* components
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
14
|
+
* Declare a backend, in `confect/app.ts`: its env, the `convex.config`
|
|
15
|
+
* definitions of the Convex components it mounts, and its mounts. Set `kind:
|
|
16
|
+
* "component"` when declaring a component; the default is `"app"`. Codegen
|
|
17
|
+
* rejects a kind that differs from its target, and writes
|
|
18
|
+
* `convex/convex.config.ts` with one `app.use` per mount, in list order, using
|
|
19
|
+
* the definition whose `defineComponent` name is the mount's component name. A
|
|
20
|
+
* mount that binds another backend's env entry fails to typecheck.
|
|
31
21
|
*
|
|
32
22
|
* ```ts
|
|
23
|
+
* import email from "@acme/email/convex.config";
|
|
24
|
+
* import workpool from "@convex-dev/workpool/convex.config";
|
|
25
|
+
*
|
|
33
26
|
* export default App.make({
|
|
34
27
|
* env,
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* httpPrefix: "/email",
|
|
38
|
-
* env: { FROM: env.EMAIL_FROM, KEY: env.RESEND_API_KEY },
|
|
39
|
-
* }),
|
|
40
|
-
* importsPool: App.mount(workpool),
|
|
41
|
-
* },
|
|
28
|
+
* components: [email, workpool],
|
|
29
|
+
* mounts: [BulkEmail, TransactionalEmail, ImportsPool],
|
|
42
30
|
* });
|
|
43
31
|
* ```
|
|
44
32
|
*/
|
|
@@ -46,22 +34,21 @@ const make = (options) => ({
|
|
|
46
34
|
[TypeId]: TypeId,
|
|
47
35
|
kind: options.kind ?? "app",
|
|
48
36
|
env: options.env,
|
|
49
|
-
|
|
37
|
+
components: options.components ?? [],
|
|
38
|
+
mounts: options.mounts ?? [],
|
|
50
39
|
requiresMiddleware: options.requiresMiddleware ?? []
|
|
51
40
|
});
|
|
52
41
|
const isApp = (u) => Predicate.hasProperty(u, TypeId) && u[TypeId] === TypeId && Predicate.hasProperty(u, "kind") && (u.kind === "app" || u.kind === "component");
|
|
53
|
-
const isMount = (u) => Predicate.hasProperty(u, MountTypeId);
|
|
54
42
|
const env = (app) => app.env;
|
|
55
43
|
/**
|
|
56
|
-
*
|
|
44
|
+
* The `convex.config` definitions the backend lists, in list order.
|
|
45
|
+
*/
|
|
46
|
+
const components = (app) => app.components;
|
|
47
|
+
/**
|
|
48
|
+
* What each mount was declared with, in list order.
|
|
57
49
|
*/
|
|
58
|
-
const mounts = (app) =>
|
|
59
|
-
name,
|
|
60
|
-
definition: installed.definition,
|
|
61
|
-
httpPrefix: installed.httpPrefix,
|
|
62
|
-
env: installed.env
|
|
63
|
-
}));
|
|
50
|
+
const mounts = (app) => app.mounts.map(data);
|
|
64
51
|
//#endregion
|
|
65
|
-
export { App_exports, env, isApp,
|
|
52
|
+
export { App_exports, components, env, isApp, make, mounts };
|
|
66
53
|
|
|
67
54
|
//# sourceMappingURL=App.js.map
|
package/dist/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.js","names":[],"sources":["../src/App.ts"],"sourcesContent":["import type { ComponentDefinition
|
|
1
|
+
{"version":3,"file":"App.js","names":["Mount.data"],"sources":["../src/App.ts"],"sourcesContent":["import type { ComponentDefinition } from \"convex/server\";\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\";\nimport * as Mount from \"./Mount.js\";\n\nconst TypeId = \"~@confect/core/App\";\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 OwnerOf<V> = V extends Env.Entry<infer N, any, any, any> ? N : never;\n\ntype Owners<M> =\n M extends Mount.Mount<any, any, Mount.Declared<any, infer B>>\n ? { [K in keyof B]: OwnerOf<B[K]> }[keyof B]\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 ReadonlyArray<Mount.Any>,\n K extends Kind = Kind,\n> {\n readonly [TypeId]: typeof TypeId;\n readonly kind: K;\n readonly env: E;\n readonly components: ReadonlyArray<Definition>;\n readonly mounts: M;\n readonly requiresMiddleware: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n}\n\nexport type Any = App<Env.Any, ReadonlyArray<Mount.Any>>;\n\n/**\n * Declare a backend, in `confect/app.ts`: its env, the `convex.config`\n * definitions of the Convex components it mounts, and its mounts. Set `kind:\n * \"component\"` when declaring a component; the default is `\"app\"`. Codegen\n * rejects a kind that differs from its target, and writes\n * `convex/convex.config.ts` with one `app.use` per mount, in list order, using\n * the definition whose `defineComponent` name is the mount's component name. A\n * mount that binds another backend's env entry fails to typecheck.\n *\n * ```ts\n * import email from \"@acme/email/convex.config\";\n * import workpool from \"@convex-dev/workpool/convex.config\";\n *\n * export default App.make({\n * env,\n * components: [email, workpool],\n * mounts: [BulkEmail, TransactionalEmail, ImportsPool],\n * });\n * ```\n */\nexport const make = <\n const E extends Env.Any,\n const M extends ReadonlyArray<Mount.Any> = [],\n const K extends Kind = \"app\",\n>(\n options: {\n readonly env: E;\n readonly requiresMiddleware?: ReadonlyArray<MiddlewareSpec.AnyMiddlewareSpec>;\n readonly components?: ReadonlyArray<Definition>;\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 components: options.components ?? [],\n mounts: options.mounts ?? ([] as unknown 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 env = <A extends Any>(app: A): A[\"env\"] => app.env;\n\n/**\n * The `convex.config` definitions the backend lists, in list order.\n */\nexport const components = (app: Any): ReadonlyArray<Definition> =>\n app.components;\n\n/**\n * What each mount was declared with, in list order.\n */\nexport const mounts = (app: Any): ReadonlyArray<Mount.Data> =>\n app.mounts.map(Mount.data);\n"],"mappings":";;;;;;;;;;;AAOA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;AAgEf,MAAa,QAKX,aAMkB;EACjB,SAAS;CACV,MAAM,QAAQ,QAAS;CACvB,KAAK,QAAQ;CACb,YAAY,QAAQ,cAAc,CAAC;CACnC,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,OAAsB,QAAqB,IAAI;;;;AAK5D,MAAa,cAAc,QACzB,IAAI;;;;AAKN,MAAa,UAAU,QACrB,IAAI,OAAO,IAAIA,IAAU"}
|
package/dist/Auth.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AuthProvider } from "convex/server";
|
|
2
2
|
import type * as App from "./App.js";
|
|
3
3
|
import type * as Env from "./Env.js";
|
|
4
|
+
import * as Mount from "./Mount.js";
|
|
4
5
|
import type { TypeError } from "./Types.js";
|
|
5
6
|
declare const TypeId = "~@confect/core/Auth";
|
|
6
7
|
declare const CloudUrlTypeId = "~@confect/core/Auth/CloudUrl";
|
|
@@ -56,9 +57,7 @@ export type Any = Auth<App.Any>;
|
|
|
56
57
|
* component's HTTP routes.
|
|
57
58
|
*/
|
|
58
59
|
export declare function siteUrl(path?: `/${string}`): SiteUrl;
|
|
59
|
-
export declare function siteUrl(mount: {
|
|
60
|
-
readonly httpPrefix: App.HttpPrefix;
|
|
61
|
-
}, path?: `/${string}`): SiteUrl;
|
|
60
|
+
export declare function siteUrl(mount: Mount.Mount<any, string, Mount.Declared<App.HttpPrefix>>, path?: `/${string}`): SiteUrl;
|
|
62
61
|
export type AppOnlyError = TypeError<"Auth.make accepts only app declarations; components receive identity through function arguments", never>;
|
|
63
62
|
type AppOnly<A extends App.Any> = [A["kind"]] extends ["app"] ? unknown : AppOnlyError;
|
|
64
63
|
/**
|
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,KAAK,GAAG,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,M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MAAM,YAAY,GAAG,SAAS,CAClC,iGAAiG,EACjG,KAAK,CACN,CAAC;AAEF,KAAK,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACzD,OAAO,GACP,YAAY,CAAC;AAEjB;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,GAAG,CAAC,GAAG,OAC/B,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WACnB;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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { data } from "./Mount.js";
|
|
2
3
|
import * as Predicate from "effect/Predicate";
|
|
3
4
|
//#region src/Auth.ts
|
|
4
5
|
var Auth_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -27,7 +28,7 @@ const cloudUrlPath = (u) => Predicate.hasProperty(u, CloudUrlTypeId) && Predicat
|
|
|
27
28
|
function siteUrl(pathOrMount, path = "") {
|
|
28
29
|
return {
|
|
29
30
|
[SiteUrlTypeId]: SiteUrlTypeId,
|
|
30
|
-
path: typeof pathOrMount === "
|
|
31
|
+
path: typeof pathOrMount === "string" || pathOrMount === void 0 ? pathOrMount ?? "" : (data(pathOrMount).httpPrefix ?? "").replace(/\/+$/, "") + path
|
|
31
32
|
};
|
|
32
33
|
}
|
|
33
34
|
/**
|
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 * 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:
|
|
1
|
+
{"version":3,"file":"Auth.js","names":["Mount.data"],"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 * as Mount from \"./Mount.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: Mount.Mount<any, string, Mount.Declared<App.HttpPrefix>>,\n path?: `/${string}`,\n): SiteUrl;\nexport function siteUrl(\n pathOrMount?: `/${string}` | Mount.Any,\n path: string = \"\",\n): SiteUrl {\n return {\n [SiteUrlTypeId]: SiteUrlTypeId,\n path:\n typeof pathOrMount === \"string\" || pathOrMount === undefined\n ? (pathOrMount ?? \"\")\n : (Mount.data(pathOrMount).httpPrefix ?? \"\").replace(/\\/+$/, \"\") + path,\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":";;;;;;;;;;;;;AAOA,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,YAAY,gBAAgB,KAAA,IAC9C,eAAe,MACfA,KAAW,WAAW,CAAC,CAAC,cAAc,GAAA,CAAI,QAAQ,QAAQ,EAAE,IAAI;CACzE;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/Component.d.ts
CHANGED
|
@@ -115,5 +115,44 @@ export declare const schema: <From extends IdScope.IdScope, To extends IdScope.I
|
|
|
115
115
|
readonly scope: To;
|
|
116
116
|
};
|
|
117
117
|
}, codec: Schema_) => GenericId.RebaseSchema<Schema_, From, To>;
|
|
118
|
+
/**
|
|
119
|
+
* A component's `init`: an internal Confect mutation whose args are the install
|
|
120
|
+
* args each mount passes.
|
|
121
|
+
*/
|
|
122
|
+
export type Init = Ref.AnyConfect & {
|
|
123
|
+
readonly "~RuntimeAndFunctionType": RuntimeAndFunctionType.ConvexMutation;
|
|
124
|
+
readonly "~FunctionVisibility": "internal";
|
|
125
|
+
};
|
|
126
|
+
export interface DescriptorOptions {
|
|
127
|
+
readonly init?: Init;
|
|
128
|
+
/**
|
|
129
|
+
* The component's `_generated/component` contract. A mount of a descriptor
|
|
130
|
+
* with one rebases a callback slot's args with `callbackArgs`.
|
|
131
|
+
*/
|
|
132
|
+
readonly contract?: Component<Spec.AnyWithProps, IdScope.IdScope, string>;
|
|
133
|
+
readonly env?: Readonly<Record<string, Schema.Top>>;
|
|
134
|
+
/**
|
|
135
|
+
* Builds the component's client from its native mount, then the mount's
|
|
136
|
+
* `options` when the client takes any.
|
|
137
|
+
*/
|
|
138
|
+
readonly client: (...args: never) => unknown;
|
|
139
|
+
}
|
|
140
|
+
export type Descriptor<Name extends string = string, Options extends DescriptorOptions = DescriptorOptions> = Options & {
|
|
141
|
+
readonly name: Name;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Describe a Convex component for `Mount.make`, as `defineComponent` does for
|
|
145
|
+
* Convex. A component with `init` takes install `args` at each mount, and one
|
|
146
|
+
* with `env` takes `env`. Export it from the package's `./client` entry.
|
|
147
|
+
*
|
|
148
|
+
* ```ts
|
|
149
|
+
* export default Component.make("email", {
|
|
150
|
+
* init: refs.internal.install.init,
|
|
151
|
+
* env: { RESEND_API_KEY: Schema.String },
|
|
152
|
+
* client: Client.make,
|
|
153
|
+
* });
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare const make: <const Name extends string, const Options extends DescriptorOptions>(name: Name, options: Options) => Descriptor<Name, Options>;
|
|
118
157
|
export {};
|
|
119
158
|
//# sourceMappingURL=Component.d.ts.map
|
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,CAAC;AAChC,OAAO,KAAK,KAAK,IAAI,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,KAAK,sBAAsB,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;;;;AAElC,qBAAa,wBAAyB,SAAQ,8BAE5C;IACA,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,OAAO,CAAC;CAC3C,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;;;;AAED,qBAAa,2BAA4B,SAAQ,iCAE/C;IACA,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;;;;AAED,qBAAa,kCAAmC,SAAQ,wCAEtD;IACA,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,OAAO,CAAC;CAC3C,CAAC;IACA,IAAa,OAAO,IAAI,MAAM,CAE7B;CACF;AAmCD,QAAA,MAAM,MAAM,6BAA6B,CAAC;AAC1C,QAAA,MAAM,WAAW,kCAAkC,CAAC;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y.js";
|
|
3
|
-
import { fromProvenance, isRef, make } from "./Ref.js";
|
|
4
3
|
import { app, instance } from "./IdScope.js";
|
|
5
4
|
import { GenericId, rebase } from "./GenericId.js";
|
|
5
|
+
import { fromProvenance, isRef, make as make$1 } from "./Ref.js";
|
|
6
6
|
import { groups } from "./Spec.js";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import * as Data from "effect/Data";
|
|
9
9
|
import { getFunctionAddress } from "convex/server";
|
|
10
|
-
import * as Match from "effect/Match";
|
|
11
10
|
import * as Array from "effect/Array";
|
|
12
11
|
import * as Result from "effect/Result";
|
|
13
12
|
import { memoize, pipe } from "effect/Function";
|
|
13
|
+
import * as Match from "effect/Match";
|
|
14
14
|
import * as Record from "effect/Record";
|
|
15
15
|
//#region src/Component.ts
|
|
16
16
|
var Component_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -20,6 +20,7 @@ var Component_exports = /* @__PURE__ */ __exportAll({
|
|
|
20
20
|
bind: () => bind,
|
|
21
21
|
contract: () => contract,
|
|
22
22
|
id: () => id,
|
|
23
|
+
make: () => make,
|
|
23
24
|
schema: () => schema
|
|
24
25
|
});
|
|
25
26
|
var EmptyComponentScopeError = class extends Data.TaggedError("EmptyComponentScopeError") {
|
|
@@ -62,7 +63,7 @@ const contract = (spec, scope, tables) => {
|
|
|
62
63
|
const path = prefix === "" ? name : `${prefix}/${name}`;
|
|
63
64
|
const functions = pipe(group.functions, Record.filter((functionSpec) => {
|
|
64
65
|
return Match.value(functionSpec.functionVisibility).pipe(Match.when("public", () => true), Match.when("internal", () => false), Match.exhaustive);
|
|
65
|
-
}), Record.map((functionSpec) => make(path, functionSpec, group.middlewareAttachments)));
|
|
66
|
+
}), Record.map((functionSpec) => make$1(path, functionSpec, group.middlewareAttachments)));
|
|
66
67
|
return {
|
|
67
68
|
...collect(group.groups, path),
|
|
68
69
|
...functions
|
|
@@ -140,7 +141,24 @@ const id = (component, table) => GenericId(table, component[BoundTypeId].scope);
|
|
|
140
141
|
* scope.
|
|
141
142
|
*/
|
|
142
143
|
const schema = (component, codec) => rebase(codec, component[BoundTypeId].from, component[BoundTypeId].scope);
|
|
144
|
+
/**
|
|
145
|
+
* Describe a Convex component for `Mount.make`, as `defineComponent` does for
|
|
146
|
+
* Convex. A component with `init` takes install `args` at each mount, and one
|
|
147
|
+
* with `env` takes `env`. Export it from the package's `./client` entry.
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* export default Component.make("email", {
|
|
151
|
+
* init: refs.internal.install.init,
|
|
152
|
+
* env: { RESEND_API_KEY: Schema.String },
|
|
153
|
+
* client: Client.make,
|
|
154
|
+
* });
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
const make = (name, options) => ({
|
|
158
|
+
...options,
|
|
159
|
+
name
|
|
160
|
+
});
|
|
143
161
|
//#endregion
|
|
144
|
-
export { ComponentNameCollisionError, Component_exports, EmptyComponentScopeError, UninstalledComponentReferenceError, bind, contract, id, schema };
|
|
162
|
+
export { ComponentNameCollisionError, Component_exports, EmptyComponentScopeError, UninstalledComponentReferenceError, bind, contract, id, make, schema };
|
|
145
163
|
|
|
146
164
|
//# sourceMappingURL=Component.js.map
|