@gaganref/confect-core 10.3.1-fork.3 → 10.3.1-fork.30
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 +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 +2 -2
- 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 +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 +329 -5
- package/dist/FunctionSpec.d.ts.map +1 -1
- package/dist/FunctionSpec.js +53 -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 +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 +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 +8 -7
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +7 -4
- 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 +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 +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 +31 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/package.json +1 -1
- package/src/ActionCall.ts +25 -0
- package/src/App.ts +20 -4
- package/src/Auth.ts +2 -2
- package/src/Callback.ts +4 -3
- package/src/Component.ts +12 -11
- package/src/FunctionProvenance.ts +3 -3
- package/src/FunctionSpec.ts +509 -9
- 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 +141 -0
- package/src/Ref.ts +19 -10
- 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 +31 -29
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,
|
|
@@ -7,12 +7,13 @@ import type {
|
|
|
7
7
|
RegisteredMutation,
|
|
8
8
|
RegisteredQuery,
|
|
9
9
|
} from "convex/server";
|
|
10
|
-
import
|
|
10
|
+
import * 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: Profile.Info<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,348 @@ 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
|
+
* Only a required description string may name a builder option. The builder
|
|
684
|
+
* reads it as that option. The conditional keeps the mapped type out of a
|
|
685
|
+
* builder call's inference, which would otherwise widen the function's name to
|
|
686
|
+
* `string` when reporting the error.
|
|
687
|
+
*/
|
|
688
|
+
type OptionFree<Type> = [keyof Type & BuilderOption] extends [never]
|
|
689
|
+
? unknown
|
|
690
|
+
: {
|
|
691
|
+
readonly [
|
|
692
|
+
Option in keyof Type & BuilderOption as Option extends "description"
|
|
693
|
+
? Type[Option] extends string
|
|
694
|
+
? string extends Type[Option]
|
|
695
|
+
? never
|
|
696
|
+
: Option
|
|
697
|
+
: Option
|
|
698
|
+
: Option
|
|
699
|
+
]: never;
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* A function's fields, checked once applied, since a profile's field type can
|
|
704
|
+
* branch on the function's name.
|
|
705
|
+
*/
|
|
706
|
+
type CheckedFields<Type> = Type & OptionFree<Type>;
|
|
707
|
+
|
|
708
|
+
type NotRepeated<
|
|
709
|
+
Middleware_,
|
|
710
|
+
Inherited extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
711
|
+
> = Middleware_ extends {
|
|
712
|
+
readonly key: infer Key extends MiddlewareSpec.Key<Inherited>;
|
|
713
|
+
}
|
|
714
|
+
? MiddlewareSpec.AttachmentError<`Middleware "${Key}" is already attached by this profile`>
|
|
715
|
+
: Middleware_;
|
|
716
|
+
|
|
717
|
+
/**
|
|
718
|
+
* Refuses a middleware without options that an earlier layer attached, as it is
|
|
719
|
+
* attached at most once; one with options may repeat. Each member of an
|
|
720
|
+
* element's union is checked, so an array typed `(A | B)[]` is refused when
|
|
721
|
+
* either was attached.
|
|
722
|
+
*/
|
|
723
|
+
type NotInherited<
|
|
724
|
+
Middleware_ extends ReadonlyArray<unknown>,
|
|
725
|
+
Inherited extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
726
|
+
> = {
|
|
727
|
+
readonly [Index in keyof Middleware_]: NotRepeated<
|
|
728
|
+
Middleware_[Index],
|
|
729
|
+
Inherited
|
|
730
|
+
>;
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* A profile's middleware: a spec without options, or an attachment.
|
|
735
|
+
*/
|
|
736
|
+
type ProfileMiddleware<FieldsType> =
|
|
737
|
+
| OptionlessMiddlewareSpec
|
|
738
|
+
| Profile.Attachment<MiddlewareSpec.AnyMiddlewareSpec, FieldsType>;
|
|
739
|
+
|
|
740
|
+
type SpecOf<Middleware_> =
|
|
741
|
+
Middleware_ extends Profile.Attachment<infer MiddlewareSpec_, any>
|
|
742
|
+
? MiddlewareSpec_
|
|
743
|
+
: Extract<Middleware_, MiddlewareSpec.AnyMiddlewareSpec>;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* `never` when a profile middleware does not declare the function type.
|
|
747
|
+
*/
|
|
748
|
+
type Declared<
|
|
749
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
750
|
+
FunctionType_ extends FunctionType,
|
|
751
|
+
Make,
|
|
752
|
+
> = [
|
|
753
|
+
MiddlewareSpecs_ extends unknown
|
|
754
|
+
? FunctionType_ extends MiddlewareSpec.FunctionTypes<MiddlewareSpecs_>
|
|
755
|
+
? never
|
|
756
|
+
: MiddlewareSpecs_
|
|
757
|
+
: never,
|
|
758
|
+
] extends [never]
|
|
759
|
+
? Make
|
|
760
|
+
: never;
|
|
761
|
+
|
|
762
|
+
type Wrapped<
|
|
763
|
+
Layers extends ReadonlyArray<Profile.Transforms>,
|
|
764
|
+
Key extends keyof Profile.Transforms,
|
|
765
|
+
Input,
|
|
766
|
+
> = Layers extends readonly [
|
|
767
|
+
infer First extends Profile.Transforms,
|
|
768
|
+
...infer Rest extends ReadonlyArray<Profile.Transforms>,
|
|
769
|
+
]
|
|
770
|
+
? Wrapped<
|
|
771
|
+
Rest,
|
|
772
|
+
Key,
|
|
773
|
+
Key extends keyof First
|
|
774
|
+
? [Input] extends [never]
|
|
775
|
+
? Key extends "error"
|
|
776
|
+
? Profile.Transform<First[Key], typeof Schema.Never>
|
|
777
|
+
: never
|
|
778
|
+
: Profile.Transform<First[Key], Input>
|
|
779
|
+
: Input
|
|
780
|
+
>
|
|
781
|
+
: Input;
|
|
782
|
+
|
|
783
|
+
type UserArgs<A> = [A] extends [never] ? {} : A;
|
|
784
|
+
|
|
785
|
+
type ExtendedMake<
|
|
786
|
+
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
787
|
+
Fields_ extends Profile.Fields,
|
|
788
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
789
|
+
Layers extends ReadonlyArray<Profile.Transforms>,
|
|
790
|
+
> = Declared<
|
|
791
|
+
MiddlewareSpecs_,
|
|
792
|
+
RuntimeAndFunctionType_["functionType"],
|
|
793
|
+
<
|
|
794
|
+
const Name_ extends string,
|
|
795
|
+
const ArgsFields_ extends FunctionProvenance.ArgsFields = never,
|
|
796
|
+
Returns_ extends Schema.Codec<any, any> = never,
|
|
797
|
+
Error_ extends Schema.Codec<any, any> = never,
|
|
798
|
+
>(
|
|
799
|
+
options: {
|
|
800
|
+
readonly name: Name_;
|
|
801
|
+
readonly description?: string;
|
|
802
|
+
readonly args?: () => ArgsFields_;
|
|
803
|
+
readonly returns: () => Returns_;
|
|
804
|
+
readonly error?: () => Error_;
|
|
805
|
+
} & NoInfer<
|
|
806
|
+
CheckedFields<Profile.Apply<Fields_, Name_, UserArgs<ArgsFields_>>>
|
|
807
|
+
>,
|
|
808
|
+
) => ExtendedBuilder<
|
|
809
|
+
RuntimeAndFunctionType_,
|
|
810
|
+
"public",
|
|
811
|
+
Name_,
|
|
812
|
+
FunctionProvenance.Confect<
|
|
813
|
+
UserArgs<Wrapped<Layers, "args", ArgsFields_>>,
|
|
814
|
+
Wrapped<Layers, "returns", Returns_>,
|
|
815
|
+
Wrapped<Layers, "error", Error_>
|
|
816
|
+
>,
|
|
817
|
+
MiddlewareSpecs_,
|
|
818
|
+
Profile.Apply<Fields_, Name_, UserArgs<ArgsFields_>>
|
|
819
|
+
>
|
|
820
|
+
>;
|
|
821
|
+
|
|
822
|
+
type ExtendedMakePaginated<
|
|
823
|
+
Fields_ extends Profile.Fields,
|
|
824
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
825
|
+
Layers extends ReadonlyArray<Profile.Transforms>,
|
|
826
|
+
> = Declared<
|
|
827
|
+
MiddlewareSpecs_,
|
|
828
|
+
"query",
|
|
829
|
+
<
|
|
830
|
+
const Name_ extends string,
|
|
831
|
+
const UserArgsFields_ extends FunctionProvenance.ArgsFields = never,
|
|
832
|
+
Item_ extends Schema.Codec<any, any> = never,
|
|
833
|
+
Error_ extends Schema.Codec<any, any> = never,
|
|
834
|
+
>(
|
|
835
|
+
options: {
|
|
836
|
+
readonly name: Name_;
|
|
837
|
+
readonly description?: string;
|
|
838
|
+
readonly args?: () => UserArgsFields_ &
|
|
839
|
+
ForbidPaginationOpts<UserArgsFields_>;
|
|
840
|
+
readonly item: () => Item_;
|
|
841
|
+
readonly error?: () => Error_;
|
|
842
|
+
} & NoInfer<
|
|
843
|
+
CheckedFields<Profile.Apply<Fields_, Name_, UserArgs<UserArgsFields_>>>
|
|
844
|
+
>,
|
|
845
|
+
) => ExtendedBuilder<
|
|
846
|
+
RuntimeAndFunctionType.ConvexQuery,
|
|
847
|
+
"public",
|
|
848
|
+
Name_,
|
|
849
|
+
FunctionProvenance.ConfectPaginated<
|
|
850
|
+
UserArgs<Wrapped<Layers, "args", UserArgsFields_>>,
|
|
851
|
+
Wrapped<Layers, "item", Item_>,
|
|
852
|
+
Wrapped<Layers, "error", Error_>
|
|
853
|
+
>,
|
|
854
|
+
MiddlewareSpecs_,
|
|
855
|
+
Profile.Apply<Fields_, Name_, UserArgs<UserArgsFields_>>
|
|
856
|
+
>
|
|
857
|
+
>;
|
|
858
|
+
|
|
859
|
+
interface ExtendedRuntimes {
|
|
860
|
+
readonly publicQuery: RuntimeAndFunctionType.ConvexQuery;
|
|
861
|
+
readonly publicMutation: RuntimeAndFunctionType.ConvexMutation;
|
|
862
|
+
readonly publicAction: RuntimeAndFunctionType.ConvexAction;
|
|
863
|
+
readonly publicNodeAction: RuntimeAndFunctionType.NodeAction;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* A profile's five public builders and its own `extend`.
|
|
868
|
+
*/
|
|
869
|
+
export type Extended<
|
|
870
|
+
Fields_ extends Profile.Fields,
|
|
871
|
+
MiddlewareSpecs_ extends MiddlewareSpec.AnyMiddlewareSpec,
|
|
872
|
+
Layers extends ReadonlyArray<Profile.Transforms> = [],
|
|
873
|
+
> = {
|
|
874
|
+
readonly [Builder_ in keyof ExtendedRuntimes]: ExtendedMake<
|
|
875
|
+
ExtendedRuntimes[Builder_],
|
|
876
|
+
Fields_,
|
|
877
|
+
MiddlewareSpecs_,
|
|
878
|
+
Layers
|
|
879
|
+
>;
|
|
880
|
+
} & {
|
|
881
|
+
readonly publicPaginatedQuery: ExtendedMakePaginated<
|
|
882
|
+
Fields_,
|
|
883
|
+
MiddlewareSpecs_,
|
|
884
|
+
Layers
|
|
885
|
+
>;
|
|
886
|
+
/**
|
|
887
|
+
* Require more fields and attach more middleware after this profile's.
|
|
888
|
+
*/
|
|
889
|
+
extend<
|
|
890
|
+
Extension extends Profile.Fields = Profile.NoFields,
|
|
891
|
+
Transforms extends Profile.Transforms = {},
|
|
892
|
+
>(): <
|
|
893
|
+
const Middleware_ extends ReadonlyArray<
|
|
894
|
+
ProfileMiddleware<
|
|
895
|
+
Profile.Apply<Profile.Both<Fields_, Extension>, string, any>
|
|
896
|
+
>
|
|
897
|
+
>,
|
|
898
|
+
>(
|
|
899
|
+
config: {
|
|
900
|
+
readonly middleware: Middleware_ &
|
|
901
|
+
NotInherited<Middleware_, MiddlewareSpecs_>;
|
|
902
|
+
} & OptionFree<Extension["Type"]> &
|
|
903
|
+
Profile.SchemaConfig<
|
|
904
|
+
Transforms,
|
|
905
|
+
Profile.Apply<Profile.Both<Fields_, Extension>, string, any>
|
|
906
|
+
>,
|
|
907
|
+
) => Extended<
|
|
908
|
+
Profile.Both<Fields_, Extension>,
|
|
909
|
+
MiddlewareSpecs_ | SpecOf<Middleware_[number]>,
|
|
910
|
+
[...Layers, Transforms]
|
|
911
|
+
>;
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
type RuntimeWrappers = Partial<
|
|
915
|
+
Record<
|
|
916
|
+
keyof Profile.Transforms,
|
|
917
|
+
(thunk: () => any, info: Profile.Info<any>) => () => any
|
|
918
|
+
>
|
|
919
|
+
>;
|
|
920
|
+
|
|
921
|
+
const makeExtended = (
|
|
922
|
+
middleware: ReadonlyArray<ProfileMiddleware<any>>,
|
|
923
|
+
schemas: ReadonlyArray<RuntimeWrappers> = [],
|
|
924
|
+
): Extended<any, any> => {
|
|
925
|
+
const extended =
|
|
926
|
+
(makeSpec: (options: never) => object, paginated = false): any =>
|
|
927
|
+
({
|
|
928
|
+
name,
|
|
929
|
+
description,
|
|
930
|
+
args,
|
|
931
|
+
returns,
|
|
932
|
+
item,
|
|
933
|
+
error,
|
|
934
|
+
...fields
|
|
935
|
+
}: Record<string, unknown>) => {
|
|
936
|
+
const info = {
|
|
937
|
+
name,
|
|
938
|
+
...(description === undefined ? {} : { description }),
|
|
939
|
+
args: args ?? (() => ({})),
|
|
940
|
+
fields,
|
|
941
|
+
} as Profile.Info<unknown>;
|
|
942
|
+
const thunks = {
|
|
943
|
+
args,
|
|
944
|
+
returns: paginated ? undefined : returns,
|
|
945
|
+
item: paginated ? item : undefined,
|
|
946
|
+
error,
|
|
947
|
+
} as Partial<Record<keyof Profile.Transforms, () => any>>;
|
|
948
|
+
for (const wrappers of schemas) {
|
|
949
|
+
for (const key of ["args", "returns", "item", "error"] as const) {
|
|
950
|
+
const wrap = wrappers[key];
|
|
951
|
+
const thunk =
|
|
952
|
+
thunks[key] ?? (key === "error" ? () => Schema.Never : undefined);
|
|
953
|
+
if (wrap !== undefined && thunk !== undefined) {
|
|
954
|
+
thunks[key] = () => wrap(thunk, info)();
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
return middleware.reduce(
|
|
959
|
+
(spec: any, entry) =>
|
|
960
|
+
MiddlewareSpec.isMiddlewareSpec(entry)
|
|
961
|
+
? spec.middleware(entry)
|
|
962
|
+
: spec.middleware(entry.spec, entry.options(info)),
|
|
963
|
+
Object.assign(makeSpec({ name, description, ...thunks } as never), {
|
|
964
|
+
fields,
|
|
965
|
+
}),
|
|
966
|
+
);
|
|
967
|
+
};
|
|
968
|
+
|
|
969
|
+
return {
|
|
970
|
+
publicQuery: extended(publicQuery),
|
|
971
|
+
publicMutation: extended(publicMutation),
|
|
972
|
+
publicAction: extended(publicAction),
|
|
973
|
+
publicNodeAction: extended(publicNodeAction),
|
|
974
|
+
publicPaginatedQuery: extended(publicPaginatedQuery, true),
|
|
975
|
+
extend:
|
|
976
|
+
() =>
|
|
977
|
+
(config: {
|
|
978
|
+
middleware: ReadonlyArray<ProfileMiddleware<any>>;
|
|
979
|
+
schemas?: RuntimeWrappers;
|
|
980
|
+
}) =>
|
|
981
|
+
makeExtended(
|
|
982
|
+
[...middleware, ...config.middleware],
|
|
983
|
+
[...schemas, config.schemas ?? {}],
|
|
984
|
+
),
|
|
985
|
+
};
|
|
986
|
+
};
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Public builders whose specs require and keep `Fields_`, with `middleware`.
|
|
990
|
+
*/
|
|
991
|
+
export const extend =
|
|
992
|
+
<
|
|
993
|
+
Fields_ extends Profile.Fields = Profile.NoFields,
|
|
994
|
+
Transforms extends Profile.Transforms = {},
|
|
995
|
+
>() =>
|
|
996
|
+
<
|
|
997
|
+
const Middleware_ extends ReadonlyArray<
|
|
998
|
+
ProfileMiddleware<Profile.Apply<Fields_, string, any>>
|
|
999
|
+
>,
|
|
1000
|
+
>(
|
|
1001
|
+
config: {
|
|
1002
|
+
readonly middleware: Middleware_;
|
|
1003
|
+
} & OptionFree<Fields_["Type"]> &
|
|
1004
|
+
Profile.SchemaConfig<Transforms, Profile.Apply<Fields_, string, any>>,
|
|
1005
|
+
) =>
|
|
1006
|
+
makeExtended(config.middleware, [config.schemas ?? {}]) as Extended<
|
|
1007
|
+
Fields_,
|
|
1008
|
+
SpecOf<Middleware_[number]>,
|
|
1009
|
+
[Transforms]
|
|
1010
|
+
>;
|
|
1011
|
+
|
|
512
1012
|
type MatchingRegisteredFunction<
|
|
513
1013
|
RuntimeAndFunctionType_ extends RuntimeAndFunctionType.RuntimeAndFunctionType,
|
|
514
1014
|
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;
|