@fragno-dev/core 0.2.0 → 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 +72 -62
- package/CHANGELOG.md +28 -0
- package/dist/api/api.d.ts +3 -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 +26 -44
- package/dist/api/fragment-definition-builder.d.ts.map +1 -1
- package/dist/api/fragment-definition-builder.js +15 -22
- package/dist/api/fragment-definition-builder.js.map +1 -1
- package/dist/api/fragment-instantiator.d.ts +51 -37
- package/dist/api/fragment-instantiator.d.ts.map +1 -1
- package/dist/api/fragment-instantiator.js +74 -69
- 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.map +1 -1
- package/dist/api/request-input-context.js.map +1 -1
- package/dist/api/request-middleware.d.ts +1 -1
- 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 +1 -1
- 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 +91 -52
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +25 -9
- 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 +7 -5
- package/dist/client/vue.d.ts.map +1 -1
- package/dist/client/vue.js +18 -10
- 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/mod-client.d.ts +5 -4
- package/dist/mod-client.d.ts.map +1 -1
- package/dist/mod-client.js +7 -5
- package/dist/mod-client.js.map +1 -1
- package/dist/mod.d.ts +6 -5
- package/dist/mod.js +2 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- 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 +24 -40
- package/src/api/api.test.ts +3 -1
- package/src/api/api.ts +6 -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 +49 -124
- package/src/api/fragment-instantiator.test.ts +92 -233
- package/src/api/fragment-instantiator.ts +228 -196
- package/src/api/fragment-services.test.ts +1 -0
- package/src/api/internal/path-runtime.test.ts +1 -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 +4 -2
- package/src/api/request-input-context.ts +2 -1
- package/src/api/request-middleware.test.ts +9 -14
- package/src/api/request-middleware.ts +3 -2
- 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 +2 -1
- 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 +49 -10
- package/src/client/client.ts +291 -141
- 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 +223 -84
- package/src/client/vue.ts +57 -30
- package/src/id.ts +1 -0
- package/src/internal/cuid.test.ts +164 -0
- package/src/internal/cuid.ts +133 -0
- package/src/mod-client.ts +4 -2
- package/src/mod.ts +3 -2
- package/src/runtime.ts +1 -1
- package/src/test/test.test.ts +4 -2
- package/src/test/test.ts +7 -9
- 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 +1 -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
|
-
TFragment extends AnyFragnoInstantiatedFragment = AnyFragnoInstantiatedFragment,
|
|
28
|
-
> = (context: {
|
|
29
|
-
config: TConfig;
|
|
30
|
-
options: TOptions;
|
|
31
|
-
serviceDependencies?: TServiceDependencies;
|
|
32
|
-
}) => TFragment;
|
|
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
|
|
|
@@ -230,26 +203,16 @@ export interface FragmentDefinition<
|
|
|
230
203
|
config: TConfig;
|
|
231
204
|
options: TOptions;
|
|
232
205
|
deps: TDeps;
|
|
233
|
-
|
|
206
|
+
services: BoundServices<TBaseServices & TServices>;
|
|
207
|
+
serviceDeps: TServiceDependencies;
|
|
234
208
|
}) => Record<string, unknown> | void;
|
|
235
209
|
|
|
236
|
-
|
|
237
|
-
* Optional linked fragments that will be automatically instantiated with this fragment.
|
|
238
|
-
* Linked fragments are service-only and share the same config/options as the parent.
|
|
239
|
-
*/
|
|
240
|
-
linkedFragments?: {
|
|
241
|
-
[K in keyof TLinkedFragments]: LinkedFragmentCallback<
|
|
242
|
-
TConfig,
|
|
243
|
-
TOptions,
|
|
244
|
-
TServiceDependencies,
|
|
245
|
-
TLinkedFragments[K]
|
|
246
|
-
>;
|
|
247
|
-
};
|
|
210
|
+
internalRoutes?: TInternalRoutes;
|
|
248
211
|
|
|
249
212
|
$serviceThisContext?: TServiceThisContext;
|
|
250
213
|
$handlerThisContext?: THandlerThisContext;
|
|
251
214
|
$requestStorage?: TRequestStorage;
|
|
252
|
-
$
|
|
215
|
+
$internalRoutes?: TInternalRoutes;
|
|
253
216
|
}
|
|
254
217
|
|
|
255
218
|
/**
|
|
@@ -267,7 +230,7 @@ export class FragmentDefinitionBuilder<
|
|
|
267
230
|
TServiceThisContext extends RequestThisContext,
|
|
268
231
|
THandlerThisContext extends RequestThisContext,
|
|
269
232
|
TRequestStorage = {},
|
|
270
|
-
|
|
233
|
+
TInternalRoutes extends readonly AnyRouteOrFactory[] = readonly [],
|
|
271
234
|
> {
|
|
272
235
|
#name: string;
|
|
273
236
|
#dependencies?: (context: { config: TConfig; options: TOptions }) => TDeps;
|
|
@@ -321,14 +284,7 @@ export class FragmentDefinitionBuilder<
|
|
|
321
284
|
options: TOptions;
|
|
322
285
|
deps: TDeps;
|
|
323
286
|
}) => RequestContextStorage<TRequestStorage>;
|
|
324
|
-
#
|
|
325
|
-
[K in keyof TLinkedFragments]: LinkedFragmentCallback<
|
|
326
|
-
TConfig,
|
|
327
|
-
TOptions,
|
|
328
|
-
TServiceDependencies,
|
|
329
|
-
TLinkedFragments[K]
|
|
330
|
-
>;
|
|
331
|
-
};
|
|
287
|
+
#internalRoutes?: TInternalRoutes;
|
|
332
288
|
|
|
333
289
|
constructor(
|
|
334
290
|
name: string,
|
|
@@ -384,14 +340,7 @@ export class FragmentDefinitionBuilder<
|
|
|
384
340
|
options: TOptions;
|
|
385
341
|
deps: TDeps;
|
|
386
342
|
}) => RequestContextStorage<TRequestStorage>;
|
|
387
|
-
|
|
388
|
-
[K in keyof TLinkedFragments]: LinkedFragmentCallback<
|
|
389
|
-
TConfig,
|
|
390
|
-
TOptions,
|
|
391
|
-
TServiceDependencies,
|
|
392
|
-
TLinkedFragments[K]
|
|
393
|
-
>;
|
|
394
|
-
};
|
|
343
|
+
internalRoutes?: TInternalRoutes;
|
|
395
344
|
},
|
|
396
345
|
) {
|
|
397
346
|
this.#name = name;
|
|
@@ -404,7 +353,7 @@ export class FragmentDefinitionBuilder<
|
|
|
404
353
|
this.#createRequestStorage = state.createRequestStorage;
|
|
405
354
|
this.#createThisContext = state.createThisContext;
|
|
406
355
|
this.#getExternalStorage = state.getExternalStorage;
|
|
407
|
-
this.#
|
|
356
|
+
this.#internalRoutes = state.internalRoutes;
|
|
408
357
|
}
|
|
409
358
|
}
|
|
410
359
|
|
|
@@ -447,7 +396,7 @@ export class FragmentDefinitionBuilder<
|
|
|
447
396
|
TServiceThisContext,
|
|
448
397
|
THandlerThisContext,
|
|
449
398
|
TRequestStorage,
|
|
450
|
-
|
|
399
|
+
TInternalRoutes
|
|
451
400
|
> {
|
|
452
401
|
// Warn if we're discarding existing configuration
|
|
453
402
|
if (
|
|
@@ -475,7 +424,7 @@ export class FragmentDefinitionBuilder<
|
|
|
475
424
|
TServiceThisContext,
|
|
476
425
|
THandlerThisContext,
|
|
477
426
|
TRequestStorage,
|
|
478
|
-
|
|
427
|
+
TInternalRoutes
|
|
479
428
|
>(this.#name, {
|
|
480
429
|
dependencies: fn,
|
|
481
430
|
baseServices: undefined,
|
|
@@ -486,7 +435,7 @@ export class FragmentDefinitionBuilder<
|
|
|
486
435
|
createRequestStorage: undefined,
|
|
487
436
|
createThisContext: undefined,
|
|
488
437
|
getExternalStorage: undefined,
|
|
489
|
-
|
|
438
|
+
internalRoutes: this.#internalRoutes,
|
|
490
439
|
});
|
|
491
440
|
}
|
|
492
441
|
|
|
@@ -515,7 +464,7 @@ export class FragmentDefinitionBuilder<
|
|
|
515
464
|
TServiceThisContext,
|
|
516
465
|
THandlerThisContext,
|
|
517
466
|
TRequestStorage,
|
|
518
|
-
|
|
467
|
+
TInternalRoutes
|
|
519
468
|
> {
|
|
520
469
|
return new FragmentDefinitionBuilder<
|
|
521
470
|
TConfig,
|
|
@@ -528,7 +477,7 @@ export class FragmentDefinitionBuilder<
|
|
|
528
477
|
TServiceThisContext,
|
|
529
478
|
THandlerThisContext,
|
|
530
479
|
TRequestStorage,
|
|
531
|
-
|
|
480
|
+
TInternalRoutes
|
|
532
481
|
>(this.#name, {
|
|
533
482
|
dependencies: this.#dependencies,
|
|
534
483
|
baseServices: fn,
|
|
@@ -538,7 +487,7 @@ export class FragmentDefinitionBuilder<
|
|
|
538
487
|
createRequestStorage: this.#createRequestStorage,
|
|
539
488
|
createThisContext: this.#createThisContext,
|
|
540
489
|
getExternalStorage: this.#getExternalStorage,
|
|
541
|
-
|
|
490
|
+
internalRoutes: this.#internalRoutes,
|
|
542
491
|
});
|
|
543
492
|
}
|
|
544
493
|
|
|
@@ -568,7 +517,7 @@ export class FragmentDefinitionBuilder<
|
|
|
568
517
|
TServiceThisContext,
|
|
569
518
|
THandlerThisContext,
|
|
570
519
|
TRequestStorage,
|
|
571
|
-
|
|
520
|
+
TInternalRoutes
|
|
572
521
|
> {
|
|
573
522
|
// Type assertion needed because TypeScript can't verify object spread with mapped types
|
|
574
523
|
const newNamedServices = {
|
|
@@ -597,7 +546,7 @@ export class FragmentDefinitionBuilder<
|
|
|
597
546
|
TServiceThisContext,
|
|
598
547
|
THandlerThisContext,
|
|
599
548
|
TRequestStorage,
|
|
600
|
-
|
|
549
|
+
TInternalRoutes
|
|
601
550
|
>(this.#name, {
|
|
602
551
|
dependencies: this.#dependencies,
|
|
603
552
|
baseServices: this.#baseServices,
|
|
@@ -607,7 +556,7 @@ export class FragmentDefinitionBuilder<
|
|
|
607
556
|
createRequestStorage: this.#createRequestStorage,
|
|
608
557
|
createThisContext: this.#createThisContext,
|
|
609
558
|
getExternalStorage: this.#getExternalStorage,
|
|
610
|
-
|
|
559
|
+
internalRoutes: this.#internalRoutes,
|
|
611
560
|
});
|
|
612
561
|
}
|
|
613
562
|
|
|
@@ -640,7 +589,7 @@ export class FragmentDefinitionBuilder<
|
|
|
640
589
|
TServiceThisContext,
|
|
641
590
|
THandlerThisContext,
|
|
642
591
|
TRequestStorage,
|
|
643
|
-
|
|
592
|
+
TInternalRoutes
|
|
644
593
|
> {
|
|
645
594
|
// Type assertion needed because TypeScript can't verify object spread with mapped types
|
|
646
595
|
const newPrivateServices = {
|
|
@@ -669,7 +618,7 @@ export class FragmentDefinitionBuilder<
|
|
|
669
618
|
TServiceThisContext,
|
|
670
619
|
THandlerThisContext,
|
|
671
620
|
TRequestStorage,
|
|
672
|
-
|
|
621
|
+
TInternalRoutes
|
|
673
622
|
>(this.#name, {
|
|
674
623
|
dependencies: this.#dependencies,
|
|
675
624
|
baseServices: this.#baseServices,
|
|
@@ -678,7 +627,7 @@ export class FragmentDefinitionBuilder<
|
|
|
678
627
|
serviceDependencies: this.#serviceDependencies,
|
|
679
628
|
createRequestStorage: this.#createRequestStorage,
|
|
680
629
|
createThisContext: this.#createThisContext,
|
|
681
|
-
|
|
630
|
+
internalRoutes: this.#internalRoutes,
|
|
682
631
|
});
|
|
683
632
|
}
|
|
684
633
|
|
|
@@ -698,7 +647,7 @@ export class FragmentDefinitionBuilder<
|
|
|
698
647
|
TServiceThisContext,
|
|
699
648
|
THandlerThisContext,
|
|
700
649
|
TRequestStorage,
|
|
701
|
-
|
|
650
|
+
TInternalRoutes
|
|
702
651
|
> {
|
|
703
652
|
// Type assertion needed because TypeScript can't verify object spread with mapped types
|
|
704
653
|
const newServiceDependencies = {
|
|
@@ -719,7 +668,7 @@ export class FragmentDefinitionBuilder<
|
|
|
719
668
|
TServiceThisContext,
|
|
720
669
|
THandlerThisContext,
|
|
721
670
|
TRequestStorage,
|
|
722
|
-
|
|
671
|
+
TInternalRoutes
|
|
723
672
|
>(this.#name, {
|
|
724
673
|
dependencies: this.#dependencies,
|
|
725
674
|
baseServices: this.#baseServices,
|
|
@@ -728,7 +677,7 @@ export class FragmentDefinitionBuilder<
|
|
|
728
677
|
serviceDependencies: newServiceDependencies,
|
|
729
678
|
createRequestStorage: this.#createRequestStorage,
|
|
730
679
|
createThisContext: this.#createThisContext,
|
|
731
|
-
|
|
680
|
+
internalRoutes: this.#internalRoutes,
|
|
732
681
|
});
|
|
733
682
|
}
|
|
734
683
|
|
|
@@ -748,7 +697,7 @@ export class FragmentDefinitionBuilder<
|
|
|
748
697
|
TServiceThisContext,
|
|
749
698
|
THandlerThisContext,
|
|
750
699
|
TRequestStorage,
|
|
751
|
-
|
|
700
|
+
TInternalRoutes
|
|
752
701
|
> {
|
|
753
702
|
// Type assertion needed because TypeScript can't verify object spread with mapped types
|
|
754
703
|
const newServiceDependencies = {
|
|
@@ -771,7 +720,7 @@ export class FragmentDefinitionBuilder<
|
|
|
771
720
|
TServiceThisContext,
|
|
772
721
|
THandlerThisContext,
|
|
773
722
|
TRequestStorage,
|
|
774
|
-
|
|
723
|
+
TInternalRoutes
|
|
775
724
|
>(this.#name, {
|
|
776
725
|
dependencies: this.#dependencies,
|
|
777
726
|
baseServices: this.#baseServices,
|
|
@@ -780,7 +729,7 @@ export class FragmentDefinitionBuilder<
|
|
|
780
729
|
serviceDependencies: newServiceDependencies,
|
|
781
730
|
createRequestStorage: this.#createRequestStorage,
|
|
782
731
|
createThisContext: this.#createThisContext,
|
|
783
|
-
|
|
732
|
+
internalRoutes: this.#internalRoutes,
|
|
784
733
|
});
|
|
785
734
|
}
|
|
786
735
|
|
|
@@ -823,7 +772,7 @@ export class FragmentDefinitionBuilder<
|
|
|
823
772
|
TServiceThisContext,
|
|
824
773
|
THandlerThisContext,
|
|
825
774
|
TNewRequestStorage,
|
|
826
|
-
|
|
775
|
+
TInternalRoutes
|
|
827
776
|
> {
|
|
828
777
|
// getExternalStorage can coexist with createRequestStorage (they work together)
|
|
829
778
|
// Cast is safe when storage type changes: the external storage container adapts to hold the new type
|
|
@@ -846,7 +795,7 @@ export class FragmentDefinitionBuilder<
|
|
|
846
795
|
TServiceThisContext,
|
|
847
796
|
THandlerThisContext,
|
|
848
797
|
TNewRequestStorage,
|
|
849
|
-
|
|
798
|
+
TInternalRoutes
|
|
850
799
|
>(this.#name, {
|
|
851
800
|
dependencies: this.#dependencies,
|
|
852
801
|
baseServices: this.#baseServices,
|
|
@@ -857,7 +806,7 @@ export class FragmentDefinitionBuilder<
|
|
|
857
806
|
// Reset context function since storage type changed - it must be reconfigured
|
|
858
807
|
createThisContext: undefined,
|
|
859
808
|
getExternalStorage: preservedExternalStorage,
|
|
860
|
-
|
|
809
|
+
internalRoutes: this.#internalRoutes,
|
|
861
810
|
});
|
|
862
811
|
}
|
|
863
812
|
|
|
@@ -894,7 +843,7 @@ export class FragmentDefinitionBuilder<
|
|
|
894
843
|
TServiceThisContext,
|
|
895
844
|
THandlerThisContext,
|
|
896
845
|
TNewStorage,
|
|
897
|
-
|
|
846
|
+
TInternalRoutes
|
|
898
847
|
> {
|
|
899
848
|
return new FragmentDefinitionBuilder<
|
|
900
849
|
TConfig,
|
|
@@ -907,7 +856,7 @@ export class FragmentDefinitionBuilder<
|
|
|
907
856
|
TServiceThisContext,
|
|
908
857
|
THandlerThisContext,
|
|
909
858
|
TNewStorage,
|
|
910
|
-
|
|
859
|
+
TInternalRoutes
|
|
911
860
|
>(this.#name, {
|
|
912
861
|
dependencies: this.#dependencies,
|
|
913
862
|
baseServices: this.#baseServices,
|
|
@@ -918,7 +867,7 @@ export class FragmentDefinitionBuilder<
|
|
|
918
867
|
createRequestStorage: undefined,
|
|
919
868
|
createThisContext: undefined,
|
|
920
869
|
getExternalStorage: getStorage,
|
|
921
|
-
|
|
870
|
+
internalRoutes: this.#internalRoutes,
|
|
922
871
|
});
|
|
923
872
|
}
|
|
924
873
|
|
|
@@ -958,7 +907,7 @@ export class FragmentDefinitionBuilder<
|
|
|
958
907
|
TNewServiceThisContext,
|
|
959
908
|
TNewHandlerThisContext,
|
|
960
909
|
TRequestStorage,
|
|
961
|
-
|
|
910
|
+
TInternalRoutes
|
|
962
911
|
> {
|
|
963
912
|
return new FragmentDefinitionBuilder<
|
|
964
913
|
TConfig,
|
|
@@ -971,7 +920,7 @@ export class FragmentDefinitionBuilder<
|
|
|
971
920
|
TNewServiceThisContext,
|
|
972
921
|
TNewHandlerThisContext,
|
|
973
922
|
TRequestStorage,
|
|
974
|
-
|
|
923
|
+
TInternalRoutes
|
|
975
924
|
>(this.#name, {
|
|
976
925
|
dependencies: this.#dependencies,
|
|
977
926
|
baseServices: this.#baseServices,
|
|
@@ -981,19 +930,15 @@ export class FragmentDefinitionBuilder<
|
|
|
981
930
|
createRequestStorage: this.#createRequestStorage,
|
|
982
931
|
createThisContext: fn,
|
|
983
932
|
getExternalStorage: this.#getExternalStorage,
|
|
984
|
-
|
|
933
|
+
internalRoutes: this.#internalRoutes,
|
|
985
934
|
});
|
|
986
935
|
}
|
|
987
936
|
|
|
988
937
|
/**
|
|
989
|
-
*
|
|
990
|
-
* Linked fragments share the same config/options as the parent and their services
|
|
991
|
-
* are exposed as private services. Routes are not exposed by default, but the
|
|
992
|
-
* instantiator may mount internal linked fragment routes under an internal prefix.
|
|
938
|
+
* Define internal routes that will be mounted under /_internal.
|
|
993
939
|
*/
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
callback: LinkedFragmentCallback<TConfig, TOptions, TServiceDependencies, TFragment>,
|
|
940
|
+
withInternalRoutes<const TNewInternalRoutes extends readonly AnyRouteOrFactory[]>(
|
|
941
|
+
routes: TNewInternalRoutes,
|
|
997
942
|
): FragmentDefinitionBuilder<
|
|
998
943
|
TConfig,
|
|
999
944
|
TOptions,
|
|
@@ -1001,20 +946,12 @@ export class FragmentDefinitionBuilder<
|
|
|
1001
946
|
TBaseServices,
|
|
1002
947
|
TServices,
|
|
1003
948
|
TServiceDependencies,
|
|
1004
|
-
TPrivateServices
|
|
949
|
+
TPrivateServices,
|
|
1005
950
|
TServiceThisContext,
|
|
1006
951
|
THandlerThisContext,
|
|
1007
952
|
TRequestStorage,
|
|
1008
|
-
|
|
953
|
+
TNewInternalRoutes
|
|
1009
954
|
> {
|
|
1010
|
-
const newLinkedFragments = {
|
|
1011
|
-
...this.#linkedFragments,
|
|
1012
|
-
[name]: callback,
|
|
1013
|
-
};
|
|
1014
|
-
|
|
1015
|
-
// Cast is safe: We're declaring that the returned builder has TPrivateServices & ExtractLinkedServices<TFragment>,
|
|
1016
|
-
// even though the runtime privateServices hasn't changed yet. The linked fragment services will be
|
|
1017
|
-
// merged into privateServices at instantiation time by the instantiator.
|
|
1018
955
|
return new FragmentDefinitionBuilder(this.#name, {
|
|
1019
956
|
dependencies: this.#dependencies,
|
|
1020
957
|
baseServices: this.#baseServices,
|
|
@@ -1024,20 +961,8 @@ export class FragmentDefinitionBuilder<
|
|
|
1024
961
|
createRequestStorage: this.#createRequestStorage,
|
|
1025
962
|
createThisContext: this.#createThisContext,
|
|
1026
963
|
getExternalStorage: this.#getExternalStorage,
|
|
1027
|
-
|
|
1028
|
-
})
|
|
1029
|
-
TConfig,
|
|
1030
|
-
TOptions,
|
|
1031
|
-
TDeps,
|
|
1032
|
-
TBaseServices,
|
|
1033
|
-
TServices,
|
|
1034
|
-
TServiceDependencies,
|
|
1035
|
-
TPrivateServices & ExtractLinkedServices<() => TFragment>,
|
|
1036
|
-
TServiceThisContext,
|
|
1037
|
-
THandlerThisContext,
|
|
1038
|
-
TRequestStorage,
|
|
1039
|
-
TLinkedFragments & { [K in TName]: TFragment }
|
|
1040
|
-
>;
|
|
964
|
+
internalRoutes: routes,
|
|
965
|
+
});
|
|
1041
966
|
}
|
|
1042
967
|
|
|
1043
968
|
/**
|
|
@@ -1062,7 +987,7 @@ export class FragmentDefinitionBuilder<
|
|
|
1062
987
|
TServiceThisContext,
|
|
1063
988
|
THandlerThisContext,
|
|
1064
989
|
TRequestStorage,
|
|
1065
|
-
|
|
990
|
+
TInternalRoutes
|
|
1066
991
|
> {
|
|
1067
992
|
return {
|
|
1068
993
|
name: this.#name,
|
|
@@ -1074,7 +999,7 @@ export class FragmentDefinitionBuilder<
|
|
|
1074
999
|
createRequestStorage: this.#createRequestStorage,
|
|
1075
1000
|
createThisContext: this.#createThisContext,
|
|
1076
1001
|
getExternalStorage: this.#getExternalStorage,
|
|
1077
|
-
|
|
1002
|
+
internalRoutes: this.#internalRoutes,
|
|
1078
1003
|
};
|
|
1079
1004
|
}
|
|
1080
1005
|
}
|
|
@@ -1101,7 +1026,7 @@ export function defineFragment<
|
|
|
1101
1026
|
TServiceThisContext,
|
|
1102
1027
|
THandlerThisContext,
|
|
1103
1028
|
TRequestStorage,
|
|
1104
|
-
|
|
1029
|
+
[]
|
|
1105
1030
|
> {
|
|
1106
1031
|
return new FragmentDefinitionBuilder(name);
|
|
1107
1032
|
}
|