@gaganref/confect-core 10.3.1-fork.2 → 10.3.1-fork.21
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 +14 -3
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +6 -3
- package/dist/App.js.map +1 -1
- package/dist/Auth.d.ts +2 -2
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js.map +1 -1
- package/dist/Callback.d.ts +3 -3
- package/dist/Callback.d.ts.map +1 -1
- package/dist/Callback.js.map +1 -1
- package/dist/Component.d.ts +8 -8
- package/dist/Component.d.ts.map +1 -1
- package/dist/Component.js.map +1 -1
- package/dist/FunctionProvenance.d.ts +2 -2
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/FunctionProvenance.js.map +1 -1
- package/dist/FunctionSpec.d.ts +320 -4
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +35 -3
- package/dist/FunctionSpec.js.map +1 -1
- package/dist/GenericId.d.ts +2 -2
- package/dist/GenericId.d.ts.map +1 -1
- package/dist/GenericId.js.map +1 -1
- package/dist/GroupPath.d.ts +1 -1
- package/dist/GroupPath.d.ts.map +1 -1
- package/dist/GroupPath.js.map +1 -1
- package/dist/GroupSpec.d.ts +4 -4
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Http.d.ts +1 -1
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js.map +1 -1
- package/dist/Manifest.d.ts +1 -1
- package/dist/Manifest.d.ts.map +1 -1
- package/dist/Manifest.js.map +1 -1
- package/dist/MiddlewareAttachment.d.ts +1 -1
- package/dist/MiddlewareAttachment.d.ts.map +1 -1
- package/dist/MiddlewareAttachment.js.map +1 -1
- package/dist/MiddlewareSpec.d.ts +3 -3
- package/dist/MiddlewareSpec.d.ts.map +1 -1
- package/dist/MiddlewareSpec.js.map +1 -1
- package/dist/Profile.d.ts +52 -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 +5 -5
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js.map +1 -1
- package/dist/Refs.d.ts +5 -5
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +2 -2
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/Spec.d.ts +1 -1
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js.map +1 -1
- package/dist/SystemFields.d.ts +2 -2
- package/dist/SystemFields.d.ts.map +1 -1
- package/dist/SystemFields.js.map +1 -1
- package/dist/Table.d.ts +3 -3
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js.map +1 -1
- package/dist/index.d.ts +30 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/package.json +1 -1
- package/src/App.ts +20 -4
- package/src/Auth.ts +2 -2
- package/src/Callback.ts +3 -3
- package/src/Component.ts +11 -11
- package/src/FunctionProvenance.ts +3 -3
- package/src/FunctionSpec.ts +414 -8
- package/src/GenericId.ts +2 -2
- package/src/GroupPath.ts +1 -1
- package/src/GroupSpec.ts +5 -5
- package/src/Http.ts +1 -1
- package/src/Manifest.ts +1 -1
- package/src/MiddlewareAttachment.ts +1 -1
- package/src/MiddlewareSpec.ts +4 -4
- package/src/Profile.ts +80 -0
- package/src/Ref.ts +6 -6
- package/src/Refs.ts +5 -5
- package/src/SchemaToValidator.ts +3 -3
- package/src/Spec.ts +1 -1
- package/src/SystemFields.ts +2 -2
- package/src/Table.ts +4 -4
- package/src/index.ts +30 -29
package/src/Auth.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AuthProvider } from "convex/server";
|
|
2
2
|
import * as Predicate from "effect/Predicate";
|
|
3
|
-
import type * as App from "./App";
|
|
4
|
-
import type { TypeError } from "./Types";
|
|
3
|
+
import type * as App from "./App.js";
|
|
4
|
+
import type { TypeError } from "./Types.js";
|
|
5
5
|
|
|
6
6
|
const TypeId = "~@confect/core/Auth";
|
|
7
7
|
const SiteUrlTypeId = "~@confect/core/Auth/SiteUrl";
|
package/src/Callback.ts
CHANGED
|
@@ -6,9 +6,9 @@ import type {
|
|
|
6
6
|
import * as Predicate from "effect/Predicate";
|
|
7
7
|
import * as Schema from "effect/Schema";
|
|
8
8
|
import * as SchemaGetter from "effect/SchemaGetter";
|
|
9
|
-
import * as FunctionProvenance from "./FunctionProvenance";
|
|
10
|
-
import * as Ref from "./Ref";
|
|
11
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
9
|
+
import * as FunctionProvenance from "./FunctionProvenance.js";
|
|
10
|
+
import * as Ref from "./Ref.js";
|
|
11
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
12
12
|
|
|
13
13
|
export const TypeId = "~@confect/core/Callback";
|
|
14
14
|
export type TypeId = typeof TypeId;
|
package/src/Component.ts
CHANGED
|
@@ -7,17 +7,17 @@ import { memoize, pipe } from "effect/Function";
|
|
|
7
7
|
import * as Match from "effect/Match";
|
|
8
8
|
import * as Record from "effect/Record";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
|
-
import type * as FunctionProvenance from "./FunctionProvenance";
|
|
11
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
12
|
-
import * as GenericId from "./GenericId";
|
|
13
|
-
import type * as GroupSpec from "./GroupSpec";
|
|
14
|
-
import * as IdScope from "./IdScope";
|
|
15
|
-
import * as Lazy from "./Lazy";
|
|
16
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
17
|
-
import * as Ref from "./Ref";
|
|
18
|
-
import type * as Refs from "./Refs";
|
|
19
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
20
|
-
import * as Spec from "./Spec";
|
|
10
|
+
import type * as FunctionProvenance from "./FunctionProvenance.js";
|
|
11
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
12
|
+
import * as GenericId from "./GenericId.js";
|
|
13
|
+
import type * as GroupSpec from "./GroupSpec.js";
|
|
14
|
+
import * as IdScope from "./IdScope.js";
|
|
15
|
+
import * as Lazy from "./Lazy.js";
|
|
16
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
17
|
+
import * as Ref from "./Ref.js";
|
|
18
|
+
import type * as Refs from "./Refs.js";
|
|
19
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
20
|
+
import * as Spec from "./Spec.js";
|
|
21
21
|
|
|
22
22
|
export class EmptyComponentScopeError extends Data.TaggedError(
|
|
23
23
|
"EmptyComponentScopeError",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DefaultFunctionArgs } from "convex/server";
|
|
2
2
|
import * as Data from "effect/Data";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
|
-
import * as Lazy from "./Lazy";
|
|
5
|
-
import * as PaginationOptions from "./PaginationOptions";
|
|
6
|
-
import * as PaginationResult from "./PaginationResult";
|
|
4
|
+
import * as Lazy from "./Lazy.js";
|
|
5
|
+
import * as PaginationOptions from "./PaginationOptions.js";
|
|
6
|
+
import * as PaginationResult from "./PaginationResult.js";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A field map accepted as Confect function args. Restricting each field to a
|
package/src/FunctionSpec.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as MiddlewareAttachment from "./MiddlewareAttachment";
|
|
1
|
+
import type * as MiddlewareAttachment from "./MiddlewareAttachment.js";
|
|
2
2
|
import type {
|
|
3
3
|
DefaultFunctionArgs,
|
|
4
4
|
FunctionType,
|
|
@@ -9,10 +9,11 @@ import type {
|
|
|
9
9
|
} from "convex/server";
|
|
10
10
|
import type * as Schema from "effect/Schema";
|
|
11
11
|
import * as Predicate from "effect/Predicate";
|
|
12
|
-
import * as FunctionProvenance from "./FunctionProvenance";
|
|
13
|
-
import { validateConfectFunctionIdentifier } from "./Identifier";
|
|
14
|
-
import
|
|
15
|
-
import * as
|
|
12
|
+
import * as FunctionProvenance from "./FunctionProvenance.js";
|
|
13
|
+
import { validateConfectFunctionIdentifier } from "./Identifier.js";
|
|
14
|
+
import * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
15
|
+
import type * as Profile from "./Profile.js";
|
|
16
|
+
import * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
16
17
|
|
|
17
18
|
export const TypeId = "~@confect/core/FunctionSpec";
|
|
18
19
|
export type TypeId = typeof TypeId;
|
|
@@ -69,6 +70,78 @@ export interface Builder<
|
|
|
69
70
|
>;
|
|
70
71
|
}
|
|
71
72
|
|
|
73
|
+
export interface DescribedBuilder<
|
|
74
|
+
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
75
|
+
FunctionVisibility_ extends FunctionVisibility,
|
|
76
|
+
Name_ extends string,
|
|
77
|
+
FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,
|
|
78
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec = never,
|
|
79
|
+
> extends Builder<
|
|
80
|
+
RuntimeAndFunctionType_,
|
|
81
|
+
FunctionVisibility_,
|
|
82
|
+
Name_,
|
|
83
|
+
FunctionProvenance_,
|
|
84
|
+
MiddlewareSpecs_
|
|
85
|
+
> {
|
|
86
|
+
readonly description?: string;
|
|
87
|
+
|
|
88
|
+
middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(
|
|
89
|
+
middlewareSpec: MiddlewareSpec_ &
|
|
90
|
+
MiddlewareSpec.ValidateFunctionAttach<
|
|
91
|
+
MiddlewareSpec_,
|
|
92
|
+
RuntimeAndFunctionType_,
|
|
93
|
+
FunctionProvenance_,
|
|
94
|
+
MiddlewareSpecs_
|
|
95
|
+
>,
|
|
96
|
+
...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>
|
|
97
|
+
): DescribedBuilder<
|
|
98
|
+
RuntimeAndFunctionType_,
|
|
99
|
+
FunctionVisibility_,
|
|
100
|
+
Name_,
|
|
101
|
+
FunctionProvenance_,
|
|
102
|
+
MiddlewareSpecs_ | MiddlewareSpec_
|
|
103
|
+
>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* A spec built through {@link extend}, keeping its fields through middleware.
|
|
108
|
+
*/
|
|
109
|
+
export interface ExtendedBuilder<
|
|
110
|
+
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
111
|
+
FunctionVisibility_ extends FunctionVisibility,
|
|
112
|
+
Name_ extends string,
|
|
113
|
+
FunctionProvenance_ extends FunctionProvenance.FunctionProvenance,
|
|
114
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
115
|
+
Fields_,
|
|
116
|
+
> extends Builder<
|
|
117
|
+
RuntimeAndFunctionType_,
|
|
118
|
+
FunctionVisibility_,
|
|
119
|
+
Name_,
|
|
120
|
+
FunctionProvenance_,
|
|
121
|
+
MiddlewareSpecs_
|
|
122
|
+
> {
|
|
123
|
+
readonly description?: string;
|
|
124
|
+
readonly fields: Fields_;
|
|
125
|
+
|
|
126
|
+
middleware<MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec>(
|
|
127
|
+
middlewareSpec: MiddlewareSpec_ &
|
|
128
|
+
MiddlewareSpec.ValidateFunctionAttach<
|
|
129
|
+
MiddlewareSpec_,
|
|
130
|
+
RuntimeAndFunctionType_,
|
|
131
|
+
FunctionProvenance_,
|
|
132
|
+
MiddlewareSpecs_
|
|
133
|
+
>,
|
|
134
|
+
...options: MiddlewareAttachment.Args<NoInfer<MiddlewareSpec_>>
|
|
135
|
+
): ExtendedBuilder<
|
|
136
|
+
RuntimeAndFunctionType_,
|
|
137
|
+
FunctionVisibility_,
|
|
138
|
+
Name_,
|
|
139
|
+
FunctionProvenance_,
|
|
140
|
+
MiddlewareSpecs_ | MiddlewareSpec_,
|
|
141
|
+
Fields_
|
|
142
|
+
>;
|
|
143
|
+
}
|
|
144
|
+
|
|
72
145
|
export interface Any {
|
|
73
146
|
readonly [TypeId]: TypeId;
|
|
74
147
|
}
|
|
@@ -79,7 +152,10 @@ export interface AnyWithProps extends FunctionSpec<
|
|
|
79
152
|
string,
|
|
80
153
|
FunctionProvenance.FunctionProvenance,
|
|
81
154
|
MiddlewareSpec.AnyMiddlewareSpec
|
|
82
|
-
> {
|
|
155
|
+
> {
|
|
156
|
+
readonly description?: string;
|
|
157
|
+
readonly fields?: object;
|
|
158
|
+
}
|
|
83
159
|
|
|
84
160
|
export interface AnyConfect extends FunctionSpec<
|
|
85
161
|
RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
@@ -326,6 +402,8 @@ const Proto = {
|
|
|
326
402
|
runtimeAndFunctionType: this.runtimeAndFunctionType,
|
|
327
403
|
functionVisibility: this.functionVisibility,
|
|
328
404
|
name: this.name,
|
|
405
|
+
...("description" in this ? { description: this.description } : {}),
|
|
406
|
+
...("fields" in this ? { fields: this.fields } : {}),
|
|
329
407
|
functionProvenance: this.functionProvenance,
|
|
330
408
|
middlewareAttachments: [
|
|
331
409
|
...this.middlewareAttachments,
|
|
@@ -336,6 +414,7 @@ const Proto = {
|
|
|
336
414
|
} satisfies ThisType<AnyWithProps>;
|
|
337
415
|
|
|
338
416
|
interface Options {
|
|
417
|
+
readonly description?: string;
|
|
339
418
|
readonly name: string;
|
|
340
419
|
readonly args?: () => FunctionProvenance.ArgsFields;
|
|
341
420
|
readonly returns: () => Schema.Codec<any, any>;
|
|
@@ -356,6 +435,7 @@ const make = <
|
|
|
356
435
|
Error_ extends Schema.Codec<any, any> = never,
|
|
357
436
|
>(options: {
|
|
358
437
|
name: Name_;
|
|
438
|
+
description?: never;
|
|
359
439
|
args: () => ArgsFields_;
|
|
360
440
|
returns: () => Returns_;
|
|
361
441
|
error?: () => Error_;
|
|
@@ -371,6 +451,7 @@ const make = <
|
|
|
371
451
|
Error_ extends Schema.Codec<any, any> = never,
|
|
372
452
|
>(options: {
|
|
373
453
|
name: Name_;
|
|
454
|
+
description?: never;
|
|
374
455
|
args?: never;
|
|
375
456
|
returns: () => Returns_;
|
|
376
457
|
error?: () => Error_;
|
|
@@ -380,13 +461,47 @@ const make = <
|
|
|
380
461
|
Name_,
|
|
381
462
|
FunctionProvenance.Confect<{}, Returns_, Error_>
|
|
382
463
|
>;
|
|
383
|
-
function makeSpec
|
|
464
|
+
function makeSpec<
|
|
465
|
+
const Name_ extends string,
|
|
466
|
+
const ArgsFields_ extends FunctionProvenance.ArgsFields,
|
|
467
|
+
Returns_ extends Schema.Codec<any, any>,
|
|
468
|
+
Error_ extends Schema.Codec<any, any> = never,
|
|
469
|
+
>(options: {
|
|
470
|
+
name: Name_;
|
|
471
|
+
description?: FunctionVisibility_ extends "public" ? string : never;
|
|
472
|
+
args: () => ArgsFields_;
|
|
473
|
+
returns: () => Returns_;
|
|
474
|
+
error?: () => Error_;
|
|
475
|
+
}): DescribedBuilder<
|
|
476
|
+
RuntimeAndFunctionType_,
|
|
477
|
+
FunctionVisibility_,
|
|
478
|
+
Name_,
|
|
479
|
+
FunctionProvenance.Confect<ArgsFields_, Returns_, Error_>
|
|
480
|
+
>;
|
|
481
|
+
function makeSpec<
|
|
482
|
+
const Name_ extends string,
|
|
483
|
+
Returns_ extends Schema.Codec<any, any>,
|
|
484
|
+
Error_ extends Schema.Codec<any, any> = never,
|
|
485
|
+
>(options: {
|
|
486
|
+
name: Name_;
|
|
487
|
+
description?: FunctionVisibility_ extends "public" ? string : never;
|
|
488
|
+
args?: never;
|
|
489
|
+
returns: () => Returns_;
|
|
490
|
+
error?: () => Error_;
|
|
491
|
+
}): DescribedBuilder<
|
|
492
|
+
RuntimeAndFunctionType_,
|
|
493
|
+
FunctionVisibility_,
|
|
494
|
+
Name_,
|
|
495
|
+
FunctionProvenance.Confect<{}, Returns_, Error_>
|
|
496
|
+
>;
|
|
497
|
+
function makeSpec({ name, description, args, returns, error }: Options) {
|
|
384
498
|
validateConfectFunctionIdentifier(name);
|
|
385
499
|
|
|
386
500
|
return Object.assign(Object.create(Proto), {
|
|
387
501
|
runtimeAndFunctionType,
|
|
388
502
|
functionVisibility,
|
|
389
503
|
name,
|
|
504
|
+
...(description === undefined ? {} : { description }),
|
|
390
505
|
functionProvenance:
|
|
391
506
|
args === undefined
|
|
392
507
|
? FunctionProvenance.Confect(() => ({}), returns, error)
|
|
@@ -411,6 +526,7 @@ type ForbidPaginationOpts<
|
|
|
411
526
|
: unknown;
|
|
412
527
|
|
|
413
528
|
interface PaginatedOptions {
|
|
529
|
+
readonly description?: string;
|
|
414
530
|
readonly name: string;
|
|
415
531
|
readonly args?: () => FunctionProvenance.ArgsFields;
|
|
416
532
|
readonly item: () => Schema.Codec<any, any>;
|
|
@@ -431,6 +547,7 @@ const makePaginated = <
|
|
|
431
547
|
Error_ extends Schema.Codec<any, any> = never,
|
|
432
548
|
>(options: {
|
|
433
549
|
name: Name_;
|
|
550
|
+
description?: never;
|
|
434
551
|
args: () => UserArgsFields_ & ForbidPaginationOpts<UserArgsFields_>;
|
|
435
552
|
item: () => Item_;
|
|
436
553
|
error?: () => Error_;
|
|
@@ -446,6 +563,7 @@ const makePaginated = <
|
|
|
446
563
|
Error_ extends Schema.Codec<any, any> = never,
|
|
447
564
|
>(options: {
|
|
448
565
|
name: Name_;
|
|
566
|
+
description?: never;
|
|
449
567
|
args?: never;
|
|
450
568
|
item: () => Item_;
|
|
451
569
|
error?: () => Error_;
|
|
@@ -455,13 +573,53 @@ const makePaginated = <
|
|
|
455
573
|
Name_,
|
|
456
574
|
FunctionProvenance.ConfectPaginated<{}, Item_, Error_>
|
|
457
575
|
>;
|
|
458
|
-
function makeSpec
|
|
576
|
+
function makeSpec<
|
|
577
|
+
const Name_ extends string,
|
|
578
|
+
const UserArgsFields_ extends FunctionProvenance.ArgsFields,
|
|
579
|
+
Item_ extends Schema.Codec<any, any>,
|
|
580
|
+
Error_ extends Schema.Codec<any, any> = never,
|
|
581
|
+
>(options: {
|
|
582
|
+
name: Name_;
|
|
583
|
+
description?: FunctionVisibility_ extends "public" ? string : never;
|
|
584
|
+
args: () => UserArgsFields_ & ForbidPaginationOpts<UserArgsFields_>;
|
|
585
|
+
item: () => Item_;
|
|
586
|
+
error?: () => Error_;
|
|
587
|
+
}): DescribedBuilder<
|
|
588
|
+
RuntimeAndFunctionType_,
|
|
589
|
+
FunctionVisibility_,
|
|
590
|
+
Name_,
|
|
591
|
+
FunctionProvenance.ConfectPaginated<UserArgsFields_, Item_, Error_>
|
|
592
|
+
>;
|
|
593
|
+
function makeSpec<
|
|
594
|
+
const Name_ extends string,
|
|
595
|
+
Item_ extends Schema.Codec<any, any>,
|
|
596
|
+
Error_ extends Schema.Codec<any, any> = never,
|
|
597
|
+
>(options: {
|
|
598
|
+
name: Name_;
|
|
599
|
+
description?: FunctionVisibility_ extends "public" ? string : never;
|
|
600
|
+
args?: never;
|
|
601
|
+
item: () => Item_;
|
|
602
|
+
error?: () => Error_;
|
|
603
|
+
}): DescribedBuilder<
|
|
604
|
+
RuntimeAndFunctionType_,
|
|
605
|
+
FunctionVisibility_,
|
|
606
|
+
Name_,
|
|
607
|
+
FunctionProvenance.ConfectPaginated<{}, Item_, Error_>
|
|
608
|
+
>;
|
|
609
|
+
function makeSpec({
|
|
610
|
+
name,
|
|
611
|
+
description,
|
|
612
|
+
args,
|
|
613
|
+
item,
|
|
614
|
+
error,
|
|
615
|
+
}: PaginatedOptions) {
|
|
459
616
|
validateConfectFunctionIdentifier(name);
|
|
460
617
|
|
|
461
618
|
return Object.assign(Object.create(Proto), {
|
|
462
619
|
runtimeAndFunctionType,
|
|
463
620
|
functionVisibility,
|
|
464
621
|
name,
|
|
622
|
+
...(description === undefined ? {} : { description }),
|
|
465
623
|
functionProvenance:
|
|
466
624
|
args === undefined
|
|
467
625
|
? FunctionProvenance.ConfectPaginated(() => ({}), item, error)
|
|
@@ -509,6 +667,254 @@ export const internalNodeAction = make(
|
|
|
509
667
|
"internal",
|
|
510
668
|
);
|
|
511
669
|
|
|
670
|
+
type OptionlessMiddlewareSpec = MiddlewareSpec.AnyMiddlewareSpec & {
|
|
671
|
+
readonly "~Options": never;
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
type BuilderOption =
|
|
675
|
+
| "name"
|
|
676
|
+
| "description"
|
|
677
|
+
| "args"
|
|
678
|
+
| "returns"
|
|
679
|
+
| "item"
|
|
680
|
+
| "error";
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Refuses fields named after a builder option, which the builder would read as
|
|
684
|
+
* that option. The conditional keeps the mapped type out of a builder call's
|
|
685
|
+
* inference, which would otherwise widen the function's name to `string` when
|
|
686
|
+
* reporting the error.
|
|
687
|
+
*/
|
|
688
|
+
type OptionFree<Type> = [keyof Type & BuilderOption] extends [never]
|
|
689
|
+
? unknown
|
|
690
|
+
: { readonly [Option in keyof Type & BuilderOption]: never };
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* A function's fields, checked once applied, since a profile's field type can
|
|
694
|
+
* branch on the function's name.
|
|
695
|
+
*/
|
|
696
|
+
type CheckedFields<Type> = Type & OptionFree<Type>;
|
|
697
|
+
|
|
698
|
+
type NotRepeated<
|
|
699
|
+
Middleware_,
|
|
700
|
+
Inherited extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
701
|
+
> = Middleware_ extends {
|
|
702
|
+
readonly key: infer Key extends MiddlewareSpec.Key<Inherited>;
|
|
703
|
+
}
|
|
704
|
+
? MiddlewareSpec.AttachmentError<`Middleware "${Key}" is already attached by this profile`>
|
|
705
|
+
: Middleware_;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Refuses a middleware without options that an earlier layer attached, as it is
|
|
709
|
+
* attached at most once; one with options may repeat. Each member of an
|
|
710
|
+
* element's union is checked, so an array typed `(A | B)[]` is refused when
|
|
711
|
+
* either was attached.
|
|
712
|
+
*/
|
|
713
|
+
type NotInherited<
|
|
714
|
+
Middleware_ extends ReadonlyArray<unknown>,
|
|
715
|
+
Inherited extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
716
|
+
> = {
|
|
717
|
+
readonly [Index in keyof Middleware_]: NotRepeated<
|
|
718
|
+
Middleware_[Index],
|
|
719
|
+
Inherited
|
|
720
|
+
>;
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
/**
|
|
724
|
+
* A profile's middleware: a spec without options, or an attachment.
|
|
725
|
+
*/
|
|
726
|
+
type ProfileMiddleware<FieldsType> =
|
|
727
|
+
| OptionlessMiddlewareSpec
|
|
728
|
+
| Profile.Attachment<MiddlewareSpec.AnyMiddlewareSpec, FieldsType>;
|
|
729
|
+
|
|
730
|
+
type SpecOf<Middleware_> =
|
|
731
|
+
Middleware_ extends Profile.Attachment<infer MiddlewareSpec_, any>
|
|
732
|
+
? MiddlewareSpec_
|
|
733
|
+
: Extract<Middleware_, MiddlewareSpec.AnyMiddlewareSpec>;
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* `never` when a profile middleware does not declare the function type.
|
|
737
|
+
*/
|
|
738
|
+
type Declared<
|
|
739
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
740
|
+
FunctionType_ extends FunctionType,
|
|
741
|
+
Make,
|
|
742
|
+
> = [
|
|
743
|
+
MiddlewareSpecs_ extends unknown
|
|
744
|
+
? FunctionType_ extends MiddlewareSpec.FunctionTypes<MiddlewareSpecs_>
|
|
745
|
+
? never
|
|
746
|
+
: MiddlewareSpecs_
|
|
747
|
+
: never,
|
|
748
|
+
] extends [never]
|
|
749
|
+
? Make
|
|
750
|
+
: never;
|
|
751
|
+
|
|
752
|
+
type ExtendedMake<
|
|
753
|
+
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
754
|
+
Fields_ extends Profile.Fields,
|
|
755
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
756
|
+
> = Declared<
|
|
757
|
+
MiddlewareSpecs_,
|
|
758
|
+
RuntimeAndFunctionType_["functionType"],
|
|
759
|
+
<
|
|
760
|
+
const Name_ extends string,
|
|
761
|
+
const ArgsFields_ extends FunctionProvenance.ArgsFields = {},
|
|
762
|
+
Returns_ extends Schema.Codec<any, any> = never,
|
|
763
|
+
Error_ extends Schema.Codec<any, any> = never,
|
|
764
|
+
>(
|
|
765
|
+
options: {
|
|
766
|
+
readonly name: Name_;
|
|
767
|
+
readonly description?: string;
|
|
768
|
+
readonly args?: () => ArgsFields_;
|
|
769
|
+
readonly returns: () => Returns_;
|
|
770
|
+
readonly error?: () => Error_;
|
|
771
|
+
} & NoInfer<CheckedFields<Profile.Apply<Fields_, Name_, ArgsFields_>>>,
|
|
772
|
+
) => ExtendedBuilder<
|
|
773
|
+
RuntimeAndFunctionType_,
|
|
774
|
+
"public",
|
|
775
|
+
Name_,
|
|
776
|
+
FunctionProvenance.Confect<ArgsFields_, Returns_, Error_>,
|
|
777
|
+
MiddlewareSpecs_,
|
|
778
|
+
Profile.Apply<Fields_, Name_, ArgsFields_>
|
|
779
|
+
>
|
|
780
|
+
>;
|
|
781
|
+
|
|
782
|
+
type ExtendedMakePaginated<
|
|
783
|
+
Fields_ extends Profile.Fields,
|
|
784
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
785
|
+
> = Declared<
|
|
786
|
+
MiddlewareSpecs_,
|
|
787
|
+
"query",
|
|
788
|
+
<
|
|
789
|
+
const Name_ extends string,
|
|
790
|
+
const UserArgsFields_ extends FunctionProvenance.ArgsFields = {},
|
|
791
|
+
Item_ extends Schema.Codec<any, any> = never,
|
|
792
|
+
Error_ extends Schema.Codec<any, any> = never,
|
|
793
|
+
>(
|
|
794
|
+
options: {
|
|
795
|
+
readonly name: Name_;
|
|
796
|
+
readonly description?: string;
|
|
797
|
+
readonly args?: () => UserArgsFields_ &
|
|
798
|
+
ForbidPaginationOpts<UserArgsFields_>;
|
|
799
|
+
readonly item: () => Item_;
|
|
800
|
+
readonly error?: () => Error_;
|
|
801
|
+
} & NoInfer<CheckedFields<Profile.Apply<Fields_, Name_, UserArgsFields_>>>,
|
|
802
|
+
) => ExtendedBuilder<
|
|
803
|
+
RuntimeAndFunctionType.ConvexQuery,
|
|
804
|
+
"public",
|
|
805
|
+
Name_,
|
|
806
|
+
FunctionProvenance.ConfectPaginated<UserArgsFields_, Item_, Error_>,
|
|
807
|
+
MiddlewareSpecs_,
|
|
808
|
+
Profile.Apply<Fields_, Name_, UserArgsFields_>
|
|
809
|
+
>
|
|
810
|
+
>;
|
|
811
|
+
|
|
812
|
+
interface ExtendedRuntimes {
|
|
813
|
+
readonly publicQuery: RuntimeAndFunctionType.ConvexQuery;
|
|
814
|
+
readonly publicMutation: RuntimeAndFunctionType.ConvexMutation;
|
|
815
|
+
readonly publicAction: RuntimeAndFunctionType.ConvexAction;
|
|
816
|
+
readonly publicNodeAction: RuntimeAndFunctionType.NodeAction;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* A profile's five public builders and its own `extend`.
|
|
821
|
+
*/
|
|
822
|
+
export type Extended<
|
|
823
|
+
Fields_ extends Profile.Fields,
|
|
824
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
825
|
+
> = {
|
|
826
|
+
readonly [Builder_ in keyof ExtendedRuntimes]: ExtendedMake<
|
|
827
|
+
ExtendedRuntimes[Builder_],
|
|
828
|
+
Fields_,
|
|
829
|
+
MiddlewareSpecs_
|
|
830
|
+
>;
|
|
831
|
+
} & {
|
|
832
|
+
readonly publicPaginatedQuery: ExtendedMakePaginated<
|
|
833
|
+
Fields_,
|
|
834
|
+
MiddlewareSpecs_
|
|
835
|
+
>;
|
|
836
|
+
/**
|
|
837
|
+
* Require more fields and attach more middleware after this profile's.
|
|
838
|
+
*/
|
|
839
|
+
extend<Extension extends Profile.Fields = Profile.NoFields>(): <
|
|
840
|
+
const Middleware_ extends ReadonlyArray<
|
|
841
|
+
ProfileMiddleware<
|
|
842
|
+
Profile.Apply<Profile.Both<Fields_, Extension>, string, any>
|
|
843
|
+
>
|
|
844
|
+
>,
|
|
845
|
+
>(
|
|
846
|
+
config: {
|
|
847
|
+
readonly middleware: Middleware_ &
|
|
848
|
+
NotInherited<Middleware_, MiddlewareSpecs_>;
|
|
849
|
+
} & OptionFree<Extension["Type"]>,
|
|
850
|
+
) => Extended<
|
|
851
|
+
Profile.Both<Fields_, Extension>,
|
|
852
|
+
MiddlewareSpecs_ | SpecOf<Middleware_[number]>
|
|
853
|
+
>;
|
|
854
|
+
};
|
|
855
|
+
|
|
856
|
+
const makeExtended = (
|
|
857
|
+
middleware: ReadonlyArray<ProfileMiddleware<any>>,
|
|
858
|
+
): Extended<any, any> => {
|
|
859
|
+
// `OptionFree` keeps option names out of the fields; this split is the
|
|
860
|
+
// runtime's fallback.
|
|
861
|
+
const extended =
|
|
862
|
+
(makeSpec: (options: never) => object): any =>
|
|
863
|
+
({
|
|
864
|
+
name,
|
|
865
|
+
description,
|
|
866
|
+
args,
|
|
867
|
+
returns,
|
|
868
|
+
item,
|
|
869
|
+
error,
|
|
870
|
+
...fields
|
|
871
|
+
}: Record<string, unknown>) =>
|
|
872
|
+
middleware.reduce(
|
|
873
|
+
(spec: any, entry) =>
|
|
874
|
+
MiddlewareSpec.isMiddlewareSpec(entry)
|
|
875
|
+
? spec.middleware(entry)
|
|
876
|
+
: spec.middleware(
|
|
877
|
+
entry.spec,
|
|
878
|
+
entry.options({
|
|
879
|
+
name,
|
|
880
|
+
args: args ?? (() => ({})),
|
|
881
|
+
fields,
|
|
882
|
+
} as Profile.Info<unknown>),
|
|
883
|
+
),
|
|
884
|
+
Object.assign(
|
|
885
|
+
makeSpec({ name, description, args, returns, item, error } as never),
|
|
886
|
+
{ fields },
|
|
887
|
+
),
|
|
888
|
+
);
|
|
889
|
+
|
|
890
|
+
return {
|
|
891
|
+
publicQuery: extended(publicQuery),
|
|
892
|
+
publicMutation: extended(publicMutation),
|
|
893
|
+
publicAction: extended(publicAction),
|
|
894
|
+
publicNodeAction: extended(publicNodeAction),
|
|
895
|
+
publicPaginatedQuery: extended(publicPaginatedQuery),
|
|
896
|
+
extend: () => (config) =>
|
|
897
|
+
makeExtended([...middleware, ...config.middleware]),
|
|
898
|
+
};
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Public builders whose specs require and keep `Fields_`, with `middleware`.
|
|
903
|
+
*/
|
|
904
|
+
export const extend =
|
|
905
|
+
<Fields_ extends Profile.Fields = Profile.NoFields>() =>
|
|
906
|
+
<
|
|
907
|
+
const Middleware_ extends ReadonlyArray<
|
|
908
|
+
ProfileMiddleware<Profile.Apply<Fields_, string, any>>
|
|
909
|
+
>,
|
|
910
|
+
>(
|
|
911
|
+
config: { readonly middleware: Middleware_ } & OptionFree<Fields_["Type"]>,
|
|
912
|
+
) =>
|
|
913
|
+
makeExtended(config.middleware) as Extended<
|
|
914
|
+
Fields_,
|
|
915
|
+
SpecOf<Middleware_[number]>
|
|
916
|
+
>;
|
|
917
|
+
|
|
512
918
|
type MatchingRegisteredFunction<
|
|
513
919
|
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
514
920
|
FunctionVisibility_ extends FunctionVisibility,
|
package/src/GenericId.ts
CHANGED
|
@@ -5,8 +5,8 @@ import * as Match from "effect/Match";
|
|
|
5
5
|
import * as Option from "effect/Option";
|
|
6
6
|
import * as Schema from "effect/Schema";
|
|
7
7
|
import * as SchemaAST from "effect/SchemaAST";
|
|
8
|
-
import * as IdScope from "./IdScope";
|
|
9
|
-
import type * as Ref from "./Ref";
|
|
8
|
+
import * as IdScope from "./IdScope.js";
|
|
9
|
+
import type * as Ref from "./Ref.js";
|
|
10
10
|
|
|
11
11
|
const ConvexId = "~@confect/core/ConvexId";
|
|
12
12
|
const ConvexIdScope = "~@confect/core/ConvexIdScope";
|
package/src/GroupPath.ts
CHANGED
package/src/GroupSpec.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as MiddlewareAttachment from "./MiddlewareAttachment";
|
|
1
|
+
import * as MiddlewareAttachment from "./MiddlewareAttachment.js";
|
|
2
2
|
import * as Predicate from "effect/Predicate";
|
|
3
3
|
import * as Record from "effect/Record";
|
|
4
4
|
import * as Result from "effect/Result";
|
|
5
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
6
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
7
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
8
|
-
import { validateConfectFunctionIdentifier } from "./Identifier";
|
|
5
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
6
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
7
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
8
|
+
import { validateConfectFunctionIdentifier } from "./Identifier.js";
|
|
9
9
|
|
|
10
10
|
export const TypeId = "~@confect/core/GroupSpec";
|
|
11
11
|
export type TypeId = typeof TypeId;
|
package/src/Http.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type * as HttpApi from "effect/http-api/HttpApi";
|
|
|
8
8
|
import * as HttpApiBuilder from "effect/http-api/HttpApiBuilder";
|
|
9
9
|
import type * as HttpApiGroup from "effect/http-api/HttpApiGroup";
|
|
10
10
|
import * as HttpApiScalar from "effect/http-api/HttpApiScalar";
|
|
11
|
-
import * as App from "./App";
|
|
11
|
+
import * as App from "./App.js";
|
|
12
12
|
|
|
13
13
|
const TypeId = "~@confect/core/Http";
|
|
14
14
|
|
package/src/Manifest.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Data from "effect/Data";
|
|
2
2
|
import * as Result from "effect/Result";
|
|
3
3
|
import * as Schema from "effect/Schema";
|
|
4
|
-
import type * as MiddlewareSpec from "./MiddlewareSpec";
|
|
4
|
+
import type * as MiddlewareSpec from "./MiddlewareSpec.js";
|
|
5
5
|
|
|
6
6
|
export type MiddlewareAttachment<
|
|
7
7
|
MiddlewareSpec_ extends MiddlewareSpec.AnyMiddlewareSpec =
|
package/src/MiddlewareSpec.ts
CHANGED
|
@@ -3,10 +3,10 @@ import type * as Effect from "effect/Effect";
|
|
|
3
3
|
import * as Predicate from "effect/Predicate";
|
|
4
4
|
import type * as Schema from "effect/Schema";
|
|
5
5
|
import type { unhandled } from "effect/Types";
|
|
6
|
-
import type * as FunctionProvenance from "./FunctionProvenance";
|
|
7
|
-
import type * as FunctionSpec from "./FunctionSpec";
|
|
8
|
-
import * as Lazy from "./Lazy";
|
|
9
|
-
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
|
|
6
|
+
import type * as FunctionProvenance from "./FunctionProvenance.js";
|
|
7
|
+
import type * as FunctionSpec from "./FunctionSpec.js";
|
|
8
|
+
import * as Lazy from "./Lazy.js";
|
|
9
|
+
import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType.js";
|
|
10
10
|
|
|
11
11
|
export const TypeId = "~@confect/core/MiddlewareSpec";
|
|
12
12
|
export type TypeId = typeof TypeId;
|