@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,7 +1,8 @@
|
|
|
1
|
+
import { BoundServices } from "./bind-services.js";
|
|
2
|
+
import { RequestContextStorage } from "./request-context-storage.js";
|
|
3
|
+
import { AnyRouteOrFactory } from "./route.js";
|
|
1
4
|
import { FragnoPublicConfig } from "./shared-types.js";
|
|
2
5
|
import { RequestThisContext } from "./api.js";
|
|
3
|
-
import { RequestContextStorage } from "./request-context-storage.js";
|
|
4
|
-
import { AnyFragnoInstantiatedFragment, FragnoInstantiatedFragment } from "./fragment-instantiator.js";
|
|
5
6
|
|
|
6
7
|
//#region src/api/fragment-definition-builder.d.ts
|
|
7
8
|
|
|
@@ -14,19 +15,6 @@ interface ServiceMetadata {
|
|
|
14
15
|
/** Whether this service is required (false means optional) */
|
|
15
16
|
required: boolean;
|
|
16
17
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Callback that instantiates a linked fragment.
|
|
19
|
-
* Receives the same context as the main fragment and returns an instantiated fragment.
|
|
20
|
-
*/
|
|
21
|
-
type LinkedFragmentCallback<TConfig, TOptions extends FragnoPublicConfig, TServiceDependencies> = (context: {
|
|
22
|
-
config: TConfig;
|
|
23
|
-
options: TOptions;
|
|
24
|
-
serviceDependencies?: TServiceDependencies;
|
|
25
|
-
}) => FragnoInstantiatedFragment<any, any, any, any, any, any, any>;
|
|
26
|
-
/**
|
|
27
|
-
* Extract the services type from a FragnoInstantiatedFragment
|
|
28
|
-
*/
|
|
29
|
-
type ExtractLinkedServices<T> = T extends ((...args: never[]) => FragnoInstantiatedFragment<any, any, infer TServices, any, any, any, any>) ? TServices : never;
|
|
30
18
|
/**
|
|
31
19
|
* Context passed to the request context factory function.
|
|
32
20
|
*/
|
|
@@ -59,14 +47,14 @@ type ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPriva
|
|
|
59
47
|
* Fragment definition interface that supports both regular and database fragments.
|
|
60
48
|
* This is the core definition that will be used for fragment instantiation.
|
|
61
49
|
*/
|
|
62
|
-
interface FragmentDefinition<TConfig, TOptions extends FragnoPublicConfig, TDeps, TBaseServices, TServices
|
|
50
|
+
interface FragmentDefinition<TConfig, TOptions extends FragnoPublicConfig, TDeps, TBaseServices, TServices, TServiceDependencies, TPrivateServices, TServiceThisContext extends RequestThisContext, THandlerThisContext extends RequestThisContext, TRequestStorage = {}, TInternalRoutes extends readonly AnyRouteOrFactory[] = readonly []> {
|
|
63
51
|
name: string;
|
|
64
52
|
dependencies?: (context: {
|
|
65
53
|
config: TConfig;
|
|
66
54
|
options: TOptions;
|
|
67
55
|
}) => TDeps;
|
|
68
56
|
baseServices?: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TBaseServices, TServiceThisContext>;
|
|
69
|
-
namedServices?: { [K in keyof TServices
|
|
57
|
+
namedServices?: { [K in keyof TServices]: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TServices[K], TServiceThisContext> };
|
|
70
58
|
privateServices?: { [K in keyof TPrivateServices]: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices,
|
|
71
59
|
// Private services can access other private services
|
|
72
60
|
TPrivateServices[K], TServiceThisContext> };
|
|
@@ -126,20 +114,26 @@ interface FragmentDefinition<TConfig, TOptions extends FragnoPublicConfig, TDeps
|
|
|
126
114
|
deps: TDeps;
|
|
127
115
|
}) => RequestContextStorage<TRequestStorage>;
|
|
128
116
|
/**
|
|
129
|
-
* Optional
|
|
130
|
-
* Linked fragments are service-only and share the same config/options as the parent.
|
|
117
|
+
* Optional factory for internal data attached to fragment.$internal.
|
|
131
118
|
*/
|
|
132
|
-
|
|
119
|
+
internalDataFactory?: (context: {
|
|
120
|
+
config: TConfig;
|
|
121
|
+
options: TOptions;
|
|
122
|
+
deps: TDeps;
|
|
123
|
+
services: BoundServices<TBaseServices & TServices>;
|
|
124
|
+
serviceDeps: TServiceDependencies;
|
|
125
|
+
}) => Record<string, unknown> | void;
|
|
126
|
+
internalRoutes?: TInternalRoutes;
|
|
133
127
|
$serviceThisContext?: TServiceThisContext;
|
|
134
128
|
$handlerThisContext?: THandlerThisContext;
|
|
135
129
|
$requestStorage?: TRequestStorage;
|
|
136
|
-
$
|
|
130
|
+
$internalRoutes?: TInternalRoutes;
|
|
137
131
|
}
|
|
138
132
|
/**
|
|
139
133
|
* Builder class for creating fragment definitions.
|
|
140
134
|
* This provides a fluent API for defining fragments with type safety.
|
|
141
135
|
*/
|
|
142
|
-
declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicConfig, TDeps, TBaseServices, TServices
|
|
136
|
+
declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicConfig, TDeps, TBaseServices, TServices, TServiceDependencies, TPrivateServices, TServiceThisContext extends RequestThisContext, THandlerThisContext extends RequestThisContext, TRequestStorage = {}, TInternalRoutes extends readonly AnyRouteOrFactory[] = readonly []> {
|
|
143
137
|
#private;
|
|
144
138
|
constructor(name: string, state?: {
|
|
145
139
|
dependencies?: (context: {
|
|
@@ -147,7 +141,7 @@ declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicCo
|
|
|
147
141
|
options: TOptions;
|
|
148
142
|
}) => TDeps;
|
|
149
143
|
baseServices?: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TBaseServices, TServiceThisContext>;
|
|
150
|
-
namedServices?: { [K in keyof TServices
|
|
144
|
+
namedServices?: { [K in keyof TServices]: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TServices[K], TServiceThisContext> };
|
|
151
145
|
privateServices?: { [K in keyof TPrivateServices]: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TPrivateServices[K], TServiceThisContext> };
|
|
152
146
|
serviceDependencies?: { [K in keyof TServiceDependencies]: ServiceMetadata };
|
|
153
147
|
createRequestStorage?: (context: {
|
|
@@ -164,7 +158,7 @@ declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicCo
|
|
|
164
158
|
options: TOptions;
|
|
165
159
|
deps: TDeps;
|
|
166
160
|
}) => RequestContextStorage<TRequestStorage>;
|
|
167
|
-
|
|
161
|
+
internalRoutes?: TInternalRoutes;
|
|
168
162
|
});
|
|
169
163
|
get name(): string;
|
|
170
164
|
/**
|
|
@@ -192,17 +186,17 @@ declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicCo
|
|
|
192
186
|
withDependencies<TNewDeps>(fn: (context: {
|
|
193
187
|
config: TConfig;
|
|
194
188
|
options: TOptions;
|
|
195
|
-
}) => TNewDeps): FragmentDefinitionBuilder<TConfig, TOptions, TNewDeps, {}, {}, TServiceDependencies, {}, TServiceThisContext, THandlerThisContext, TRequestStorage,
|
|
189
|
+
}) => TNewDeps): FragmentDefinitionBuilder<TConfig, TOptions, TNewDeps, {}, {}, TServiceDependencies, {}, TServiceThisContext, THandlerThisContext, TRequestStorage, TInternalRoutes>;
|
|
196
190
|
/**
|
|
197
191
|
* Define base (unnamed) services for this fragment.
|
|
198
192
|
* Base services are accessible directly on the fragment instance.
|
|
199
193
|
*/
|
|
200
|
-
providesBaseService<TNewService>(fn: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TNewService, TServiceThisContext>): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TNewService, TServices
|
|
194
|
+
providesBaseService<TNewService>(fn: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TNewService, TServiceThisContext>): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TNewService, TServices, TServiceDependencies, TPrivateServices, TServiceThisContext, THandlerThisContext, TRequestStorage, TInternalRoutes>;
|
|
201
195
|
/**
|
|
202
196
|
* Provide a named service that other fragments or users can use.
|
|
203
197
|
* Named services are accessible as fragment.serviceName.method()
|
|
204
198
|
*/
|
|
205
|
-
providesService<TServiceName extends string, TService>(serviceName: TServiceName, fn: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TService, TServiceThisContext>): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices
|
|
199
|
+
providesService<TServiceName extends string, TService>(serviceName: TServiceName, fn: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TService, TServiceThisContext>): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices & { [K in TServiceName]: TService }, TServiceDependencies, TPrivateServices, TServiceThisContext, THandlerThisContext, TRequestStorage, TInternalRoutes>;
|
|
206
200
|
/**
|
|
207
201
|
* Provide a private service that is only accessible to the fragment author.
|
|
208
202
|
* Private services are NOT exposed on the fragment instance, but can be used
|
|
@@ -210,15 +204,15 @@ declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicCo
|
|
|
210
204
|
* Private services are instantiated in order, so earlier private services are available
|
|
211
205
|
* to later ones.
|
|
212
206
|
*/
|
|
213
|
-
providesPrivateService<TServiceName extends string, TService>(serviceName: TServiceName, fn: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TService, TServiceThisContext>): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices
|
|
207
|
+
providesPrivateService<TServiceName extends string, TService>(serviceName: TServiceName, fn: ServiceConstructorFn<TConfig, TOptions, TDeps, TServiceDependencies, TPrivateServices, TService, TServiceThisContext>): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices, TServiceDependencies, TPrivateServices & { [K in TServiceName]: TService }, TServiceThisContext, THandlerThisContext, TRequestStorage, TInternalRoutes>;
|
|
214
208
|
/**
|
|
215
209
|
* Declare that this fragment uses a required service provided by the runtime.
|
|
216
210
|
*/
|
|
217
|
-
usesService<TServiceName extends string, TService>(serviceName: TServiceName): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices
|
|
211
|
+
usesService<TServiceName extends string, TService>(serviceName: TServiceName): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices, TServiceDependencies & { [K in TServiceName]: TService }, TPrivateServices, TServiceThisContext, THandlerThisContext, TRequestStorage, TInternalRoutes>;
|
|
218
212
|
/**
|
|
219
213
|
* Declare that this fragment uses an optional service provided by the runtime.
|
|
220
214
|
*/
|
|
221
|
-
usesOptionalService<TServiceName extends string, TService>(serviceName: TServiceName): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices
|
|
215
|
+
usesOptionalService<TServiceName extends string, TService>(serviceName: TServiceName): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices, TServiceDependencies & { [K in TServiceName]: TService | undefined }, TPrivateServices, TServiceThisContext, THandlerThisContext, TRequestStorage, TInternalRoutes>;
|
|
222
216
|
/**
|
|
223
217
|
* Define the type and initial data stored in AsyncLocalStorage for per-request isolation.
|
|
224
218
|
* This should be called before withThisContext if you need to store request-specific data.
|
|
@@ -245,7 +239,7 @@ declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicCo
|
|
|
245
239
|
config: TConfig;
|
|
246
240
|
options: TOptions;
|
|
247
241
|
deps: TDeps;
|
|
248
|
-
}) => TNewRequestStorage): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices
|
|
242
|
+
}) => TNewRequestStorage): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices, TServiceDependencies, TPrivateServices, TServiceThisContext, THandlerThisContext, TNewRequestStorage, TInternalRoutes>;
|
|
249
243
|
/**
|
|
250
244
|
* Use an externally-provided RequestContextStorage instance.
|
|
251
245
|
* This allows multiple fragments to share the same storage instance.
|
|
@@ -266,7 +260,7 @@ declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicCo
|
|
|
266
260
|
config: TConfig;
|
|
267
261
|
options: TOptions;
|
|
268
262
|
deps: TDeps;
|
|
269
|
-
}) => RequestContextStorage<TNewStorage>): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices
|
|
263
|
+
}) => RequestContextStorage<TNewStorage>): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices, TServiceDependencies, TPrivateServices, TServiceThisContext, THandlerThisContext, TNewStorage, TInternalRoutes>;
|
|
270
264
|
/**
|
|
271
265
|
* Set the this contexts for services and handlers in this fragment.
|
|
272
266
|
* Both contexts should contain only methods or getters that read from storage.
|
|
@@ -287,13 +281,11 @@ declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicCo
|
|
|
287
281
|
withThisContext<TNewServiceThisContext extends RequestThisContext, TNewHandlerThisContext extends RequestThisContext>(fn: (context: RequestContextFactoryContext<TConfig, TOptions, TDeps, TRequestStorage>) => {
|
|
288
282
|
serviceContext: TNewServiceThisContext;
|
|
289
283
|
handlerContext: TNewHandlerThisContext;
|
|
290
|
-
}): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices
|
|
284
|
+
}): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices, TServiceDependencies, TPrivateServices, TNewServiceThisContext, TNewHandlerThisContext, TRequestStorage, TInternalRoutes>;
|
|
291
285
|
/**
|
|
292
|
-
*
|
|
293
|
-
* Linked fragments are service-only (no routes) and share the same config/options as the parent.
|
|
294
|
-
* All services from the linked fragment will be available as private services.
|
|
286
|
+
* Define internal routes that will be mounted under /_internal.
|
|
295
287
|
*/
|
|
296
|
-
|
|
288
|
+
withInternalRoutes<const TNewInternalRoutes extends readonly AnyRouteOrFactory[]>(routes: TNewInternalRoutes): FragmentDefinitionBuilder<TConfig, TOptions, TDeps, TBaseServices, TServices, TServiceDependencies, TPrivateServices, TServiceThisContext, THandlerThisContext, TRequestStorage, TNewInternalRoutes>;
|
|
297
289
|
/**
|
|
298
290
|
* Extend this builder with a transformation function.
|
|
299
291
|
* This enables fluent API extensions like `.extend(withDatabase(schema))`.
|
|
@@ -302,12 +294,12 @@ declare class FragmentDefinitionBuilder<TConfig, TOptions extends FragnoPublicCo
|
|
|
302
294
|
/**
|
|
303
295
|
* Build the final fragment definition
|
|
304
296
|
*/
|
|
305
|
-
build(): FragmentDefinition<TConfig, TOptions, TDeps, TBaseServices, TServices
|
|
297
|
+
build(): FragmentDefinition<TConfig, TOptions, TDeps, TBaseServices, TServices, TServiceDependencies, TPrivateServices, TServiceThisContext, THandlerThisContext, TRequestStorage, TInternalRoutes>;
|
|
306
298
|
}
|
|
307
299
|
/**
|
|
308
300
|
* Create a new fragment definition builder
|
|
309
301
|
*/
|
|
310
|
-
declare function defineFragment<TConfig = {}, TOptions extends FragnoPublicConfig = FragnoPublicConfig, TServiceThisContext extends RequestThisContext = RequestThisContext, THandlerThisContext extends RequestThisContext = RequestThisContext, TRequestStorage = {}>(name: string): FragmentDefinitionBuilder<TConfig, TOptions, {}, {}, {}, {}, {}, TServiceThisContext, THandlerThisContext, TRequestStorage,
|
|
302
|
+
declare function defineFragment<TConfig = {}, TOptions extends FragnoPublicConfig = FragnoPublicConfig, TServiceThisContext extends RequestThisContext = RequestThisContext, THandlerThisContext extends RequestThisContext = RequestThisContext, TRequestStorage = {}>(name: string): FragmentDefinitionBuilder<TConfig, TOptions, {}, {}, {}, {}, {}, TServiceThisContext, THandlerThisContext, TRequestStorage, []>;
|
|
311
303
|
//#endregion
|
|
312
|
-
export {
|
|
304
|
+
export { FragmentDefinition, FragmentDefinitionBuilder, RequestContextFactoryContext, ServiceConstructorFn, ServiceContext, defineFragment };
|
|
313
305
|
//# sourceMappingURL=fragment-definition-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fragment-definition-builder.d.ts","names":[],"sources":["../../src/api/fragment-definition-builder.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fragment-definition-builder.d.ts","names":[],"sources":["../../src/api/fragment-definition-builder.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;AAIyD;AAezD,UAVU,eAAA,CAUE;EAEO;EAIT,IAAA,EAAA,MAAA;EACC;EACH,QAAA,EAAA,OAAA;;;;AAOR;AAM8B,KArBlB,4BAqBkB,CAAA,OAAA,EAAA,iBAnBX,kBAmBW,EAAA,KAAA,EAAA,eAAA,CAAA,GAAA;EAEpB,MAAA,EAjBA,OAiBA;EACC,OAAA,EAjBA,QAiBA;EACH,IAAA,EAjBA,KAiBA;EACO,OAAA,EAjBJ,qBAiBI,CAjBkB,eAiBlB,CAAA;CACI;;;;AAK6C,KAjBpD,cAiBoD,CAAA,OAAA,EAAA,QAAA,EAAA,KAAA,EAAA,oBAAA,EAAA,gBAAA,EAAA,4BAXlC,kBAWkC,CAAA,GAAA;EAAC,MAAA,EATvD,OASuD;EAMrD,OAAA,EAdD,QAcC;EAOkB,IAAA,EApBtB,KAoBsB;EAG1B,WAAA,EAtBW,oBAsBX;EACA,eAAA,EAtBe,gBAsBf;EACA;;;;EAHO,aAAA,EAAA,CAAA,CAAA,CAAA,CAAA,GAAA,EAfe,CAef,GAfmB,QAenB,CAf4B,mBAe5B,CAAA,EAAA,GAfqD,CAerD;CAQN;;AAML;;AAQ8B,KA/BlB,oBA+BkB,CAAA,OAAA,EAAA,QAAA,EAAA,KAAA,EAAA,oBAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,4BAxBA,kBAwBA,CAAA,GAAA,CAAA,OAAA,EAtBnB,cAsBmB,CAr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;
|
|
14
14
|
#createThisContext;
|
|
15
15
|
#getExternalStorage;
|
|
16
|
-
#
|
|
16
|
+
#internalRoutes;
|
|
17
17
|
constructor(name, state) {
|
|
18
18
|
this.#name = name;
|
|
19
19
|
if (state) {
|
|
@@ -25,7 +25,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
25
25
|
this.#createRequestStorage = state.createRequestStorage;
|
|
26
26
|
this.#createThisContext = state.createThisContext;
|
|
27
27
|
this.#getExternalStorage = state.getExternalStorage;
|
|
28
|
-
this.#
|
|
28
|
+
this.#internalRoutes = state.internalRoutes;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
get name() {
|
|
@@ -64,7 +64,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
64
64
|
createRequestStorage: void 0,
|
|
65
65
|
createThisContext: void 0,
|
|
66
66
|
getExternalStorage: void 0,
|
|
67
|
-
|
|
67
|
+
internalRoutes: this.#internalRoutes
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
@@ -81,7 +81,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
81
81
|
createRequestStorage: this.#createRequestStorage,
|
|
82
82
|
createThisContext: this.#createThisContext,
|
|
83
83
|
getExternalStorage: this.#getExternalStorage,
|
|
84
|
-
|
|
84
|
+
internalRoutes: this.#internalRoutes
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
@@ -102,7 +102,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
102
102
|
createRequestStorage: this.#createRequestStorage,
|
|
103
103
|
createThisContext: this.#createThisContext,
|
|
104
104
|
getExternalStorage: this.#getExternalStorage,
|
|
105
|
-
|
|
105
|
+
internalRoutes: this.#internalRoutes
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
@@ -125,7 +125,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
125
125
|
serviceDependencies: this.#serviceDependencies,
|
|
126
126
|
createRequestStorage: this.#createRequestStorage,
|
|
127
127
|
createThisContext: this.#createThisContext,
|
|
128
|
-
|
|
128
|
+
internalRoutes: this.#internalRoutes
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
@@ -147,7 +147,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
147
147
|
serviceDependencies: newServiceDependencies,
|
|
148
148
|
createRequestStorage: this.#createRequestStorage,
|
|
149
149
|
createThisContext: this.#createThisContext,
|
|
150
|
-
|
|
150
|
+
internalRoutes: this.#internalRoutes
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
@@ -169,7 +169,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
169
169
|
serviceDependencies: newServiceDependencies,
|
|
170
170
|
createRequestStorage: this.#createRequestStorage,
|
|
171
171
|
createThisContext: this.#createThisContext,
|
|
172
|
-
|
|
172
|
+
internalRoutes: this.#internalRoutes
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
@@ -205,7 +205,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
205
205
|
createRequestStorage: initializer,
|
|
206
206
|
createThisContext: void 0,
|
|
207
207
|
getExternalStorage: preservedExternalStorage,
|
|
208
|
-
|
|
208
|
+
internalRoutes: this.#internalRoutes
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
211
|
/**
|
|
@@ -234,7 +234,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
234
234
|
createRequestStorage: void 0,
|
|
235
235
|
createThisContext: void 0,
|
|
236
236
|
getExternalStorage: getStorage,
|
|
237
|
-
|
|
237
|
+
internalRoutes: this.#internalRoutes
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
240
|
/**
|
|
@@ -264,19 +264,13 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
264
264
|
createRequestStorage: this.#createRequestStorage,
|
|
265
265
|
createThisContext: fn,
|
|
266
266
|
getExternalStorage: this.#getExternalStorage,
|
|
267
|
-
|
|
267
|
+
internalRoutes: this.#internalRoutes
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
270
|
/**
|
|
271
|
-
*
|
|
272
|
-
* Linked fragments are service-only (no routes) and share the same config/options as the parent.
|
|
273
|
-
* All services from the linked fragment will be available as private services.
|
|
271
|
+
* Define internal routes that will be mounted under /_internal.
|
|
274
272
|
*/
|
|
275
|
-
|
|
276
|
-
const newLinkedFragments = {
|
|
277
|
-
...this.#linkedFragments,
|
|
278
|
-
[name]: callback
|
|
279
|
-
};
|
|
273
|
+
withInternalRoutes(routes) {
|
|
280
274
|
return new FragmentDefinitionBuilder(this.#name, {
|
|
281
275
|
dependencies: this.#dependencies,
|
|
282
276
|
baseServices: this.#baseServices,
|
|
@@ -286,7 +280,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
286
280
|
createRequestStorage: this.#createRequestStorage,
|
|
287
281
|
createThisContext: this.#createThisContext,
|
|
288
282
|
getExternalStorage: this.#getExternalStorage,
|
|
289
|
-
|
|
283
|
+
internalRoutes: routes
|
|
290
284
|
});
|
|
291
285
|
}
|
|
292
286
|
/**
|
|
@@ -310,7 +304,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
|
|
|
310
304
|
createRequestStorage: this.#createRequestStorage,
|
|
311
305
|
createThisContext: this.#createThisContext,
|
|
312
306
|
getExternalStorage: this.#getExternalStorage,
|
|
313
|
-
|
|
307
|
+
internalRoutes: this.#internalRoutes
|
|
314
308
|
};
|
|
315
309
|
}
|
|
316
310
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fragment-definition-builder.js","names":["#name","#dependencies","#baseServices","#namedServices","#privateServices","#serviceDependencies","#createRequestStorage","#createThisContext","#getExternalStorage","#linkedFragments"],"sources":["../../src/api/fragment-definition-builder.ts"],"sourcesContent":["import type { RequestThisContext } from \"./api\";\nimport type { FragnoPublicConfig } from \"./shared-types\";\nimport type { RequestContextStorage } from \"./request-context-storage\";\nimport type {\n FragnoInstantiatedFragment,\n AnyFragnoInstantiatedFragment,\n} from \"./fragment-instantiator\";\n\n/**\n * Metadata for a service dependency\n */\ninterface ServiceMetadata {\n /** Name of the service */\n name: string;\n /** Whether this service is required (false means optional) */\n required: boolean;\n}\n\n/**\n * Callback that instantiates a linked fragment.\n * Receives the same context as the main fragment and returns an instantiated fragment.\n */\nexport type LinkedFragmentCallback<\n TConfig,\n TOptions extends FragnoPublicConfig,\n TServiceDependencies,\n> = (context: {\n config: TConfig;\n options: TOptions;\n serviceDependencies?: TServiceDependencies;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n}) => FragnoInstantiatedFragment<any, any, any, any, any, any, any>;\n\n/**\n * Extract the services type from a FragnoInstantiatedFragment\n */\nexport type ExtractLinkedServices<T> = T extends (\n ...args: never[]\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n) => FragnoInstantiatedFragment<any, any, infer TServices, any, any, any, any>\n ? TServices\n : never;\n\n/**\n * Context passed to the request context factory function.\n */\nexport type RequestContextFactoryContext<\n TConfig,\n TOptions extends FragnoPublicConfig,\n TDeps,\n TRequestStorage,\n> = {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n storage: RequestContextStorage<TRequestStorage>;\n};\n\n/**\n * Context object passed to service constructor functions\n */\nexport type ServiceContext<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext extends RequestThisContext,\n> = {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n serviceDeps: TServiceDependencies;\n privateServices: TPrivateServices;\n /**\n * Helper to define services with proper `this` context typing.\n * Use this to wrap your service methods when they need access to `this`.\n */\n defineService: <T>(svc: T & ThisType<TServiceThisContext>) => T;\n};\n\n/**\n * Service constructor function type\n */\nexport type ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TService,\n TServiceThisContext extends RequestThisContext,\n> = (\n context: ServiceContext<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext\n >,\n) => TService;\n\n/**\n * Fragment definition interface that supports both regular and database fragments.\n * This is the core definition that will be used for fragment instantiation.\n */\nexport interface FragmentDefinition<\n TConfig,\n TOptions extends FragnoPublicConfig,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext extends RequestThisContext,\n THandlerThisContext extends RequestThisContext,\n TRequestStorage = {},\n TLinkedFragments extends Record<string, AnyFragnoInstantiatedFragment> = {},\n> {\n name: string;\n\n // Core callbacks - all take context objects with separate deps and serviceDeps\n dependencies?: (context: { config: TConfig; options: TOptions }) => TDeps;\n\n baseServices?: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TBaseServices,\n TServiceThisContext\n >;\n\n // Named services stored as factory functions\n namedServices?: {\n [K in keyof TServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServices[K],\n TServiceThisContext\n >;\n };\n\n // Private services - only accessible internally when defining other services\n privateServices?: {\n [K in keyof TPrivateServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices, // Private services can access other private services\n TPrivateServices[K],\n TServiceThisContext\n >;\n };\n\n // Service dependency metadata\n serviceDependencies?: {\n [K in keyof TServiceDependencies]: ServiceMetadata;\n };\n\n /**\n * Optional factory function to create the initial request storage data.\n * This is called at the start of each request to initialize the storage.\n * The returned object can be mutated throughout the request lifecycle.\n *\n * @example\n * ```ts\n * createRequestStorage: ({ config, options, deps }) => ({\n * counter: 0,\n * userId: deps.currentUserId\n * })\n * ```\n */\n createRequestStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => TRequestStorage;\n\n /**\n * Optional factory function to create the this contexts for services and handlers.\n * Returns separate contexts: serviceContext (may be restricted) and handlerContext (full access).\n * Both contexts should contain only methods or getters that read from storage.\n *\n * @example\n * ```ts\n * createThisContext: ({ storage }) => ({\n * serviceContext: {\n * getUnitOfWork: () => restrictedUOW // Without execute methods\n * },\n * handlerContext: {\n * getUnitOfWork: () => fullUOW // With execute methods\n * }\n * })\n * ```\n */\n createThisContext?: (\n context: RequestContextFactoryContext<TConfig, TOptions, TDeps, TRequestStorage>,\n ) => {\n serviceContext: TServiceThisContext;\n handlerContext: THandlerThisContext;\n };\n\n /**\n * Optional factory function to get an external RequestContextStorage instance.\n * When provided, this storage will be used instead of creating a new one.\n * This allows multiple fragments to share the same storage (e.g., database fragments sharing adapter storage).\n *\n * @example\n * ```ts\n * getExternalStorage: ({ options }) => options.databaseAdapter.contextStorage\n * ```\n */\n getExternalStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TRequestStorage>;\n\n /**\n * Optional linked fragments that will be automatically instantiated with this fragment.\n * Linked fragments are service-only and share the same config/options as the parent.\n */\n linkedFragments?: {\n [K in keyof TLinkedFragments]: LinkedFragmentCallback<TConfig, TOptions, TServiceDependencies>;\n };\n\n $serviceThisContext?: TServiceThisContext;\n $handlerThisContext?: THandlerThisContext;\n $requestStorage?: TRequestStorage;\n $linkedFragments?: TLinkedFragments;\n}\n\n/**\n * Builder class for creating fragment definitions.\n * This provides a fluent API for defining fragments with type safety.\n */\nexport class FragmentDefinitionBuilder<\n TConfig,\n TOptions extends FragnoPublicConfig,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext extends RequestThisContext,\n THandlerThisContext extends RequestThisContext,\n TRequestStorage = {},\n TLinkedFragments extends Record<string, AnyFragnoInstantiatedFragment> = {},\n> {\n #name: string;\n #dependencies?: (context: { config: TConfig; options: TOptions }) => TDeps;\n #baseServices?: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TBaseServices,\n TServiceThisContext\n >;\n #namedServices?: {\n [K in keyof TServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServices[K],\n TServiceThisContext\n >;\n };\n #privateServices?: {\n [K in keyof TPrivateServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TPrivateServices[K],\n TServiceThisContext\n >;\n };\n #serviceDependencies?: {\n [K in keyof TServiceDependencies]: ServiceMetadata;\n };\n #createRequestStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => TRequestStorage;\n #createThisContext?: (\n context: RequestContextFactoryContext<TConfig, TOptions, TDeps, TRequestStorage>,\n ) => {\n serviceContext: TServiceThisContext;\n handlerContext: THandlerThisContext;\n };\n #getExternalStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TRequestStorage>;\n #linkedFragments?: {\n [K in keyof TLinkedFragments]: LinkedFragmentCallback<TConfig, TOptions, TServiceDependencies>;\n };\n\n constructor(\n name: string,\n state?: {\n dependencies?: (context: { config: TConfig; options: TOptions }) => TDeps;\n baseServices?: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TBaseServices,\n TServiceThisContext\n >;\n namedServices?: {\n [K in keyof TServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServices[K],\n TServiceThisContext\n >;\n };\n privateServices?: {\n [K in keyof TPrivateServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TPrivateServices[K],\n TServiceThisContext\n >;\n };\n serviceDependencies?: {\n [K in keyof TServiceDependencies]: ServiceMetadata;\n };\n createRequestStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => TRequestStorage;\n createThisContext?: (\n context: RequestContextFactoryContext<TConfig, TOptions, TDeps, TRequestStorage>,\n ) => {\n serviceContext: TServiceThisContext;\n handlerContext: THandlerThisContext;\n };\n getExternalStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TRequestStorage>;\n linkedFragments?: {\n [K in keyof TLinkedFragments]: LinkedFragmentCallback<\n TConfig,\n TOptions,\n TServiceDependencies\n >;\n };\n },\n ) {\n this.#name = name;\n if (state) {\n this.#dependencies = state.dependencies;\n this.#baseServices = state.baseServices;\n this.#namedServices = state.namedServices;\n this.#privateServices = state.privateServices;\n this.#serviceDependencies = state.serviceDependencies;\n this.#createRequestStorage = state.createRequestStorage;\n this.#createThisContext = state.createThisContext;\n this.#getExternalStorage = state.getExternalStorage;\n this.#linkedFragments = state.linkedFragments;\n }\n }\n\n get name(): string {\n return this.#name;\n }\n\n /**\n * Define dependencies for this fragment.\n * Dependencies are available to services and handlers.\n *\n * **IMPORTANT**: This method resets all services, storage, and context configurations.\n * Always call `withDependencies` early in the builder chain, before defining services\n * or request storage/context.\n *\n * @example\n * ```typescript\n * // ✅ GOOD: Dependencies set first\n * defineFragment(\"my-fragment\")\n * .withDependencies(() => ({ apiKey: \"...\" }))\n * .withRequestStorage(({ deps }) => ({ userId: deps.apiKey }))\n * .providesService(\"myService\", ...)\n *\n * // ❌ BAD: Dependencies set late (erases storage setup)\n * defineFragment(\"my-fragment\")\n * .withRequestStorage(() => ({ userId: \"...\" })) // This gets erased!\n * .withDependencies(() => ({ apiKey: \"...\" }))\n * ```\n */\n withDependencies<TNewDeps>(\n fn: (context: { config: TConfig; options: TOptions }) => TNewDeps,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TNewDeps,\n {},\n {},\n TServiceDependencies,\n {},\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n > {\n // Warn if we're discarding existing configuration\n if (\n this.#baseServices ||\n this.#namedServices ||\n this.#privateServices ||\n this.#createRequestStorage ||\n this.#createThisContext ||\n this.#getExternalStorage\n ) {\n console.warn(\n `[Fragno] Warning: withDependencies() on fragment \"${this.#name}\" is resetting previously configured services, request storage, or request context. ` +\n `To avoid this, call withDependencies() earlier in the builder chain, before configuring services or storage.`,\n );\n }\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TNewDeps,\n {},\n {},\n TServiceDependencies,\n {},\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n >(this.#name, {\n dependencies: fn,\n baseServices: undefined,\n namedServices: undefined,\n privateServices: undefined,\n serviceDependencies: this.#serviceDependencies,\n // Reset storage/context functions since deps type changed - they must be reconfigured\n createRequestStorage: undefined,\n createThisContext: undefined,\n getExternalStorage: undefined,\n linkedFragments: this.#linkedFragments,\n });\n }\n\n /**\n * Define base (unnamed) services for this fragment.\n * Base services are accessible directly on the fragment instance.\n */\n providesBaseService<TNewService>(\n fn: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TNewService,\n TServiceThisContext\n >,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TNewService,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n > {\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TNewService,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: fn,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n getExternalStorage: this.#getExternalStorage,\n linkedFragments: this.#linkedFragments,\n });\n }\n\n /**\n * Provide a named service that other fragments or users can use.\n * Named services are accessible as fragment.serviceName.method()\n */\n providesService<TServiceName extends string, TService>(\n serviceName: TServiceName,\n fn: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TService,\n TServiceThisContext\n >,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices & { [K in TServiceName]: TService },\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n > {\n // Type assertion needed because TypeScript can't verify object spread with mapped types\n const newNamedServices = {\n ...this.#namedServices,\n [serviceName]: fn,\n } as {\n [K in keyof (TServices & { [K in TServiceName]: TService })]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n (TServices & { [K in TServiceName]: TService })[K],\n TServiceThisContext\n >;\n };\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices & { [K in TServiceName]: TService },\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: newNamedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n getExternalStorage: this.#getExternalStorage,\n linkedFragments: this.#linkedFragments,\n });\n }\n\n /**\n * Provide a private service that is only accessible to the fragment author.\n * Private services are NOT exposed on the fragment instance, but can be used\n * when defining other services (baseServices, namedServices, and other privateServices).\n * Private services are instantiated in order, so earlier private services are available\n * to later ones.\n */\n providesPrivateService<TServiceName extends string, TService>(\n serviceName: TServiceName,\n fn: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TService,\n TServiceThisContext\n >,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices & { [K in TServiceName]: TService },\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n > {\n // Type assertion needed because TypeScript can't verify object spread with mapped types\n const newPrivateServices = {\n ...this.#privateServices,\n [serviceName]: fn,\n } as {\n [K in keyof (TPrivateServices & { [K in TServiceName]: TService })]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices & { [K in TServiceName]: TService },\n (TPrivateServices & { [K in TServiceName]: TService })[K],\n TServiceThisContext\n >;\n };\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices & { [K in TServiceName]: TService },\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: newPrivateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n linkedFragments: this.#linkedFragments,\n });\n }\n\n /**\n * Declare that this fragment uses a required service provided by the runtime.\n */\n usesService<TServiceName extends string, TService>(\n serviceName: TServiceName,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies & { [K in TServiceName]: TService },\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n > {\n // Type assertion needed because TypeScript can't verify object spread with mapped types\n const newServiceDependencies = {\n ...this.#serviceDependencies,\n [serviceName]: { name: serviceName, required: true },\n } as {\n [K in keyof (TServiceDependencies & { [K in TServiceName]: TService })]: ServiceMetadata;\n };\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies & { [K in TServiceName]: TService },\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: newServiceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n linkedFragments: this.#linkedFragments,\n });\n }\n\n /**\n * Declare that this fragment uses an optional service provided by the runtime.\n */\n usesOptionalService<TServiceName extends string, TService>(\n serviceName: TServiceName,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies & { [K in TServiceName]: TService | undefined },\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n > {\n // Type assertion needed because TypeScript can't verify object spread with mapped types\n const newServiceDependencies = {\n ...this.#serviceDependencies,\n [serviceName]: { name: serviceName, required: false },\n } as {\n [K in keyof (TServiceDependencies & {\n [K in TServiceName]: TService | undefined;\n })]: ServiceMetadata;\n };\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies & { [K in TServiceName]: TService | undefined },\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: newServiceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n linkedFragments: this.#linkedFragments,\n });\n }\n\n /**\n * Define the type and initial data stored in AsyncLocalStorage for per-request isolation.\n * This should be called before withThisContext if you need to store request-specific data.\n *\n * @param initializer Function that returns the initial storage data for each request\n *\n * @example\n * ```typescript\n * .withRequestStorage(({ config, options, deps }) => ({\n * counter: 0,\n * userId: deps.currentUserId\n * }))\n * .withThisContext(({ storage }) => ({\n * serviceContext: {\n * get counter() { return storage.getStore()!.counter; }\n * },\n * handlerContext: {\n * get counter() { return storage.getStore()!.counter; }\n * }\n * }))\n * ```\n */\n withRequestStorage<TNewRequestStorage>(\n initializer: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => TNewRequestStorage,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TNewRequestStorage,\n TLinkedFragments\n > {\n // getExternalStorage can coexist with createRequestStorage (they work together)\n // Cast is safe when storage type changes: the external storage container adapts to hold the new type\n const preservedExternalStorage = this.#getExternalStorage\n ? (this.#getExternalStorage as unknown as (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TNewRequestStorage>)\n : undefined;\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TNewRequestStorage,\n TLinkedFragments\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: initializer,\n // Reset context function since storage type changed - it must be reconfigured\n createThisContext: undefined,\n getExternalStorage: preservedExternalStorage,\n linkedFragments: this.#linkedFragments,\n });\n }\n\n /**\n * Use an externally-provided RequestContextStorage instance.\n * This allows multiple fragments to share the same storage instance.\n * Useful when fragments need to coordinate (e.g., database fragments sharing adapter storage).\n * Note: You must still call withRequestStorage to provide the initial storage data.\n *\n * @example\n * ```typescript\n * .withExternalRequestStorage(({ options }) =>\n * options.databaseAdapter.contextStorage\n * )\n * .withRequestStorage(({ options }) => ({\n * uow: options.databaseAdapter.db.createUnitOfWork()\n * }))\n * ```\n */\n withExternalRequestStorage<TNewStorage>(\n getStorage: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TNewStorage>,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TNewStorage,\n TLinkedFragments\n > {\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TNewStorage,\n TLinkedFragments\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n // Reset storage/context functions since storage type changed - they must be reconfigured\n createRequestStorage: undefined,\n createThisContext: undefined,\n getExternalStorage: getStorage,\n linkedFragments: this.#linkedFragments,\n });\n }\n\n /**\n * Set the this contexts for services and handlers in this fragment.\n * Both contexts should contain only methods or getters that read from storage.\n * This ensures proper per-request isolation via AsyncLocalStorage.\n *\n * @example\n * ```ts\n * .withThisContext(({ storage }) => ({\n * serviceContext: {\n * get myNumber() { return storage.getStore()?.myNumber ?? 0; }\n * },\n * handlerContext: {\n * get myNumber() { return storage.getStore()?.myNumber ?? 0; }\n * }\n * }))\n * ```\n */\n withThisContext<\n TNewServiceThisContext extends RequestThisContext,\n TNewHandlerThisContext extends RequestThisContext,\n >(\n fn: (context: RequestContextFactoryContext<TConfig, TOptions, TDeps, TRequestStorage>) => {\n serviceContext: TNewServiceThisContext;\n handlerContext: TNewHandlerThisContext;\n },\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TNewServiceThisContext,\n TNewHandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n > {\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TNewServiceThisContext,\n TNewHandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: fn,\n getExternalStorage: this.#getExternalStorage,\n linkedFragments: this.#linkedFragments,\n });\n }\n\n /**\n * Register a linked fragment that will be automatically instantiated.\n * Linked fragments are service-only (no routes) and share the same config/options as the parent.\n * All services from the linked fragment will be available as private services.\n */\n withLinkedFragment<\n const TName extends string,\n TCallback extends LinkedFragmentCallback<TConfig, TOptions, TServiceDependencies>,\n >(\n name: TName,\n callback: TCallback,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices & ExtractLinkedServices<TCallback>,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments & { [K in TName]: ReturnType<TCallback> }\n > {\n const newLinkedFragments = {\n ...this.#linkedFragments,\n [name]: callback,\n };\n\n // Cast is safe: We're declaring that the returned builder has TPrivateServices & ExtractLinkedServices<TCallback>,\n // even though the runtime privateServices hasn't changed yet. The linked fragment services will be\n // merged into privateServices at instantiation time by the instantiator.\n return new FragmentDefinitionBuilder(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n getExternalStorage: this.#getExternalStorage,\n linkedFragments: newLinkedFragments,\n }) as FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices & ExtractLinkedServices<TCallback>,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments & { [K in TName]: ReturnType<TCallback> }\n >;\n }\n\n /**\n * Extend this builder with a transformation function.\n * This enables fluent API extensions like `.extend(withDatabase(schema))`.\n */\n extend<const TNewBuilder>(transformer: (builder: this) => TNewBuilder): TNewBuilder {\n return transformer(this);\n }\n\n /**\n * Build the final fragment definition\n */\n build(): FragmentDefinition<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments\n > {\n return {\n name: this.#name,\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n getExternalStorage: this.#getExternalStorage,\n linkedFragments: this.#linkedFragments,\n };\n }\n}\n\n/**\n * Create a new fragment definition builder\n */\nexport function defineFragment<\n TConfig = {},\n TOptions extends FragnoPublicConfig = FragnoPublicConfig,\n TServiceThisContext extends RequestThisContext = RequestThisContext,\n THandlerThisContext extends RequestThisContext = RequestThisContext,\n TRequestStorage = {},\n>(\n name: string,\n): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n {},\n {},\n {},\n {},\n {},\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n {}\n> {\n return new FragmentDefinitionBuilder(name);\n}\n"],"mappings":";;;;;AAmPA,IAAa,4BAAb,MAAa,0BAYX;CACA;CACA;CACA;CASA;CAWA;CAWA;CAGA;CAKA;CAMA;CAKA;CAIA,YACE,MACA,OA4DA;AACA,QAAKA,OAAQ;AACb,MAAI,OAAO;AACT,SAAKC,eAAgB,MAAM;AAC3B,SAAKC,eAAgB,MAAM;AAC3B,SAAKC,gBAAiB,MAAM;AAC5B,SAAKC,kBAAmB,MAAM;AAC9B,SAAKC,sBAAuB,MAAM;AAClC,SAAKC,uBAAwB,MAAM;AACnC,SAAKC,oBAAqB,MAAM;AAChC,SAAKC,qBAAsB,MAAM;AACjC,SAAKC,kBAAmB,MAAM;;;CAIlC,IAAI,OAAe;AACj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B,MAAKI;GACvB,CAAC;;;;;;;;;;;;;;;;;;;CAoBJ,gBAIE,IAgBA;AACA,SAAO,IAAI,0BAYT,MAAKT,MAAO;GACZ,cAAc,MAAKC;GACnB,cAAc,MAAKC;GACnB,eAAe,MAAKC;GACpB,iBAAiB,MAAKC;GACtB,qBAAqB,MAAKC;GAC1B,sBAAsB,MAAKC;GAC3B,mBAAmB;GACnB,oBAAoB,MAAKE;GACzB,iBAAiB,MAAKC;GACvB,CAAC;;;;;;;CAQJ,mBAIE,MACA,UAaA;EACA,MAAM,qBAAqB;GACzB,GAAG,MAAKA;IACP,OAAO;GACT;AAKD,SAAO,IAAI,0BAA0B,MAAKT,MAAO;GAC/C,cAAc,MAAKC;GACnB,cAAc,MAAKC;GACnB,eAAe,MAAKC;GACpB,iBAAiB,MAAKC;GACtB,qBAAqB,MAAKC;GAC1B,sBAAsB,MAAKC;GAC3B,mBAAmB,MAAKC;GACxB,oBAAoB,MAAKC;GACzB,iBAAiB;GAClB,CAAC;;;;;;CAmBJ,OAA0B,aAA0D;AAClF,SAAO,YAAY,KAAK;;;;;CAM1B,QAYE;AACA,SAAO;GACL,MAAM,MAAKR;GACX,cAAc,MAAKC;GACnB,cAAc,MAAKC;GACnB,eAAe,MAAKC;GACpB,iBAAiB,MAAKC;GACtB,qBAAqB,MAAKC;GAC1B,sBAAsB,MAAKC;GAC3B,mBAAmB,MAAKC;GACxB,oBAAoB,MAAKC;GACzB,iBAAiB,MAAKC;GACvB;;;;;;AAOL,SAAgB,eAOd,MAaA;AACA,QAAO,IAAI,0BAA0B,KAAK"}
|
|
1
|
+
{"version":3,"file":"fragment-definition-builder.js","names":["#name","#dependencies","#baseServices","#namedServices","#privateServices","#serviceDependencies","#createRequestStorage","#createThisContext","#getExternalStorage","#internalRoutes"],"sources":["../../src/api/fragment-definition-builder.ts"],"sourcesContent":["import type { RequestThisContext } from \"./api\";\nimport type { BoundServices } from \"./bind-services\";\nimport type { RequestContextStorage } from \"./request-context-storage\";\nimport type { AnyRouteOrFactory } from \"./route\";\nimport type { FragnoPublicConfig } from \"./shared-types\";\n\n/**\n * Metadata for a service dependency\n */\ninterface ServiceMetadata {\n /** Name of the service */\n name: string;\n /** Whether this service is required (false means optional) */\n required: boolean;\n}\n\n/**\n * Context passed to the request context factory function.\n */\nexport type RequestContextFactoryContext<\n TConfig,\n TOptions extends FragnoPublicConfig,\n TDeps,\n TRequestStorage,\n> = {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n storage: RequestContextStorage<TRequestStorage>;\n};\n\n/**\n * Context object passed to service constructor functions\n */\nexport type ServiceContext<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext extends RequestThisContext,\n> = {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n serviceDeps: TServiceDependencies;\n privateServices: TPrivateServices;\n /**\n * Helper to define services with proper `this` context typing.\n * Use this to wrap your service methods when they need access to `this`.\n */\n defineService: <T>(svc: T & ThisType<TServiceThisContext>) => T;\n};\n\n/**\n * Service constructor function type\n */\nexport type ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TService,\n TServiceThisContext extends RequestThisContext,\n> = (\n context: ServiceContext<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext\n >,\n) => TService;\n\n/**\n * Fragment definition interface that supports both regular and database fragments.\n * This is the core definition that will be used for fragment instantiation.\n */\nexport interface FragmentDefinition<\n TConfig,\n TOptions extends FragnoPublicConfig,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext extends RequestThisContext,\n THandlerThisContext extends RequestThisContext,\n TRequestStorage = {},\n TInternalRoutes extends readonly AnyRouteOrFactory[] = readonly [],\n> {\n name: string;\n\n // Core callbacks - all take context objects with separate deps and serviceDeps\n dependencies?: (context: { config: TConfig; options: TOptions }) => TDeps;\n\n baseServices?: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TBaseServices,\n TServiceThisContext\n >;\n\n // Named services stored as factory functions\n namedServices?: {\n [K in keyof TServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServices[K],\n TServiceThisContext\n >;\n };\n\n // Private services - only accessible internally when defining other services\n privateServices?: {\n [K in keyof TPrivateServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices, // Private services can access other private services\n TPrivateServices[K],\n TServiceThisContext\n >;\n };\n\n // Service dependency metadata\n serviceDependencies?: {\n [K in keyof TServiceDependencies]: ServiceMetadata;\n };\n\n /**\n * Optional factory function to create the initial request storage data.\n * This is called at the start of each request to initialize the storage.\n * The returned object can be mutated throughout the request lifecycle.\n *\n * @example\n * ```ts\n * createRequestStorage: ({ config, options, deps }) => ({\n * counter: 0,\n * userId: deps.currentUserId\n * })\n * ```\n */\n createRequestStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => TRequestStorage;\n\n /**\n * Optional factory function to create the this contexts for services and handlers.\n * Returns separate contexts: serviceContext (may be restricted) and handlerContext (full access).\n * Both contexts should contain only methods or getters that read from storage.\n *\n * @example\n * ```ts\n * createThisContext: ({ storage }) => ({\n * serviceContext: {\n * getUnitOfWork: () => restrictedUOW // Without execute methods\n * },\n * handlerContext: {\n * getUnitOfWork: () => fullUOW // With execute methods\n * }\n * })\n * ```\n */\n createThisContext?: (\n context: RequestContextFactoryContext<TConfig, TOptions, TDeps, TRequestStorage>,\n ) => {\n serviceContext: TServiceThisContext;\n handlerContext: THandlerThisContext;\n };\n\n /**\n * Optional factory function to get an external RequestContextStorage instance.\n * When provided, this storage will be used instead of creating a new one.\n * This allows multiple fragments to share the same storage (e.g., database fragments sharing adapter storage).\n *\n * @example\n * ```ts\n * getExternalStorage: ({ options }) => options.databaseAdapter.contextStorage\n * ```\n */\n getExternalStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TRequestStorage>;\n\n /**\n * Optional factory for internal data attached to fragment.$internal.\n */\n internalDataFactory?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n services: BoundServices<TBaseServices & TServices>;\n serviceDeps: TServiceDependencies;\n }) => Record<string, unknown> | void;\n\n internalRoutes?: TInternalRoutes;\n\n $serviceThisContext?: TServiceThisContext;\n $handlerThisContext?: THandlerThisContext;\n $requestStorage?: TRequestStorage;\n $internalRoutes?: TInternalRoutes;\n}\n\n/**\n * Builder class for creating fragment definitions.\n * This provides a fluent API for defining fragments with type safety.\n */\nexport class FragmentDefinitionBuilder<\n TConfig,\n TOptions extends FragnoPublicConfig,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext extends RequestThisContext,\n THandlerThisContext extends RequestThisContext,\n TRequestStorage = {},\n TInternalRoutes extends readonly AnyRouteOrFactory[] = readonly [],\n> {\n #name: string;\n #dependencies?: (context: { config: TConfig; options: TOptions }) => TDeps;\n #baseServices?: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TBaseServices,\n TServiceThisContext\n >;\n #namedServices?: {\n [K in keyof TServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServices[K],\n TServiceThisContext\n >;\n };\n #privateServices?: {\n [K in keyof TPrivateServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TPrivateServices[K],\n TServiceThisContext\n >;\n };\n #serviceDependencies?: {\n [K in keyof TServiceDependencies]: ServiceMetadata;\n };\n #createRequestStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => TRequestStorage;\n #createThisContext?: (\n context: RequestContextFactoryContext<TConfig, TOptions, TDeps, TRequestStorage>,\n ) => {\n serviceContext: TServiceThisContext;\n handlerContext: THandlerThisContext;\n };\n #getExternalStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TRequestStorage>;\n #internalRoutes?: TInternalRoutes;\n\n constructor(\n name: string,\n state?: {\n dependencies?: (context: { config: TConfig; options: TOptions }) => TDeps;\n baseServices?: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TBaseServices,\n TServiceThisContext\n >;\n namedServices?: {\n [K in keyof TServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TServices[K],\n TServiceThisContext\n >;\n };\n privateServices?: {\n [K in keyof TPrivateServices]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TPrivateServices[K],\n TServiceThisContext\n >;\n };\n serviceDependencies?: {\n [K in keyof TServiceDependencies]: ServiceMetadata;\n };\n createRequestStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => TRequestStorage;\n createThisContext?: (\n context: RequestContextFactoryContext<TConfig, TOptions, TDeps, TRequestStorage>,\n ) => {\n serviceContext: TServiceThisContext;\n handlerContext: THandlerThisContext;\n };\n getExternalStorage?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TRequestStorage>;\n internalRoutes?: TInternalRoutes;\n },\n ) {\n this.#name = name;\n if (state) {\n this.#dependencies = state.dependencies;\n this.#baseServices = state.baseServices;\n this.#namedServices = state.namedServices;\n this.#privateServices = state.privateServices;\n this.#serviceDependencies = state.serviceDependencies;\n this.#createRequestStorage = state.createRequestStorage;\n this.#createThisContext = state.createThisContext;\n this.#getExternalStorage = state.getExternalStorage;\n this.#internalRoutes = state.internalRoutes;\n }\n }\n\n get name(): string {\n return this.#name;\n }\n\n /**\n * Define dependencies for this fragment.\n * Dependencies are available to services and handlers.\n *\n * **IMPORTANT**: This method resets all services, storage, and context configurations.\n * Always call `withDependencies` early in the builder chain, before defining services\n * or request storage/context.\n *\n * @example\n * ```typescript\n * // ✅ GOOD: Dependencies set first\n * defineFragment(\"my-fragment\")\n * .withDependencies(() => ({ apiKey: \"...\" }))\n * .withRequestStorage(({ deps }) => ({ userId: deps.apiKey }))\n * .providesService(\"myService\", ...)\n *\n * // ❌ BAD: Dependencies set late (erases storage setup)\n * defineFragment(\"my-fragment\")\n * .withRequestStorage(() => ({ userId: \"...\" })) // This gets erased!\n * .withDependencies(() => ({ apiKey: \"...\" }))\n * ```\n */\n withDependencies<TNewDeps>(\n fn: (context: { config: TConfig; options: TOptions }) => TNewDeps,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TNewDeps,\n {},\n {},\n TServiceDependencies,\n {},\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n > {\n // Warn if we're discarding existing configuration\n if (\n this.#baseServices ||\n this.#namedServices ||\n this.#privateServices ||\n this.#createRequestStorage ||\n this.#createThisContext ||\n this.#getExternalStorage\n ) {\n console.warn(\n `[Fragno] Warning: withDependencies() on fragment \"${this.#name}\" is resetting previously configured services, request storage, or request context. ` +\n `To avoid this, call withDependencies() earlier in the builder chain, before configuring services or storage.`,\n );\n }\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TNewDeps,\n {},\n {},\n TServiceDependencies,\n {},\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n >(this.#name, {\n dependencies: fn,\n baseServices: undefined,\n namedServices: undefined,\n privateServices: undefined,\n serviceDependencies: this.#serviceDependencies,\n // Reset storage/context functions since deps type changed - they must be reconfigured\n createRequestStorage: undefined,\n createThisContext: undefined,\n getExternalStorage: undefined,\n internalRoutes: this.#internalRoutes,\n });\n }\n\n /**\n * Define base (unnamed) services for this fragment.\n * Base services are accessible directly on the fragment instance.\n */\n providesBaseService<TNewService>(\n fn: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TNewService,\n TServiceThisContext\n >,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TNewService,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n > {\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TNewService,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: fn,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n getExternalStorage: this.#getExternalStorage,\n internalRoutes: this.#internalRoutes,\n });\n }\n\n /**\n * Provide a named service that other fragments or users can use.\n * Named services are accessible as fragment.serviceName.method()\n */\n providesService<TServiceName extends string, TService>(\n serviceName: TServiceName,\n fn: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TService,\n TServiceThisContext\n >,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices & { [K in TServiceName]: TService },\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n > {\n // Type assertion needed because TypeScript can't verify object spread with mapped types\n const newNamedServices = {\n ...this.#namedServices,\n [serviceName]: fn,\n } as {\n [K in keyof (TServices & { [K in TServiceName]: TService })]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n (TServices & { [K in TServiceName]: TService })[K],\n TServiceThisContext\n >;\n };\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices & { [K in TServiceName]: TService },\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: newNamedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n getExternalStorage: this.#getExternalStorage,\n internalRoutes: this.#internalRoutes,\n });\n }\n\n /**\n * Provide a private service that is only accessible to the fragment author.\n * Private services are NOT exposed on the fragment instance, but can be used\n * when defining other services (baseServices, namedServices, and other privateServices).\n * Private services are instantiated in order, so earlier private services are available\n * to later ones.\n */\n providesPrivateService<TServiceName extends string, TService>(\n serviceName: TServiceName,\n fn: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices,\n TService,\n TServiceThisContext\n >,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices & { [K in TServiceName]: TService },\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n > {\n // Type assertion needed because TypeScript can't verify object spread with mapped types\n const newPrivateServices = {\n ...this.#privateServices,\n [serviceName]: fn,\n } as {\n [K in keyof (TPrivateServices & { [K in TServiceName]: TService })]: ServiceConstructorFn<\n TConfig,\n TOptions,\n TDeps,\n TServiceDependencies,\n TPrivateServices & { [K in TServiceName]: TService },\n (TPrivateServices & { [K in TServiceName]: TService })[K],\n TServiceThisContext\n >;\n };\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices & { [K in TServiceName]: TService },\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: newPrivateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n internalRoutes: this.#internalRoutes,\n });\n }\n\n /**\n * Declare that this fragment uses a required service provided by the runtime.\n */\n usesService<TServiceName extends string, TService>(\n serviceName: TServiceName,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies & { [K in TServiceName]: TService },\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n > {\n // Type assertion needed because TypeScript can't verify object spread with mapped types\n const newServiceDependencies = {\n ...this.#serviceDependencies,\n [serviceName]: { name: serviceName, required: true },\n } as {\n [K in keyof (TServiceDependencies & { [K in TServiceName]: TService })]: ServiceMetadata;\n };\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies & { [K in TServiceName]: TService },\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: newServiceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n internalRoutes: this.#internalRoutes,\n });\n }\n\n /**\n * Declare that this fragment uses an optional service provided by the runtime.\n */\n usesOptionalService<TServiceName extends string, TService>(\n serviceName: TServiceName,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies & { [K in TServiceName]: TService | undefined },\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n > {\n // Type assertion needed because TypeScript can't verify object spread with mapped types\n const newServiceDependencies = {\n ...this.#serviceDependencies,\n [serviceName]: { name: serviceName, required: false },\n } as {\n [K in keyof (TServiceDependencies & {\n [K in TServiceName]: TService | undefined;\n })]: ServiceMetadata;\n };\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies & { [K in TServiceName]: TService | undefined },\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: newServiceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n internalRoutes: this.#internalRoutes,\n });\n }\n\n /**\n * Define the type and initial data stored in AsyncLocalStorage for per-request isolation.\n * This should be called before withThisContext if you need to store request-specific data.\n *\n * @param initializer Function that returns the initial storage data for each request\n *\n * @example\n * ```typescript\n * .withRequestStorage(({ config, options, deps }) => ({\n * counter: 0,\n * userId: deps.currentUserId\n * }))\n * .withThisContext(({ storage }) => ({\n * serviceContext: {\n * get counter() { return storage.getStore()!.counter; }\n * },\n * handlerContext: {\n * get counter() { return storage.getStore()!.counter; }\n * }\n * }))\n * ```\n */\n withRequestStorage<TNewRequestStorage>(\n initializer: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => TNewRequestStorage,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TNewRequestStorage,\n TInternalRoutes\n > {\n // getExternalStorage can coexist with createRequestStorage (they work together)\n // Cast is safe when storage type changes: the external storage container adapts to hold the new type\n const preservedExternalStorage = this.#getExternalStorage\n ? (this.#getExternalStorage as unknown as (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TNewRequestStorage>)\n : undefined;\n\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TNewRequestStorage,\n TInternalRoutes\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: initializer,\n // Reset context function since storage type changed - it must be reconfigured\n createThisContext: undefined,\n getExternalStorage: preservedExternalStorage,\n internalRoutes: this.#internalRoutes,\n });\n }\n\n /**\n * Use an externally-provided RequestContextStorage instance.\n * This allows multiple fragments to share the same storage instance.\n * Useful when fragments need to coordinate (e.g., database fragments sharing adapter storage).\n * Note: You must still call withRequestStorage to provide the initial storage data.\n *\n * @example\n * ```typescript\n * .withExternalRequestStorage(({ options }) =>\n * options.databaseAdapter.contextStorage\n * )\n * .withRequestStorage(({ options }) => ({\n * uow: options.databaseAdapter.db.createUnitOfWork()\n * }))\n * ```\n */\n withExternalRequestStorage<TNewStorage>(\n getStorage: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n }) => RequestContextStorage<TNewStorage>,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TNewStorage,\n TInternalRoutes\n > {\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TNewStorage,\n TInternalRoutes\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n // Reset storage/context functions since storage type changed - they must be reconfigured\n createRequestStorage: undefined,\n createThisContext: undefined,\n getExternalStorage: getStorage,\n internalRoutes: this.#internalRoutes,\n });\n }\n\n /**\n * Set the this contexts for services and handlers in this fragment.\n * Both contexts should contain only methods or getters that read from storage.\n * This ensures proper per-request isolation via AsyncLocalStorage.\n *\n * @example\n * ```ts\n * .withThisContext(({ storage }) => ({\n * serviceContext: {\n * get myNumber() { return storage.getStore()?.myNumber ?? 0; }\n * },\n * handlerContext: {\n * get myNumber() { return storage.getStore()?.myNumber ?? 0; }\n * }\n * }))\n * ```\n */\n withThisContext<\n TNewServiceThisContext extends RequestThisContext,\n TNewHandlerThisContext extends RequestThisContext,\n >(\n fn: (context: RequestContextFactoryContext<TConfig, TOptions, TDeps, TRequestStorage>) => {\n serviceContext: TNewServiceThisContext;\n handlerContext: TNewHandlerThisContext;\n },\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TNewServiceThisContext,\n TNewHandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n > {\n return new FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TNewServiceThisContext,\n TNewHandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n >(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: fn,\n getExternalStorage: this.#getExternalStorage,\n internalRoutes: this.#internalRoutes,\n });\n }\n\n /**\n * Define internal routes that will be mounted under /_internal.\n */\n withInternalRoutes<const TNewInternalRoutes extends readonly AnyRouteOrFactory[]>(\n routes: TNewInternalRoutes,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TNewInternalRoutes\n > {\n return new FragmentDefinitionBuilder(this.#name, {\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n getExternalStorage: this.#getExternalStorage,\n internalRoutes: routes,\n });\n }\n\n /**\n * Extend this builder with a transformation function.\n * This enables fluent API extensions like `.extend(withDatabase(schema))`.\n */\n extend<const TNewBuilder>(transformer: (builder: this) => TNewBuilder): TNewBuilder {\n return transformer(this);\n }\n\n /**\n * Build the final fragment definition\n */\n build(): FragmentDefinition<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TInternalRoutes\n > {\n return {\n name: this.#name,\n dependencies: this.#dependencies,\n baseServices: this.#baseServices,\n namedServices: this.#namedServices,\n privateServices: this.#privateServices,\n serviceDependencies: this.#serviceDependencies,\n createRequestStorage: this.#createRequestStorage,\n createThisContext: this.#createThisContext,\n getExternalStorage: this.#getExternalStorage,\n internalRoutes: this.#internalRoutes,\n };\n }\n}\n\n/**\n * Create a new fragment definition builder\n */\nexport function defineFragment<\n TConfig = {},\n TOptions extends FragnoPublicConfig = FragnoPublicConfig,\n TServiceThisContext extends RequestThisContext = RequestThisContext,\n THandlerThisContext extends RequestThisContext = RequestThisContext,\n TRequestStorage = {},\n>(\n name: string,\n): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n {},\n {},\n {},\n {},\n {},\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n []\n> {\n return new FragmentDefinitionBuilder(name);\n}\n"],"mappings":";;;;;AA6NA,IAAa,4BAAb,MAAa,0BAYX;CACA;CACA;CACA;CASA;CAWA;CAWA;CAGA;CAKA;CAMA;CAKA;CAEA,YACE,MACA,OAsDA;AACA,QAAKA,OAAQ;AACb,MAAI,OAAO;AACT,SAAKC,eAAgB,MAAM;AAC3B,SAAKC,eAAgB,MAAM;AAC3B,SAAKC,gBAAiB,MAAM;AAC5B,SAAKC,kBAAmB,MAAM;AAC9B,SAAKC,sBAAuB,MAAM;AAClC,SAAKC,uBAAwB,MAAM;AACnC,SAAKC,oBAAqB,MA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