@gaganref/confect-core 10.3.1-fork.12 → 10.3.1-fork.14
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 +10 -2
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +4 -2
- package/dist/App.js.map +1 -1
- package/package.json +1 -1
- package/src/App.ts +15 -3
package/dist/App.d.ts
CHANGED
|
@@ -36,13 +36,20 @@ type HttpOptions = {
|
|
|
36
36
|
readonly httpPrefix: HttpPrefix;
|
|
37
37
|
readonly api?: Api;
|
|
38
38
|
};
|
|
39
|
-
export type Options<D extends Definition> = HttpOptions &
|
|
39
|
+
export type Options<D extends Definition> = HttpOptions & {
|
|
40
|
+
/**
|
|
41
|
+
* The package specifier of the module whose `register(t, name)` the generated
|
|
42
|
+
* test registry calls for this mount, in place of the component package's own
|
|
43
|
+
* `<package>/test`. The kit registers the mount's children.
|
|
44
|
+
*/
|
|
45
|
+
readonly testing?: string;
|
|
46
|
+
} & ([RequiredKeys<EnvOf<D>>] extends [never] ? {
|
|
40
47
|
readonly env?: Bindings<EnvOf<D>>;
|
|
41
48
|
} : {
|
|
42
49
|
readonly env: Bindings<EnvOf<D>>;
|
|
43
50
|
});
|
|
44
51
|
type Exact<D extends Definition, O> = {
|
|
45
|
-
readonly [K in Exclude<keyof O, "env" | "httpPrefix" | "api">]: never;
|
|
52
|
+
readonly [K in Exclude<keyof O, "env" | "httpPrefix" | "api" | "testing">]: never;
|
|
46
53
|
} & (O extends {
|
|
47
54
|
readonly env: infer B;
|
|
48
55
|
} ? {
|
|
@@ -55,6 +62,7 @@ export interface MountData {
|
|
|
55
62
|
readonly httpPrefix: HttpPrefix | undefined;
|
|
56
63
|
readonly api: Api | undefined;
|
|
57
64
|
readonly env: Readonly<Record<string, string | Env.AnyEntry | undefined>>;
|
|
65
|
+
readonly testing: string | undefined;
|
|
58
66
|
}
|
|
59
67
|
/**
|
|
60
68
|
* A mounted Convex component. `O` ke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C,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC,KACvE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAKZ,CAAC;AAEH,eAAO,MAAM,KAAK,MAAO,OAAO,KAAG,CAAC,IAAI,GAIM,CAAC;AAE/C,eAAO,MAAM,OAAO,MAAO,OAAO,KAAG,CAAC,IAAI,QACH,CAAC;AAExC,eAAO,MAAM,GAAG,GAAI,CAAC,SAAS,GAAG,OAAO,CAAC,KAAG,CAAC,CAAC,KAAK,CAAY,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,MAAM,QACZ,GAAG,KACP,aAAa,CAAC,SAAS,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAQjD,CAAC"}
|
package/dist/App.js
CHANGED
|
@@ -20,7 +20,8 @@ function mount(definition, options) {
|
|
|
20
20
|
definition,
|
|
21
21
|
httpPrefix: options?.httpPrefix,
|
|
22
22
|
api: options?.api,
|
|
23
|
-
env: options?.env ?? {}
|
|
23
|
+
env: options?.env ?? {},
|
|
24
|
+
testing: options?.testing
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
/**
|
|
@@ -60,7 +61,8 @@ const mounts = (app) => Object.entries(app.mounts).map(([name, installed]) => ({
|
|
|
60
61
|
definition: installed.definition,
|
|
61
62
|
httpPrefix: installed.httpPrefix,
|
|
62
63
|
api: installed.api,
|
|
63
|
-
env: installed.env
|
|
64
|
+
env: installed.env,
|
|
65
|
+
testing: installed.testing
|
|
64
66
|
}));
|
|
65
67
|
//#endregion
|
|
66
68
|
export { App_exports, env, isApp, isMount, make, mount, mounts };
|
package/dist/App.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"App.js","names":[],"sources":["../src/App.ts"],"sourcesContent":["import type { ComponentDefinition, EnvDefinition } from \"convex/server\";\nimport type { Infer, Validator } from \"convex/values\";\nimport type * as HttpApi from \"effect/http-api/HttpApi\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Env from \"./Env.js\";\n\nconst TypeId = \"~@confect/core/App\";\nconst MountTypeId = \"~@confect/core/App/Mount\";\n\n/**\n * The default export of a Convex component's `convex.config` module.\n */\nexport type Definition = ComponentDefinition<any, any>;\n\nexport type HttpPrefix = `/${string}`;\n\n/**\n * Any `HttpApi`, with its identifier and groups erased.\n */\nexport type Api = HttpApi.HttpApi<string, any>;\n\ntype EnvOf<D extends Definition> = D[\"__env\"];\n\ntype IsOptional<V> = V extends Validator<any, \"optional\", any> ? true : false;\n\ntype RequiredKeys<E extends EnvDefinition> = {\n [K in keyof E]: IsOptional<E[K]> extends true ? never : K;\n}[keyof E];\n\ntype SlotValue<V extends Validator<any, any, any>> = Extract<Infer<V>, string>;\n\n/**\n * What one component env slot accepts: a constant, or an entry whose Convex\n * value fits. A required slot takes only a required entry.\n */\ntype Slot<V extends Validator<any, any, any>> =\n IsOptional<V> extends true\n ? SlotValue<V> | undefined | Env.Entry<string, any, SlotValue<V>, boolean>\n : SlotValue<V> | Env.Entry<string, any, SlotValue<V>, false>;\n\nexport type Bindings<E extends EnvDefinition> = {\n readonly [K in RequiredKeys<E>]: Slot<E[K]>;\n} & {\n readonly [K in Exclude<keyof E, RequiredKeys<E>>]?: Slot<E[K]>;\n};\n\ntype HttpOptions =\n | { readonly httpPrefix?: never; readonly api?: never }\n | { readonly httpPrefix: HttpPrefix; readonly api?: Api };\n\nexport type Options<D extends Definition> = HttpOptions
|
|
1
|
+
{"version":3,"file":"App.js","names":[],"sources":["../src/App.ts"],"sourcesContent":["import type { ComponentDefinition, EnvDefinition } from \"convex/server\";\nimport type { Infer, Validator } from \"convex/values\";\nimport type * as HttpApi from \"effect/http-api/HttpApi\";\nimport * as Predicate from \"effect/Predicate\";\nimport type * as Env from \"./Env.js\";\n\nconst TypeId = \"~@confect/core/App\";\nconst MountTypeId = \"~@confect/core/App/Mount\";\n\n/**\n * The default export of a Convex component's `convex.config` module.\n */\nexport type Definition = ComponentDefinition<any, any>;\n\nexport type HttpPrefix = `/${string}`;\n\n/**\n * Any `HttpApi`, with its identifier and groups erased.\n */\nexport type Api = HttpApi.HttpApi<string, any>;\n\ntype EnvOf<D extends Definition> = D[\"__env\"];\n\ntype IsOptional<V> = V extends Validator<any, \"optional\", any> ? true : false;\n\ntype RequiredKeys<E extends EnvDefinition> = {\n [K in keyof E]: IsOptional<E[K]> extends true ? never : K;\n}[keyof E];\n\ntype SlotValue<V extends Validator<any, any, any>> = Extract<Infer<V>, string>;\n\n/**\n * What one component env slot accepts: a constant, or an entry whose Convex\n * value fits. A required slot takes only a required entry.\n */\ntype Slot<V extends Validator<any, any, any>> =\n IsOptional<V> extends true\n ? SlotValue<V> | undefined | Env.Entry<string, any, SlotValue<V>, boolean>\n : SlotValue<V> | Env.Entry<string, any, SlotValue<V>, false>;\n\nexport type Bindings<E extends EnvDefinition> = {\n readonly [K in RequiredKeys<E>]: Slot<E[K]>;\n} & {\n readonly [K in Exclude<keyof E, RequiredKeys<E>>]?: Slot<E[K]>;\n};\n\ntype HttpOptions =\n | { readonly httpPrefix?: never; readonly api?: never }\n | { readonly httpPrefix: HttpPrefix; readonly api?: Api };\n\nexport type Options<D extends Definition> = HttpOptions & {\n /**\n * The package specifier of the module whose `register(t, name)` the generated\n * test registry calls for this mount, in place of the component package's own\n * `<package>/test`. The kit registers the mount's children.\n */\n readonly testing?: string;\n} & ([RequiredKeys<EnvOf<D>>] extends [never]\n ? { readonly env?: Bindings<EnvOf<D>> }\n : { readonly env: Bindings<EnvOf<D>> });\n\ntype Exact<D extends Definition, O> = {\n readonly [\n K in Exclude<keyof O, \"env\" | \"httpPrefix\" | \"api\" | \"testing\">\n ]: never;\n} & (O extends { readonly env: infer B }\n ? {\n readonly env: { readonly [K in Exclude<keyof B, keyof EnvOf<D>>]: never };\n }\n : unknown);\n\nexport interface MountData {\n readonly definition: Definition;\n readonly httpPrefix: HttpPrefix | undefined;\n readonly api: Api | undefined;\n readonly env: Readonly<Record<string, string | Env.AnyEntry | undefined>>;\n readonly testing: string | undefined;\n}\n\n/**\n * A mounted Convex component. `O` keeps the options as written, so {@link make}\n * can see which backends the bound entries come from.\n */\nexport interface Mount<out D extends Definition, out O> extends MountData {\n readonly [MountTypeId]: { readonly definition: D; readonly options: O };\n readonly httpPrefix: O extends {\n readonly httpPrefix: infer P extends HttpPrefix;\n }\n ? P\n : undefined;\n}\n\nexport type AnyMount = Mount<Definition, unknown>;\n\n/**\n * Mount a Convex component: the default export of its `convex.config` module,\n * official or Confect-authored. `env` is typed against the component's own\n * `defineComponent({ env })` declaration, so a missing required binding, an\n * optional entry in a required slot, a wrong literal and an unknown slot fail\n * to typecheck. `api` is the component's `HttpApi`, for route checks.\n */\nexport function mount<const D extends Definition>(\n definition: D &\n ([RequiredKeys<EnvOf<D>>] extends [never]\n ? unknown\n : \"App.mount: this component declares required env; pass { env }\"),\n): Mount<D, {}>;\nexport function mount<const D extends Definition, const O extends Options<D>>(\n definition: D,\n options: O & Exact<NoInfer<D>, NoInfer<O>>,\n): Mount<D, O>;\nexport function mount(\n definition: Definition,\n options?: {\n readonly httpPrefix?: HttpPrefix;\n readonly api?: Api;\n readonly env?: MountData[\"env\"];\n readonly testing?: string;\n },\n): AnyMount {\n return {\n [MountTypeId]: { definition, options },\n definition,\n httpPrefix: options?.httpPrefix,\n api: options?.api,\n env: options?.env ?? {},\n testing: options?.testing,\n // The overloads above carry the precise types; this body serves both.\n } as AnyMount;\n}\n\ntype OwnerOf<V> = V extends Env.Entry<infer N, any, any, any> ? N : never;\n\ntype Owners<M> =\n M extends Mount<Definition, infer O>\n ? O extends { readonly env: infer B }\n ? { [K in keyof B]: OwnerOf<B[K]> }[keyof B]\n : never\n : never;\n\ntype OwnedBy<N extends string, M> = {\n readonly [K in keyof M]: [Exclude<Owners<M[K]>, N>] extends [never]\n ? unknown\n : { readonly foreignEnvBackend: Exclude<Owners<M[K]>, N> };\n};\n\nexport type Kind = \"app\" | \"component\";\n\nexport interface App<\n E extends Env.Any,\n M extends Readonly<Record<string, AnyMount>>,\n K extends Kind = Kind,\n> {\n readonly [TypeId]: typeof TypeId;\n readonly kind: K;\n readonly env: E;\n readonly mounts: M;\n}\n\nexport type Any = App<Env.Any, Readonly<Record<string, AnyMount>>>;\n\n/**\n * Declare a backend, in `confect/app.ts`: its env and its mounted Convex\n * components by name. Set `kind: \"component\"` when declaring a component; the\n * default is `\"app\"`. Codegen rejects a kind that differs from its target.\n * Codegen writes `convex/convex.config.ts` from it. A mount that binds another\n * backend's env entry fails to typecheck.\n *\n * ```ts\n * export default App.make({\n * env,\n * mounts: {\n * email: App.mount(email, {\n * httpPrefix: \"/email\",\n * env: { FROM: env.EMAIL_FROM, KEY: env.RESEND_API_KEY },\n * }),\n * importsPool: App.mount(workpool),\n * },\n * });\n * ```\n */\nexport const make = <\n const E extends Env.Any,\n const M extends Readonly<Record<string, AnyMount>> = {},\n const K extends Kind = \"app\",\n>(\n options: {\n readonly env: E;\n readonly mounts?: M & OwnedBy<NoInfer<Env.Name<E>>, NoInfer<M>>;\n } & ([K] extends [\"app\"] ? { readonly kind?: K } : { readonly kind: K }),\n): App<E, M, K> => ({\n [TypeId]: TypeId,\n kind: options.kind ?? (\"app\" as K),\n env: options.env,\n mounts: options.mounts ?? ({} as M),\n});\n\nexport const isApp = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId) &&\n u[TypeId] === TypeId &&\n Predicate.hasProperty(u, \"kind\") &&\n (u.kind === \"app\" || u.kind === \"component\");\n\nexport const isMount = (u: unknown): u is AnyMount =>\n Predicate.hasProperty(u, MountTypeId);\n\nexport const env = <A extends Any>(app: A): A[\"env\"] => app.env;\n\n/**\n * Every mount with its name, in declaration order.\n */\nexport const mounts = (\n app: Any,\n): ReadonlyArray<MountData & { readonly name: string }> =>\n Object.entries(app.mounts).map(([name, installed]) => ({\n name,\n definition: installed.definition,\n httpPrefix: installed.httpPrefix,\n api: installed.api,\n env: installed.env,\n testing: installed.testing,\n }));\n"],"mappings":";;;;;;;;;;;AAMA,MAAM,SAAS;AACf,MAAM,cAAc;AAwGpB,SAAgB,MACd,YACA,SAMU;CACV,OAAO;GACJ,cAAc;GAAE;GAAY;EAAQ;EACrC;EACA,YAAY,SAAS;EACrB,KAAK,SAAS;EACd,KAAK,SAAS,OAAO,CAAC;EACtB,SAAS,SAAS;CAEpB;AACF;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAa,QAKX,aAIkB;EACjB,SAAS;CACV,MAAM,QAAQ,QAAS;CACvB,KAAK,QAAQ;CACb,QAAQ,QAAQ,UAAW,CAAC;AAC9B;AAEA,MAAa,SAAS,MACpB,UAAU,YAAY,GAAG,MAAM,KAC/B,EAAE,YAAY,UACd,UAAU,YAAY,GAAG,MAAM,MAC9B,EAAE,SAAS,SAAS,EAAE,SAAS;AAElC,MAAa,WAAW,MACtB,UAAU,YAAY,GAAG,WAAW;AAEtC,MAAa,OAAsB,QAAqB,IAAI;;;;AAK5D,MAAa,UACX,QAEA,OAAO,QAAQ,IAAI,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,gBAAgB;CACrD;CACA,YAAY,UAAU;CACtB,YAAY,UAAU;CACtB,KAAK,UAAU;CACf,KAAK,UAAU;CACf,SAAS,UAAU;AACrB,EAAE"}
|
package/package.json
CHANGED
package/src/App.ts
CHANGED
|
@@ -48,13 +48,21 @@ type HttpOptions =
|
|
|
48
48
|
| { readonly httpPrefix?: never; readonly api?: never }
|
|
49
49
|
| { readonly httpPrefix: HttpPrefix; readonly api?: Api };
|
|
50
50
|
|
|
51
|
-
export type Options<D extends Definition> = HttpOptions &
|
|
52
|
-
|
|
51
|
+
export type Options<D extends Definition> = HttpOptions & {
|
|
52
|
+
/**
|
|
53
|
+
* The package specifier of the module whose `register(t, name)` the generated
|
|
54
|
+
* test registry calls for this mount, in place of the component package's own
|
|
55
|
+
* `<package>/test`. The kit registers the mount's children.
|
|
56
|
+
*/
|
|
57
|
+
readonly testing?: string;
|
|
58
|
+
} & ([RequiredKeys<EnvOf<D>>] extends [never]
|
|
53
59
|
? { readonly env?: Bindings<EnvOf<D>> }
|
|
54
60
|
: { readonly env: Bindings<EnvOf<D>> });
|
|
55
61
|
|
|
56
62
|
type Exact<D extends Definition, O> = {
|
|
57
|
-
readonly [
|
|
63
|
+
readonly [
|
|
64
|
+
K in Exclude<keyof O, "env" | "httpPrefix" | "api" | "testing">
|
|
65
|
+
]: never;
|
|
58
66
|
} & (O extends { readonly env: infer B }
|
|
59
67
|
? {
|
|
60
68
|
readonly env: { readonly [K in Exclude<keyof B, keyof EnvOf<D>>]: never };
|
|
@@ -66,6 +74,7 @@ export interface MountData {
|
|
|
66
74
|
readonly httpPrefix: HttpPrefix | undefined;
|
|
67
75
|
readonly api: Api | undefined;
|
|
68
76
|
readonly env: Readonly<Record<string, string | Env.AnyEntry | undefined>>;
|
|
77
|
+
readonly testing: string | undefined;
|
|
69
78
|
}
|
|
70
79
|
|
|
71
80
|
/**
|
|
@@ -106,6 +115,7 @@ export function mount(
|
|
|
106
115
|
readonly httpPrefix?: HttpPrefix;
|
|
107
116
|
readonly api?: Api;
|
|
108
117
|
readonly env?: MountData["env"];
|
|
118
|
+
readonly testing?: string;
|
|
109
119
|
},
|
|
110
120
|
): AnyMount {
|
|
111
121
|
return {
|
|
@@ -114,6 +124,7 @@ export function mount(
|
|
|
114
124
|
httpPrefix: options?.httpPrefix,
|
|
115
125
|
api: options?.api,
|
|
116
126
|
env: options?.env ?? {},
|
|
127
|
+
testing: options?.testing,
|
|
117
128
|
// The overloads above carry the precise types; this body serves both.
|
|
118
129
|
} as AnyMount;
|
|
119
130
|
}
|
|
@@ -207,4 +218,5 @@ export const mounts = (
|
|
|
207
218
|
httpPrefix: installed.httpPrefix,
|
|
208
219
|
api: installed.api,
|
|
209
220
|
env: installed.env,
|
|
221
|
+
testing: installed.testing,
|
|
210
222
|
}));
|