@fragno-dev/core 0.1.11 → 0.2.2
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/.turbo/turbo-build.log +87 -69
- package/CHANGELOG.md +79 -0
- package/dist/api/api.d.ts +21 -2
- package/dist/api/api.d.ts.map +1 -1
- package/dist/api/api.js +2 -1
- package/dist/api/api.js.map +1 -1
- package/dist/api/bind-services.d.ts +0 -1
- package/dist/api/bind-services.d.ts.map +1 -1
- package/dist/api/bind-services.js.map +1 -1
- package/dist/api/error.d.ts.map +1 -1
- package/dist/api/error.js.map +1 -1
- package/dist/api/fragment-definition-builder.d.ts +32 -40
- package/dist/api/fragment-definition-builder.d.ts.map +1 -1
- package/dist/api/fragment-definition-builder.js +15 -21
- package/dist/api/fragment-definition-builder.js.map +1 -1
- package/dist/api/fragment-instantiator.d.ts +51 -30
- package/dist/api/fragment-instantiator.d.ts.map +1 -1
- package/dist/api/fragment-instantiator.js +201 -52
- package/dist/api/fragment-instantiator.js.map +1 -1
- package/dist/api/request-context-storage.d.ts +4 -0
- package/dist/api/request-context-storage.d.ts.map +1 -1
- package/dist/api/request-context-storage.js +6 -0
- package/dist/api/request-context-storage.js.map +1 -1
- package/dist/api/request-input-context.d.ts +57 -1
- package/dist/api/request-input-context.d.ts.map +1 -1
- package/dist/api/request-input-context.js +67 -0
- package/dist/api/request-input-context.js.map +1 -1
- package/dist/api/request-middleware.d.ts +2 -2
- package/dist/api/request-middleware.d.ts.map +1 -1
- package/dist/api/request-middleware.js.map +1 -1
- package/dist/api/request-output-context.d.ts +1 -1
- package/dist/api/request-output-context.d.ts.map +1 -1
- package/dist/api/request-output-context.js.map +1 -1
- package/dist/api/route-caller.d.ts +30 -0
- package/dist/api/route-caller.d.ts.map +1 -0
- package/dist/api/route-caller.js +63 -0
- package/dist/api/route-caller.js.map +1 -0
- package/dist/api/route-handler-input-options.d.ts.map +1 -1
- package/dist/api/route.d.ts +8 -8
- package/dist/api/route.d.ts.map +1 -1
- package/dist/api/route.js.map +1 -1
- package/dist/api/shared-types.d.ts.map +1 -1
- package/dist/client/client-error.d.ts.map +1 -1
- package/dist/client/client-error.js.map +1 -1
- package/dist/client/client.d.ts +90 -50
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +128 -16
- package/dist/client/client.js.map +1 -1
- package/dist/client/client.svelte.d.ts +6 -5
- package/dist/client/client.svelte.d.ts.map +1 -1
- package/dist/client/client.svelte.js +10 -2
- package/dist/client/client.svelte.js.map +1 -1
- package/dist/client/internal/ndjson-streaming.js.map +1 -1
- package/dist/client/react.d.ts +5 -4
- package/dist/client/react.d.ts.map +1 -1
- package/dist/client/react.js +104 -12
- package/dist/client/react.js.map +1 -1
- package/dist/client/solid.d.ts +7 -5
- package/dist/client/solid.d.ts.map +1 -1
- package/dist/client/solid.js +23 -9
- package/dist/client/solid.js.map +1 -1
- package/dist/client/vanilla.d.ts +16 -4
- package/dist/client/vanilla.d.ts.map +1 -1
- package/dist/client/vanilla.js +21 -1
- package/dist/client/vanilla.js.map +1 -1
- package/dist/client/vue.d.ts +10 -4
- package/dist/client/vue.d.ts.map +1 -1
- package/dist/client/vue.js +24 -1
- package/dist/client/vue.js.map +1 -1
- package/dist/id.d.ts +2 -0
- package/dist/id.js +3 -0
- package/dist/internal/cuid.d.ts +16 -0
- package/dist/internal/cuid.d.ts.map +1 -0
- package/dist/internal/cuid.js +82 -0
- package/dist/internal/cuid.js.map +1 -0
- package/dist/internal/trace-context.d.ts +23 -0
- package/dist/internal/trace-context.d.ts.map +1 -0
- package/dist/internal/trace-context.js +14 -0
- package/dist/internal/trace-context.js.map +1 -0
- package/dist/mod-client.d.ts +7 -20
- package/dist/mod-client.d.ts.map +1 -1
- package/dist/mod-client.js +25 -13
- package/dist/mod-client.js.map +1 -1
- package/dist/mod.d.ts +8 -6
- package/dist/mod.js +3 -1
- package/dist/runtime.d.ts +15 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +33 -0
- package/dist/runtime.js.map +1 -0
- package/dist/test/test.d.ts +6 -6
- package/dist/test/test.d.ts.map +1 -1
- package/dist/test/test.js.map +1 -1
- package/dist/util/ssr.js.map +1 -1
- package/package.json +42 -52
- package/src/api/api.test.ts +3 -1
- package/src/api/api.ts +28 -0
- package/src/api/bind-services.ts +0 -5
- package/src/api/error.ts +1 -0
- package/src/api/fragment-definition-builder.extend.test.ts +2 -1
- package/src/api/fragment-definition-builder.test.ts +2 -1
- package/src/api/fragment-definition-builder.ts +56 -112
- package/src/api/fragment-instantiator.test.ts +311 -166
- package/src/api/fragment-instantiator.ts +470 -131
- package/src/api/fragment-services.test.ts +1 -0
- package/src/api/internal/path-runtime.test.ts +8 -0
- package/src/api/internal/path-type.test.ts +3 -1
- package/src/api/internal/route.test.ts +1 -0
- package/src/api/request-context-storage.ts +7 -0
- package/src/api/request-input-context.test.ts +156 -2
- package/src/api/request-input-context.ts +87 -1
- package/src/api/request-middleware.test.ts +43 -2
- package/src/api/request-middleware.ts +4 -3
- package/src/api/request-output-context.test.ts +3 -1
- package/src/api/request-output-context.ts +2 -1
- package/src/api/route-caller.test.ts +195 -0
- package/src/api/route-caller.ts +167 -0
- package/src/api/route-handler-input-options.ts +2 -1
- package/src/api/route.test.ts +4 -2
- package/src/api/route.ts +9 -3
- package/src/api/shared-types.ts +2 -1
- package/src/client/client-builder.test.ts +4 -2
- package/src/client/client-error.test.ts +2 -1
- package/src/client/client-error.ts +1 -1
- package/src/client/client-types.test.ts +19 -5
- package/src/client/client.ssr.test.ts +6 -4
- package/src/client/client.svelte.test.ts +18 -9
- package/src/client/client.svelte.ts +38 -13
- package/src/client/client.test.ts +244 -10
- package/src/client/client.ts +473 -148
- package/src/client/internal/ndjson-streaming.test.ts +6 -3
- package/src/client/internal/ndjson-streaming.ts +1 -0
- package/src/client/react.test.ts +176 -6
- package/src/client/react.ts +226 -31
- package/src/client/solid.test.ts +29 -5
- package/src/client/solid.ts +60 -22
- package/src/client/vanilla.test.ts +148 -6
- package/src/client/vanilla.ts +63 -9
- package/src/client/vue.test.ts +397 -8
- package/src/client/vue.ts +74 -4
- package/src/id.ts +1 -0
- package/src/internal/cuid.test.ts +164 -0
- package/src/internal/cuid.ts +133 -0
- package/src/internal/trace-context.ts +35 -0
- package/src/mod-client.ts +55 -9
- package/src/mod.ts +9 -3
- package/src/runtime.ts +48 -0
- package/src/test/test.test.ts +4 -2
- package/src/test/test.ts +14 -7
- package/src/util/async.test.ts +1 -0
- package/src/util/content-type.test.ts +1 -0
- package/src/util/nanostores.test.ts +3 -1
- package/src/util/ssr.ts +1 -0
- package/tsconfig.json +1 -1
- package/tsdown.config.ts +2 -0
- package/vitest.config.ts +2 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { RequestThisContext } from "./api";
|
|
2
|
-
import type {
|
|
2
|
+
import type { BoundServices } from "./bind-services";
|
|
3
3
|
import type { RequestContextStorage } from "./request-context-storage";
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
AnyFragnoInstantiatedFragment,
|
|
7
|
-
} from "./fragment-instantiator";
|
|
4
|
+
import type { AnyRouteOrFactory } from "./route";
|
|
5
|
+
import type { FragnoPublicConfig } from "./shared-types";
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Metadata for a service dependency
|
|
@@ -16,31 +14,6 @@ interface ServiceMetadata {
|
|
|
16
14
|
required: boolean;
|
|
17
15
|
}
|
|
18
16
|
|
|
19
|
-
/**
|
|
20
|
-
* Callback that instantiates a linked fragment.
|
|
21
|
-
* Receives the same context as the main fragment and returns an instantiated fragment.
|
|
22
|
-
*/
|
|
23
|
-
export type LinkedFragmentCallback<
|
|
24
|
-
TConfig,
|
|
25
|
-
TOptions extends FragnoPublicConfig,
|
|
26
|
-
TServiceDependencies,
|
|
27
|
-
> = (context: {
|
|
28
|
-
config: TConfig;
|
|
29
|
-
options: TOptions;
|
|
30
|
-
serviceDependencies?: TServiceDependencies;
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
}) => FragnoInstantiatedFragment<any, any, any, any, any, any, any>;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Extract the services type from a FragnoInstantiatedFragment
|
|
36
|
-
*/
|
|
37
|
-
export type ExtractLinkedServices<T> = T extends (
|
|
38
|
-
...args: never[]
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
) => FragnoInstantiatedFragment<any, any, infer TServices, any, any, any, any>
|
|
41
|
-
? TServices
|
|
42
|
-
: never;
|
|
43
|
-
|
|
44
17
|
/**
|
|
45
18
|
* Context passed to the request context factory function.
|
|
46
19
|
*/
|
|
@@ -116,7 +89,7 @@ export interface FragmentDefinition<
|
|
|
116
89
|
TServiceThisContext extends RequestThisContext,
|
|
117
90
|
THandlerThisContext extends RequestThisContext,
|
|
118
91
|
TRequestStorage = {},
|
|
119
|
-
|
|
92
|
+
TInternalRoutes extends readonly AnyRouteOrFactory[] = readonly [],
|
|
120
93
|
> {
|
|
121
94
|
name: string;
|
|
122
95
|
|
|
@@ -224,17 +197,22 @@ export interface FragmentDefinition<
|
|
|
224
197
|
}) => RequestContextStorage<TRequestStorage>;
|
|
225
198
|
|
|
226
199
|
/**
|
|
227
|
-
* Optional
|
|
228
|
-
* Linked fragments are service-only and share the same config/options as the parent.
|
|
200
|
+
* Optional factory for internal data attached to fragment.$internal.
|
|
229
201
|
*/
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
202
|
+
internalDataFactory?: (context: {
|
|
203
|
+
config: TConfig;
|
|
204
|
+
options: TOptions;
|
|
205
|
+
deps: TDeps;
|
|
206
|
+
services: BoundServices<TBaseServices & TServices>;
|
|
207
|
+
serviceDeps: TServiceDependencies;
|
|
208
|
+
}) => Record<string, unknown> | void;
|
|
209
|
+
|
|
210
|
+
internalRoutes?: TInternalRoutes;
|
|
233
211
|
|
|
234
212
|
$serviceThisContext?: TServiceThisContext;
|
|
235
213
|
$handlerThisContext?: THandlerThisContext;
|
|
236
214
|
$requestStorage?: TRequestStorage;
|
|
237
|
-
$
|
|
215
|
+
$internalRoutes?: TInternalRoutes;
|
|
238
216
|
}
|
|
239
217
|
|
|
240
218
|
/**
|
|
@@ -252,7 +230,7 @@ export class FragmentDefinitionBuilder<
|
|
|
252
230
|
TServiceThisContext extends RequestThisContext,
|
|
253
231
|
THandlerThisContext extends RequestThisContext,
|
|
254
232
|
TRequestStorage = {},
|
|
255
|
-
|
|
233
|
+
TInternalRoutes extends readonly AnyRouteOrFactory[] = readonly [],
|
|
256
234
|
> {
|
|
257
235
|
#name: string;
|
|
258
236
|
#dependencies?: (context: { config: TConfig; options: TOptions }) => TDeps;
|
|
@@ -306,9 +284,7 @@ export class FragmentDefinitionBuilder<
|
|
|
306
284
|
options: TOptions;
|
|
307
285
|
deps: TDeps;
|
|
308
286
|
}) => RequestContextStorage<TRequestStorage>;
|
|
309
|
-
#
|
|
310
|
-
[K in keyof TLinkedFragments]: LinkedFragmentCallback<TConfig, TOptions, TServiceDependencies>;
|
|
311
|
-
};
|
|
287
|
+
#internalRoutes?: TInternalRoutes;
|
|
312
288
|
|
|
313
289
|
constructor(
|
|
314
290
|
name: string,
|
|
@@ -364,13 +340,7 @@ export class FragmentDefinitionBuilder<
|
|
|
364
340
|
options: TOptions;
|
|
365
341
|
deps: TDeps;
|
|
366
342
|
}) => RequestContextStorage<TRequestStorage>;
|
|
367
|
-
|
|
368
|
-
[K in keyof TLinkedFragments]: LinkedFragmentCallback<
|
|
369
|
-
TConfig,
|
|
370
|
-
TOptions,
|
|
371
|
-
TServiceDependencies
|
|
372
|
-
>;
|
|
373
|
-
};
|
|
343
|
+
internalRoutes?: TInternalRoutes;
|
|
374
344
|
},
|
|
375
345
|
) {
|
|
376
346
|
this.#name = name;
|
|
@@ -383,7 +353,7 @@ export class FragmentDefinitionBuilder<
|
|
|
383
353
|
this.#createRequestStorage = state.createRequestStorage;
|
|
384
354
|
this.#createThisContext = state.createThisContext;
|
|
385
355
|
this.#getExternalStorage = state.getExternalStorage;
|
|
386
|
-
this.#
|
|
356
|
+
this.#internalRoutes = state.internalRoutes;
|
|
387
357
|
}
|
|
388
358
|
}
|
|
389
359
|
|
|
@@ -426,7 +396,7 @@ export class FragmentDefinitionBuilder<
|
|
|
426
396
|
TServiceThisContext,
|
|
427
397
|
THandlerThisContext,
|
|
428
398
|
TRequestStorage,
|
|
429
|
-
|
|
399
|
+
TInternalRoutes
|
|
430
400
|
> {
|
|
431
401
|
// Warn if we're discarding existing configuration
|
|
432
402
|
if (
|
|
@@ -454,7 +424,7 @@ export class FragmentDefinitionBuilder<
|
|
|
454
424
|
TServiceThisContext,
|
|
455
425
|
THandlerThisContext,
|
|
456
426
|
TRequestStorage,
|
|
457
|
-
|
|
427
|
+
TInternalRoutes
|
|
458
428
|
>(this.#name, {
|
|
459
429
|
dependencies: fn,
|
|
460
430
|
baseServices: undefined,
|
|
@@ -465,7 +435,7 @@ export class FragmentDefinitionBuilder<
|
|
|
465
435
|
createRequestStorage: undefined,
|
|
466
436
|
createThisContext: undefined,
|
|
467
437
|
getExternalStorage: undefined,
|
|
468
|
-
|
|
438
|
+
internalRoutes: this.#internalRoutes,
|
|
469
439
|
});
|
|
470
440
|
}
|
|
471
441
|
|
|
@@ -494,7 +464,7 @@ export class FragmentDefinitionBuilder<
|
|
|
494
464
|
TServiceThisContext,
|
|
495
465
|
THandlerThisContext,
|
|
496
466
|
TRequestStorage,
|
|
497
|
-
|
|
467
|
+
TInternalRoutes
|
|
498
468
|
> {
|
|
499
469
|
return new FragmentDefinitionBuilder<
|
|
500
470
|
TConfig,
|
|
@@ -507,7 +477,7 @@ export class FragmentDefinitionBuilder<
|
|
|
507
477
|
TServiceThisContext,
|
|
508
478
|
THandlerThisContext,
|
|
509
479
|
TRequestStorage,
|
|
510
|
-
|
|
480
|
+
TInternalRoutes
|
|
511
481
|
>(this.#name, {
|
|
512
482
|
dependencies: this.#dependencies,
|
|
513
483
|
baseServices: fn,
|
|
@@ -517,7 +487,7 @@ export class FragmentDefinitionBuilder<
|
|
|
517
487
|
createRequestStorage: this.#createRequestStorage,
|
|
518
488
|
createThisContext: this.#createThisContext,
|
|
519
489
|
getExternalStorage: this.#getExternalStorage,
|
|
520
|
-
|
|
490
|
+
internalRoutes: this.#internalRoutes,
|
|
521
491
|
});
|
|
522
492
|
}
|
|
523
493
|
|
|
@@ -547,7 +517,7 @@ export class FragmentDefinitionBuilder<
|
|
|
547
517
|
TServiceThisContext,
|
|
548
518
|
THandlerThisContext,
|
|
549
519
|
TRequestStorage,
|
|
550
|
-
|
|
520
|
+
TInternalRoutes
|
|
551
521
|
> {
|
|
552
522
|
// Type assertion needed because TypeScript can't verify object spread with mapped types
|
|
553
523
|
const newNamedServices = {
|
|
@@ -576,7 +546,7 @@ export class FragmentDefinitionBuilder<
|
|
|
576
546
|
TServiceThisContext,
|
|
577
547
|
THandlerThisContext,
|
|
578
548
|
TRequestStorage,
|
|
579
|
-
|
|
549
|
+
TInternalRoutes
|
|
580
550
|
>(this.#name, {
|
|
581
551
|
dependencies: this.#dependencies,
|
|
582
552
|
baseServices: this.#baseServices,
|
|
@@ -586,7 +556,7 @@ export class FragmentDefinitionBuilder<
|
|
|
586
556
|
createRequestStorage: this.#createRequestStorage,
|
|
587
557
|
createThisContext: this.#createThisContext,
|
|
588
558
|
getExternalStorage: this.#getExternalStorage,
|
|
589
|
-
|
|
559
|
+
internalRoutes: this.#internalRoutes,
|
|
590
560
|
});
|
|
591
561
|
}
|
|
592
562
|
|
|
@@ -619,7 +589,7 @@ export class FragmentDefinitionBuilder<
|
|
|
619
589
|
TServiceThisContext,
|
|
620
590
|
THandlerThisContext,
|
|
621
591
|
TRequestStorage,
|
|
622
|
-
|
|
592
|
+
TInternalRoutes
|
|
623
593
|
> {
|
|
624
594
|
// Type assertion needed because TypeScript can't verify object spread with mapped types
|
|
625
595
|
const newPrivateServices = {
|
|
@@ -648,7 +618,7 @@ export class FragmentDefinitionBuilder<
|
|
|
648
618
|
TServiceThisContext,
|
|
649
619
|
THandlerThisContext,
|
|
650
620
|
TRequestStorage,
|
|
651
|
-
|
|
621
|
+
TInternalRoutes
|
|
652
622
|
>(this.#name, {
|
|
653
623
|
dependencies: this.#dependencies,
|
|
654
624
|
baseServices: this.#baseServices,
|
|
@@ -657,7 +627,7 @@ export class FragmentDefinitionBuilder<
|
|
|
657
627
|
serviceDependencies: this.#serviceDependencies,
|
|
658
628
|
createRequestStorage: this.#createRequestStorage,
|
|
659
629
|
createThisContext: this.#createThisContext,
|
|
660
|
-
|
|
630
|
+
internalRoutes: this.#internalRoutes,
|
|
661
631
|
});
|
|
662
632
|
}
|
|
663
633
|
|
|
@@ -677,7 +647,7 @@ export class FragmentDefinitionBuilder<
|
|
|
677
647
|
TServiceThisContext,
|
|
678
648
|
THandlerThisContext,
|
|
679
649
|
TRequestStorage,
|
|
680
|
-
|
|
650
|
+
TInternalRoutes
|
|
681
651
|
> {
|
|
682
652
|
// Type assertion needed because TypeScript can't verify object spread with mapped types
|
|
683
653
|
const newServiceDependencies = {
|
|
@@ -698,7 +668,7 @@ export class FragmentDefinitionBuilder<
|
|
|
698
668
|
TServiceThisContext,
|
|
699
669
|
THandlerThisContext,
|
|
700
670
|
TRequestStorage,
|
|
701
|
-
|
|
671
|
+
TInternalRoutes
|
|
702
672
|
>(this.#name, {
|
|
703
673
|
dependencies: this.#dependencies,
|
|
704
674
|
baseServices: this.#baseServices,
|
|
@@ -707,7 +677,7 @@ export class FragmentDefinitionBuilder<
|
|
|
707
677
|
serviceDependencies: newServiceDependencies,
|
|
708
678
|
createRequestStorage: this.#createRequestStorage,
|
|
709
679
|
createThisContext: this.#createThisContext,
|
|
710
|
-
|
|
680
|
+
internalRoutes: this.#internalRoutes,
|
|
711
681
|
});
|
|
712
682
|
}
|
|
713
683
|
|
|
@@ -727,7 +697,7 @@ export class FragmentDefinitionBuilder<
|
|
|
727
697
|
TServiceThisContext,
|
|
728
698
|
THandlerThisContext,
|
|
729
699
|
TRequestStorage,
|
|
730
|
-
|
|
700
|
+
TInternalRoutes
|
|
731
701
|
> {
|
|
732
702
|
// Type assertion needed because TypeScript can't verify object spread with mapped types
|
|
733
703
|
const newServiceDependencies = {
|
|
@@ -750,7 +720,7 @@ export class FragmentDefinitionBuilder<
|
|
|
750
720
|
TServiceThisContext,
|
|
751
721
|
THandlerThisContext,
|
|
752
722
|
TRequestStorage,
|
|
753
|
-
|
|
723
|
+
TInternalRoutes
|
|
754
724
|
>(this.#name, {
|
|
755
725
|
dependencies: this.#dependencies,
|
|
756
726
|
baseServices: this.#baseServices,
|
|
@@ -759,7 +729,7 @@ export class FragmentDefinitionBuilder<
|
|
|
759
729
|
serviceDependencies: newServiceDependencies,
|
|
760
730
|
createRequestStorage: this.#createRequestStorage,
|
|
761
731
|
createThisContext: this.#createThisContext,
|
|
762
|
-
|
|
732
|
+
internalRoutes: this.#internalRoutes,
|
|
763
733
|
});
|
|
764
734
|
}
|
|
765
735
|
|
|
@@ -802,7 +772,7 @@ export class FragmentDefinitionBuilder<
|
|
|
802
772
|
TServiceThisContext,
|
|
803
773
|
THandlerThisContext,
|
|
804
774
|
TNewRequestStorage,
|
|
805
|
-
|
|
775
|
+
TInternalRoutes
|
|
806
776
|
> {
|
|
807
777
|
// getExternalStorage can coexist with createRequestStorage (they work together)
|
|
808
778
|
// Cast is safe when storage type changes: the external storage container adapts to hold the new type
|
|
@@ -825,7 +795,7 @@ export class FragmentDefinitionBuilder<
|
|
|
825
795
|
TServiceThisContext,
|
|
826
796
|
THandlerThisContext,
|
|
827
797
|
TNewRequestStorage,
|
|
828
|
-
|
|
798
|
+
TInternalRoutes
|
|
829
799
|
>(this.#name, {
|
|
830
800
|
dependencies: this.#dependencies,
|
|
831
801
|
baseServices: this.#baseServices,
|
|
@@ -836,7 +806,7 @@ export class FragmentDefinitionBuilder<
|
|
|
836
806
|
// Reset context function since storage type changed - it must be reconfigured
|
|
837
807
|
createThisContext: undefined,
|
|
838
808
|
getExternalStorage: preservedExternalStorage,
|
|
839
|
-
|
|
809
|
+
internalRoutes: this.#internalRoutes,
|
|
840
810
|
});
|
|
841
811
|
}
|
|
842
812
|
|
|
@@ -873,7 +843,7 @@ export class FragmentDefinitionBuilder<
|
|
|
873
843
|
TServiceThisContext,
|
|
874
844
|
THandlerThisContext,
|
|
875
845
|
TNewStorage,
|
|
876
|
-
|
|
846
|
+
TInternalRoutes
|
|
877
847
|
> {
|
|
878
848
|
return new FragmentDefinitionBuilder<
|
|
879
849
|
TConfig,
|
|
@@ -886,7 +856,7 @@ export class FragmentDefinitionBuilder<
|
|
|
886
856
|
TServiceThisContext,
|
|
887
857
|
THandlerThisContext,
|
|
888
858
|
TNewStorage,
|
|
889
|
-
|
|
859
|
+
TInternalRoutes
|
|
890
860
|
>(this.#name, {
|
|
891
861
|
dependencies: this.#dependencies,
|
|
892
862
|
baseServices: this.#baseServices,
|
|
@@ -897,7 +867,7 @@ export class FragmentDefinitionBuilder<
|
|
|
897
867
|
createRequestStorage: undefined,
|
|
898
868
|
createThisContext: undefined,
|
|
899
869
|
getExternalStorage: getStorage,
|
|
900
|
-
|
|
870
|
+
internalRoutes: this.#internalRoutes,
|
|
901
871
|
});
|
|
902
872
|
}
|
|
903
873
|
|
|
@@ -937,7 +907,7 @@ export class FragmentDefinitionBuilder<
|
|
|
937
907
|
TNewServiceThisContext,
|
|
938
908
|
TNewHandlerThisContext,
|
|
939
909
|
TRequestStorage,
|
|
940
|
-
|
|
910
|
+
TInternalRoutes
|
|
941
911
|
> {
|
|
942
912
|
return new FragmentDefinitionBuilder<
|
|
943
913
|
TConfig,
|
|
@@ -950,7 +920,7 @@ export class FragmentDefinitionBuilder<
|
|
|
950
920
|
TNewServiceThisContext,
|
|
951
921
|
TNewHandlerThisContext,
|
|
952
922
|
TRequestStorage,
|
|
953
|
-
|
|
923
|
+
TInternalRoutes
|
|
954
924
|
>(this.#name, {
|
|
955
925
|
dependencies: this.#dependencies,
|
|
956
926
|
baseServices: this.#baseServices,
|
|
@@ -960,21 +930,15 @@ export class FragmentDefinitionBuilder<
|
|
|
960
930
|
createRequestStorage: this.#createRequestStorage,
|
|
961
931
|
createThisContext: fn,
|
|
962
932
|
getExternalStorage: this.#getExternalStorage,
|
|
963
|
-
|
|
933
|
+
internalRoutes: this.#internalRoutes,
|
|
964
934
|
});
|
|
965
935
|
}
|
|
966
936
|
|
|
967
937
|
/**
|
|
968
|
-
*
|
|
969
|
-
* Linked fragments are service-only (no routes) and share the same config/options as the parent.
|
|
970
|
-
* All services from the linked fragment will be available as private services.
|
|
938
|
+
* Define internal routes that will be mounted under /_internal.
|
|
971
939
|
*/
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
TCallback extends LinkedFragmentCallback<TConfig, TOptions, TServiceDependencies>,
|
|
975
|
-
>(
|
|
976
|
-
name: TName,
|
|
977
|
-
callback: TCallback,
|
|
940
|
+
withInternalRoutes<const TNewInternalRoutes extends readonly AnyRouteOrFactory[]>(
|
|
941
|
+
routes: TNewInternalRoutes,
|
|
978
942
|
): FragmentDefinitionBuilder<
|
|
979
943
|
TConfig,
|
|
980
944
|
TOptions,
|
|
@@ -982,20 +946,12 @@ export class FragmentDefinitionBuilder<
|
|
|
982
946
|
TBaseServices,
|
|
983
947
|
TServices,
|
|
984
948
|
TServiceDependencies,
|
|
985
|
-
TPrivateServices
|
|
949
|
+
TPrivateServices,
|
|
986
950
|
TServiceThisContext,
|
|
987
951
|
THandlerThisContext,
|
|
988
952
|
TRequestStorage,
|
|
989
|
-
|
|
953
|
+
TNewInternalRoutes
|
|
990
954
|
> {
|
|
991
|
-
const newLinkedFragments = {
|
|
992
|
-
...this.#linkedFragments,
|
|
993
|
-
[name]: callback,
|
|
994
|
-
};
|
|
995
|
-
|
|
996
|
-
// Cast is safe: We're declaring that the returned builder has TPrivateServices & ExtractLinkedServices<TCallback>,
|
|
997
|
-
// even though the runtime privateServices hasn't changed yet. The linked fragment services will be
|
|
998
|
-
// merged into privateServices at instantiation time by the instantiator.
|
|
999
955
|
return new FragmentDefinitionBuilder(this.#name, {
|
|
1000
956
|
dependencies: this.#dependencies,
|
|
1001
957
|
baseServices: this.#baseServices,
|
|
@@ -1005,20 +961,8 @@ export class FragmentDefinitionBuilder<
|
|
|
1005
961
|
createRequestStorage: this.#createRequestStorage,
|
|
1006
962
|
createThisContext: this.#createThisContext,
|
|
1007
963
|
getExternalStorage: this.#getExternalStorage,
|
|
1008
|
-
|
|
1009
|
-
})
|
|
1010
|
-
TConfig,
|
|
1011
|
-
TOptions,
|
|
1012
|
-
TDeps,
|
|
1013
|
-
TBaseServices,
|
|
1014
|
-
TServices,
|
|
1015
|
-
TServiceDependencies,
|
|
1016
|
-
TPrivateServices & ExtractLinkedServices<TCallback>,
|
|
1017
|
-
TServiceThisContext,
|
|
1018
|
-
THandlerThisContext,
|
|
1019
|
-
TRequestStorage,
|
|
1020
|
-
TLinkedFragments & { [K in TName]: ReturnType<TCallback> }
|
|
1021
|
-
>;
|
|
964
|
+
internalRoutes: routes,
|
|
965
|
+
});
|
|
1022
966
|
}
|
|
1023
967
|
|
|
1024
968
|
/**
|
|
@@ -1043,7 +987,7 @@ export class FragmentDefinitionBuilder<
|
|
|
1043
987
|
TServiceThisContext,
|
|
1044
988
|
THandlerThisContext,
|
|
1045
989
|
TRequestStorage,
|
|
1046
|
-
|
|
990
|
+
TInternalRoutes
|
|
1047
991
|
> {
|
|
1048
992
|
return {
|
|
1049
993
|
name: this.#name,
|
|
@@ -1055,7 +999,7 @@ export class FragmentDefinitionBuilder<
|
|
|
1055
999
|
createRequestStorage: this.#createRequestStorage,
|
|
1056
1000
|
createThisContext: this.#createThisContext,
|
|
1057
1001
|
getExternalStorage: this.#getExternalStorage,
|
|
1058
|
-
|
|
1002
|
+
internalRoutes: this.#internalRoutes,
|
|
1059
1003
|
};
|
|
1060
1004
|
}
|
|
1061
1005
|
}
|
|
@@ -1082,7 +1026,7 @@ export function defineFragment<
|
|
|
1082
1026
|
TServiceThisContext,
|
|
1083
1027
|
THandlerThisContext,
|
|
1084
1028
|
TRequestStorage,
|
|
1085
|
-
|
|
1029
|
+
[]
|
|
1086
1030
|
> {
|
|
1087
1031
|
return new FragmentDefinitionBuilder(name);
|
|
1088
1032
|
}
|