@gaganref/confect-core 10.3.1-fork.7 → 10.3.1-fork.70
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 +66 -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 +74 -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
package/src/Auth.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { AuthProvider } from "convex/server";
|
|
2
2
|
import * as Predicate from "effect/Predicate";
|
|
3
3
|
import type * as App from "./App.js";
|
|
4
|
+
import type * as Env from "./Env.js";
|
|
4
5
|
import type { TypeError } from "./Types.js";
|
|
5
6
|
|
|
6
7
|
const TypeId = "~@confect/core/Auth";
|
|
8
|
+
const CloudUrlTypeId = "~@confect/core/Auth/CloudUrl";
|
|
7
9
|
const SiteUrlTypeId = "~@confect/core/Auth/SiteUrl";
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -15,19 +17,59 @@ export interface SiteUrl {
|
|
|
15
17
|
readonly path: string;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
/**
|
|
21
|
+
* The deployment's cloud URL (`CONVEX_CLOUD_URL`) plus a path.
|
|
22
|
+
*/
|
|
23
|
+
export interface CloudUrl {
|
|
24
|
+
readonly [CloudUrlTypeId]: typeof CloudUrlTypeId;
|
|
25
|
+
readonly path: string;
|
|
26
|
+
}
|
|
19
27
|
|
|
20
|
-
type
|
|
28
|
+
type Url =
|
|
29
|
+
| string
|
|
30
|
+
| SiteUrl
|
|
31
|
+
| CloudUrl
|
|
32
|
+
| Env.Entry<string, string, string, false>;
|
|
33
|
+
|
|
34
|
+
type WithUrls<P> = P extends unknown
|
|
21
35
|
? {
|
|
22
|
-
[K in keyof P]: K extends "domain" | "issuer" | "jwks"
|
|
36
|
+
[K in keyof P]: K extends "domain" | "issuer" | "jwks" | "applicationID"
|
|
37
|
+
? Url
|
|
38
|
+
: P[K];
|
|
23
39
|
}
|
|
24
40
|
: never;
|
|
25
41
|
|
|
26
42
|
/**
|
|
27
|
-
* Convex's
|
|
28
|
-
|
|
43
|
+
* Convex's provider list with deployment URLs and required, public env strings.
|
|
44
|
+
*/
|
|
45
|
+
export type Provider = WithUrls<AuthProvider> & {
|
|
46
|
+
/**
|
|
47
|
+
* Application-defined token family, copied to the runtime provider data.
|
|
48
|
+
*/
|
|
49
|
+
readonly family?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Application-defined issuer name, for example a trusted service.
|
|
52
|
+
*/
|
|
53
|
+
readonly name?: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The cloud URL, or a path under it, resolved when Convex loads auth config.
|
|
29
58
|
*/
|
|
30
|
-
export
|
|
59
|
+
export const cloudUrl = (path: `/${string}` | "" = ""): CloudUrl => ({
|
|
60
|
+
[CloudUrlTypeId]: CloudUrlTypeId,
|
|
61
|
+
path,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The path of a cloud URL placeholder, or `undefined` for another value.
|
|
66
|
+
*/
|
|
67
|
+
export const cloudUrlPath = (u: unknown): string | undefined =>
|
|
68
|
+
Predicate.hasProperty(u, CloudUrlTypeId) &&
|
|
69
|
+
Predicate.hasProperty(u, "path") &&
|
|
70
|
+
typeof u.path === "string"
|
|
71
|
+
? u.path
|
|
72
|
+
: undefined;
|
|
31
73
|
|
|
32
74
|
export interface Auth<A extends App.Any> {
|
|
33
75
|
readonly [TypeId]: typeof TypeId;
|
package/src/Callback.ts
CHANGED
|
@@ -8,6 +8,8 @@ import * as Schema from "effect/Schema";
|
|
|
8
8
|
import * as SchemaGetter from "effect/SchemaGetter";
|
|
9
9
|
import * as FunctionProvenance from "./FunctionProvenance.js";
|
|
10
10
|
import * as Ref from "./Ref.js";
|
|
11
|
+
import { getFunctionReference } from "./RefInternal.js";
|
|
12
|
+
import { CallbackContract } from "./internal/annotations.js";
|
|
11
13
|
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
12
14
|
|
|
13
15
|
export const TypeId = "~@confect/core/Callback";
|
|
@@ -137,6 +139,7 @@ const isHandleOf =
|
|
|
137
139
|
const fromText = <Contract_ extends Any>(
|
|
138
140
|
contract: Contract_,
|
|
139
141
|
text: string,
|
|
142
|
+
reservedArgument?: string,
|
|
140
143
|
): Handle<Contract_> =>
|
|
141
144
|
Object.assign(
|
|
142
145
|
Ref.fromProvenance(
|
|
@@ -145,25 +148,35 @@ const fromText = <Contract_ extends Any>(
|
|
|
145
148
|
[],
|
|
146
149
|
// Convex types a handle as a string that is also a function reference.
|
|
147
150
|
text as unknown as FunctionReference<any, any>,
|
|
151
|
+
contract.functionType,
|
|
152
|
+
contract.functionType === "query" ? undefined : reservedArgument,
|
|
148
153
|
),
|
|
149
154
|
{ [HandleTypeId]: contract.id },
|
|
150
155
|
) as unknown as Handle<Contract_>;
|
|
151
156
|
|
|
152
157
|
/**
|
|
153
158
|
* The schema of a handle for `contract`: a string on the wire, a runnable ref
|
|
154
|
-
* once decoded. Use it in a component's function args or tables.
|
|
159
|
+
* once decoded. Use it in a component's function args or tables. It lowers to
|
|
160
|
+
* Convex's `v.function` with the contract's encoded args and returns.
|
|
161
|
+
* `reservedArgument` opts mutation and action handles into context forwarding.
|
|
162
|
+
* The host target must reserve the same argument name.
|
|
155
163
|
*/
|
|
156
164
|
export const handle = <Contract_ extends Any>(
|
|
157
165
|
contract: Contract_,
|
|
166
|
+
options?: {
|
|
167
|
+
readonly reservedArgument?: Contract_["functionType"] extends "query"
|
|
168
|
+
? never
|
|
169
|
+
: string;
|
|
170
|
+
},
|
|
158
171
|
): Schema.Codec<Handle<Contract_>, string> =>
|
|
159
|
-
Schema.String.pipe(
|
|
172
|
+
Schema.String.annotate({ [CallbackContract]: contract }).pipe(
|
|
160
173
|
Schema.decodeTo(
|
|
161
174
|
Schema.declare(isHandleOf(contract), {
|
|
162
175
|
identifier: `Callback.Handle<${contract.id}>`,
|
|
163
176
|
}),
|
|
164
177
|
{
|
|
165
178
|
decode: SchemaGetter.transform((text: string) =>
|
|
166
|
-
fromText(contract, text),
|
|
179
|
+
fromText(contract, text, options?.reservedArgument),
|
|
167
180
|
),
|
|
168
181
|
encode: SchemaGetter.transform(
|
|
169
182
|
(ref: Handle<Contract_>) => ref.convexFunctionName,
|
|
@@ -301,4 +314,4 @@ export const toFuture = <Ref_ extends Ref.Any>(
|
|
|
301
314
|
Ref.GetFunctionVisibility<Ref_>,
|
|
302
315
|
EncodedArgs<Ref_>,
|
|
303
316
|
EncodedReturns<Ref_>
|
|
304
|
-
> =>
|
|
317
|
+
> => getFunctionReference(ref) as never;
|
package/src/Component.ts
CHANGED
|
@@ -215,7 +215,7 @@ export type Bound<
|
|
|
215
215
|
/**
|
|
216
216
|
* Build a publishable contract containing only exported functions and codecs.
|
|
217
217
|
*/
|
|
218
|
-
export const
|
|
218
|
+
export const contract = <
|
|
219
219
|
Spec_ extends Spec.AnyWithProps,
|
|
220
220
|
const Scope extends IdScope.IdScope,
|
|
221
221
|
const Tables extends string,
|
|
@@ -275,14 +275,14 @@ export const bind = <
|
|
|
275
275
|
MountScope<Parent, Extract<MountName<Native>, string | undefined>>,
|
|
276
276
|
Tables
|
|
277
277
|
> => {
|
|
278
|
-
const
|
|
278
|
+
const published = component[TypeId];
|
|
279
279
|
const address = getFunctionAddress(native);
|
|
280
280
|
const installedReference = Result.getOrThrow(
|
|
281
281
|
Result.fromNullishOr(
|
|
282
282
|
address.reference,
|
|
283
283
|
() =>
|
|
284
284
|
new UninstalledComponentReferenceError({
|
|
285
|
-
definitionScope:
|
|
285
|
+
definitionScope: published.scope,
|
|
286
286
|
}),
|
|
287
287
|
),
|
|
288
288
|
);
|
|
@@ -293,7 +293,7 @@ export const bind = <
|
|
|
293
293
|
installedReference,
|
|
294
294
|
);
|
|
295
295
|
const rebase = (schema: Schema.ConstraintCodec<any, any, never, never>) =>
|
|
296
|
-
GenericId.rebase(schema,
|
|
296
|
+
GenericId.rebase(schema, published.scope, scope);
|
|
297
297
|
const rebaseMiddleware = memoize(
|
|
298
298
|
(middleware: MiddlewareSpec.AnyMiddlewareSpec) => {
|
|
299
299
|
if (!("error" in middleware)) return middleware;
|
|
@@ -358,6 +358,8 @@ export const bind = <
|
|
|
358
358
|
spec: rebaseMiddleware(attachment.spec),
|
|
359
359
|
})),
|
|
360
360
|
nativeRef,
|
|
361
|
+
ref.functionType,
|
|
362
|
+
ref.reservedArgument,
|
|
361
363
|
);
|
|
362
364
|
}),
|
|
363
365
|
Match.exhaustive,
|
|
@@ -366,9 +368,9 @@ export const bind = <
|
|
|
366
368
|
return visit(child, reference);
|
|
367
369
|
}
|
|
368
370
|
});
|
|
369
|
-
const refs = visit(
|
|
371
|
+
const refs = visit(published.refs, native);
|
|
370
372
|
Object.defineProperty(refs, BoundTypeId, {
|
|
371
|
-
value: { from:
|
|
373
|
+
value: { from: published.scope, scope, tables: published.tables },
|
|
372
374
|
});
|
|
373
375
|
return refs as Bound<
|
|
374
376
|
Spec_,
|