@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.
Files changed (146) hide show
  1. package/.turbo/turbo-build.log +72 -62
  2. package/CHANGELOG.md +28 -0
  3. package/dist/api/api.d.ts +3 -2
  4. package/dist/api/api.d.ts.map +1 -1
  5. package/dist/api/api.js +2 -1
  6. package/dist/api/api.js.map +1 -1
  7. package/dist/api/bind-services.d.ts +0 -1
  8. package/dist/api/bind-services.d.ts.map +1 -1
  9. package/dist/api/bind-services.js.map +1 -1
  10. package/dist/api/error.d.ts.map +1 -1
  11. package/dist/api/error.js.map +1 -1
  12. package/dist/api/fragment-definition-builder.d.ts +26 -44
  13. package/dist/api/fragment-definition-builder.d.ts.map +1 -1
  14. package/dist/api/fragment-definition-builder.js +15 -22
  15. package/dist/api/fragment-definition-builder.js.map +1 -1
  16. package/dist/api/fragment-instantiator.d.ts +51 -37
  17. package/dist/api/fragment-instantiator.d.ts.map +1 -1
  18. package/dist/api/fragment-instantiator.js +74 -69
  19. package/dist/api/fragment-instantiator.js.map +1 -1
  20. package/dist/api/request-context-storage.d.ts +4 -0
  21. package/dist/api/request-context-storage.d.ts.map +1 -1
  22. package/dist/api/request-context-storage.js +6 -0
  23. package/dist/api/request-context-storage.js.map +1 -1
  24. package/dist/api/request-input-context.d.ts.map +1 -1
  25. package/dist/api/request-input-context.js.map +1 -1
  26. package/dist/api/request-middleware.d.ts +1 -1
  27. package/dist/api/request-middleware.d.ts.map +1 -1
  28. package/dist/api/request-middleware.js.map +1 -1
  29. package/dist/api/request-output-context.d.ts +1 -1
  30. package/dist/api/request-output-context.d.ts.map +1 -1
  31. package/dist/api/request-output-context.js.map +1 -1
  32. package/dist/api/route-caller.d.ts +30 -0
  33. package/dist/api/route-caller.d.ts.map +1 -0
  34. package/dist/api/route-caller.js +63 -0
  35. package/dist/api/route-caller.js.map +1 -0
  36. package/dist/api/route-handler-input-options.d.ts.map +1 -1
  37. package/dist/api/route.d.ts +1 -1
  38. package/dist/api/route.d.ts.map +1 -1
  39. package/dist/api/route.js.map +1 -1
  40. package/dist/api/shared-types.d.ts.map +1 -1
  41. package/dist/client/client-error.d.ts.map +1 -1
  42. package/dist/client/client-error.js.map +1 -1
  43. package/dist/client/client.d.ts +91 -52
  44. package/dist/client/client.d.ts.map +1 -1
  45. package/dist/client/client.js +25 -9
  46. package/dist/client/client.js.map +1 -1
  47. package/dist/client/client.svelte.d.ts +6 -5
  48. package/dist/client/client.svelte.d.ts.map +1 -1
  49. package/dist/client/client.svelte.js +10 -2
  50. package/dist/client/client.svelte.js.map +1 -1
  51. package/dist/client/internal/ndjson-streaming.js.map +1 -1
  52. package/dist/client/react.d.ts +5 -4
  53. package/dist/client/react.d.ts.map +1 -1
  54. package/dist/client/react.js +104 -12
  55. package/dist/client/react.js.map +1 -1
  56. package/dist/client/solid.d.ts +7 -5
  57. package/dist/client/solid.d.ts.map +1 -1
  58. package/dist/client/solid.js +23 -9
  59. package/dist/client/solid.js.map +1 -1
  60. package/dist/client/vanilla.d.ts +16 -4
  61. package/dist/client/vanilla.d.ts.map +1 -1
  62. package/dist/client/vanilla.js +21 -1
  63. package/dist/client/vanilla.js.map +1 -1
  64. package/dist/client/vue.d.ts +7 -5
  65. package/dist/client/vue.d.ts.map +1 -1
  66. package/dist/client/vue.js +18 -10
  67. package/dist/client/vue.js.map +1 -1
  68. package/dist/id.d.ts +2 -0
  69. package/dist/id.js +3 -0
  70. package/dist/internal/cuid.d.ts +16 -0
  71. package/dist/internal/cuid.d.ts.map +1 -0
  72. package/dist/internal/cuid.js +82 -0
  73. package/dist/internal/cuid.js.map +1 -0
  74. package/dist/mod-client.d.ts +5 -4
  75. package/dist/mod-client.d.ts.map +1 -1
  76. package/dist/mod-client.js +7 -5
  77. package/dist/mod-client.js.map +1 -1
  78. package/dist/mod.d.ts +6 -5
  79. package/dist/mod.js +2 -1
  80. package/dist/runtime.js +1 -1
  81. package/dist/runtime.js.map +1 -1
  82. package/dist/test/test.d.ts +6 -6
  83. package/dist/test/test.d.ts.map +1 -1
  84. package/dist/test/test.js.map +1 -1
  85. package/dist/util/ssr.js.map +1 -1
  86. package/package.json +24 -40
  87. package/src/api/api.test.ts +3 -1
  88. package/src/api/api.ts +6 -0
  89. package/src/api/bind-services.ts +0 -5
  90. package/src/api/error.ts +1 -0
  91. package/src/api/fragment-definition-builder.extend.test.ts +2 -1
  92. package/src/api/fragment-definition-builder.test.ts +2 -1
  93. package/src/api/fragment-definition-builder.ts +49 -124
  94. package/src/api/fragment-instantiator.test.ts +92 -233
  95. package/src/api/fragment-instantiator.ts +228 -196
  96. package/src/api/fragment-services.test.ts +1 -0
  97. package/src/api/internal/path-runtime.test.ts +1 -0
  98. package/src/api/internal/path-type.test.ts +3 -1
  99. package/src/api/internal/route.test.ts +1 -0
  100. package/src/api/request-context-storage.ts +7 -0
  101. package/src/api/request-input-context.test.ts +4 -2
  102. package/src/api/request-input-context.ts +2 -1
  103. package/src/api/request-middleware.test.ts +9 -14
  104. package/src/api/request-middleware.ts +3 -2
  105. package/src/api/request-output-context.test.ts +3 -1
  106. package/src/api/request-output-context.ts +2 -1
  107. package/src/api/route-caller.test.ts +195 -0
  108. package/src/api/route-caller.ts +167 -0
  109. package/src/api/route-handler-input-options.ts +2 -1
  110. package/src/api/route.test.ts +4 -2
  111. package/src/api/route.ts +2 -1
  112. package/src/api/shared-types.ts +2 -1
  113. package/src/client/client-builder.test.ts +4 -2
  114. package/src/client/client-error.test.ts +2 -1
  115. package/src/client/client-error.ts +1 -1
  116. package/src/client/client-types.test.ts +19 -5
  117. package/src/client/client.ssr.test.ts +6 -4
  118. package/src/client/client.svelte.test.ts +18 -9
  119. package/src/client/client.svelte.ts +38 -13
  120. package/src/client/client.test.ts +49 -10
  121. package/src/client/client.ts +291 -141
  122. package/src/client/internal/ndjson-streaming.test.ts +6 -3
  123. package/src/client/internal/ndjson-streaming.ts +1 -0
  124. package/src/client/react.test.ts +176 -6
  125. package/src/client/react.ts +226 -31
  126. package/src/client/solid.test.ts +29 -5
  127. package/src/client/solid.ts +60 -22
  128. package/src/client/vanilla.test.ts +148 -6
  129. package/src/client/vanilla.ts +63 -9
  130. package/src/client/vue.test.ts +223 -84
  131. package/src/client/vue.ts +57 -30
  132. package/src/id.ts +1 -0
  133. package/src/internal/cuid.test.ts +164 -0
  134. package/src/internal/cuid.ts +133 -0
  135. package/src/mod-client.ts +4 -2
  136. package/src/mod.ts +3 -2
  137. package/src/runtime.ts +1 -1
  138. package/src/test/test.test.ts +4 -2
  139. package/src/test/test.ts +7 -9
  140. package/src/util/async.test.ts +1 -0
  141. package/src/util/content-type.test.ts +1 -0
  142. package/src/util/nanostores.test.ts +3 -1
  143. package/src/util/ssr.ts +1 -0
  144. package/tsconfig.json +1 -1
  145. package/tsdown.config.ts +1 -0
  146. package/vitest.config.ts +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fragment-definition-builder.d.ts","names":[],"sources":["../../src/api/fragment-definition-builder.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAMiC;AAgBjC,UAXU,eAAA,CAWE;EAEO;EAEC,IAAA,EAAA,MAAA;EAAgC;EAE1C,QAAA,EAAA,OAAA;;;;;AAQV;AAAuC,KAd3B,sBAc2B,CAAA,OAAA,EAAA,iBAZpB,kBAYoB,EAAA,oBAAA,EAAA,kBAVnB,6BAUmB,GAVa,6BAUb,CAAA,GAAA,CAAA,OAAA,EAAA;EAGlC,MAAA,EAXK,OAWL;EACD,OAAA,EAXO,QAWP;EAAS,mBAAA,CAAA,EAVW,oBAUX;AAMb,CAAA,EAAA,GAfM,SAeM;;;;AAQJ,KAlBI,qBAkBJ,CAAA,CAAA,CAAA,GAlB+B,CAkB/B,UAAA,CAAA,GAAA,IAAA,EAAA,KAAA,EAAA,EAAA,GAfH,0BAeG,CAAA,GAAA,EAAA,GAAA,EAAA,KAAA,UAAA,EAAA,GAAA,EAAA,GAAA,EAAA,GAAA,EAAA,G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,CAAA,CAAA,WAAA,EAAA,CAAA,OAAA,EAAA,IAAA,EAAA,GA6Eb,WA7Ea,CAAA,EA6EC,WA7ED;EAAvD;;;EAKd,KAAA,CAAA,CAAA,EA+EO,kBA/EP,CAgFA,OAhFA,EAiFA,QAjFA,EAkFA,KAlFA,EAmFA,aAnFA,EAoFA,SApFA,EAqFA,oBArFA,EAsFA,gBAtFA,EAuFA,mBAvFA,EAwFA,mBAxFA,EAyFA,eAzFA,EA0FA,eA1FA,CAAA;;;;;AAKA,iBAyGY,cAzGZ,CAAA,UAAA,CAAA,CAAA,EAAA,iBA2Ge,kBA3Gf,GA2GoC,kBA3GpC,EAAA,4BA4G0B,kBA5G1B,GA4G+C,kBA5G/C,EAAA,4BA6G0B,kBA7G1B,GA6G+C,kBA7G/C,EAAA,kBAAA,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,CAAA,EAiHD,yBAjHC,CAkHF,OAlHE,EAmHF,QAnHE,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAyHF,mBAzHE,EA0HF,mBA1HE,EA2HF,eA3HE,EAAA,EACA,CAAA"}
@@ -13,7 +13,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
13
13
  #createRequestStorage;
14
14
  #createThisContext;
15
15
  #getExternalStorage;
16
- #linkedFragments;
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.#linkedFragments = state.linkedFragments;
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
- linkedFragments: this.#linkedFragments
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
- linkedFragments: this.#linkedFragments
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
- linkedFragments: this.#linkedFragments
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
- linkedFragments: this.#linkedFragments
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
- linkedFragments: this.#linkedFragments
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
- linkedFragments: this.#linkedFragments
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
- linkedFragments: this.#linkedFragments
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
- linkedFragments: this.#linkedFragments
237
+ internalRoutes: this.#internalRoutes
238
238
  });
239
239
  }
240
240
  /**
@@ -264,20 +264,13 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
264
264
  createRequestStorage: this.#createRequestStorage,
265
265
  createThisContext: fn,
266
266
  getExternalStorage: this.#getExternalStorage,
267
- linkedFragments: this.#linkedFragments
267
+ internalRoutes: this.#internalRoutes
268
268
  });
269
269
  }
270
270
  /**
271
- * Register a linked fragment that will be automatically instantiated.
272
- * Linked fragments share the same config/options as the parent and their services
273
- * are exposed as private services. Routes are not exposed by default, but the
274
- * instantiator may mount internal linked fragment routes under an internal prefix.
271
+ * Define internal routes that will be mounted under /_internal.
275
272
  */
276
- withLinkedFragment(name, callback) {
277
- const newLinkedFragments = {
278
- ...this.#linkedFragments,
279
- [name]: callback
280
- };
273
+ withInternalRoutes(routes) {
281
274
  return new FragmentDefinitionBuilder(this.#name, {
282
275
  dependencies: this.#dependencies,
283
276
  baseServices: this.#baseServices,
@@ -287,7 +280,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
287
280
  createRequestStorage: this.#createRequestStorage,
288
281
  createThisContext: this.#createThisContext,
289
282
  getExternalStorage: this.#getExternalStorage,
290
- linkedFragments: newLinkedFragments
283
+ internalRoutes: routes
291
284
  });
292
285
  }
293
286
  /**
@@ -311,7 +304,7 @@ var FragmentDefinitionBuilder = class FragmentDefinitionBuilder {
311
304
  createRequestStorage: this.#createRequestStorage,
312
305
  createThisContext: this.#createThisContext,
313
306
  getExternalStorage: this.#getExternalStorage,
314
- linkedFragments: this.#linkedFragments
307
+ internalRoutes: this.#internalRoutes
315
308
  };
316
309
  }
317
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 TFragment extends AnyFragnoInstantiatedFragment = AnyFragnoInstantiatedFragment,\n> = (context: {\n config: TConfig;\n options: TOptions;\n serviceDependencies?: TServiceDependencies;\n}) => TFragment;\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 factory for internal data attached to fragment.$internal.\n */\n internalDataFactory?: (context: {\n config: TConfig;\n options: TOptions;\n deps: TDeps;\n linkedFragments: TLinkedFragments;\n }) => Record<string, unknown> | void;\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<\n TConfig,\n TOptions,\n TServiceDependencies,\n TLinkedFragments[K]\n >;\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<\n TConfig,\n TOptions,\n TServiceDependencies,\n TLinkedFragments[K]\n >;\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 TLinkedFragments[K]\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 share the same config/options as the parent and their services\n * are exposed as private services. Routes are not exposed by default, but the\n * instantiator may mount internal linked fragment routes under an internal prefix.\n */\n withLinkedFragment<const TName extends string, TFragment extends AnyFragnoInstantiatedFragment>(\n name: TName,\n callback: LinkedFragmentCallback<TConfig, TOptions, TServiceDependencies, TFragment>,\n ): FragmentDefinitionBuilder<\n TConfig,\n TOptions,\n TDeps,\n TBaseServices,\n TServices,\n TServiceDependencies,\n TPrivateServices & ExtractLinkedServices<() => TFragment>,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments & { [K in TName]: TFragment }\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<TFragment>,\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<() => TFragment>,\n TServiceThisContext,\n THandlerThisContext,\n TRequestStorage,\n TLinkedFragments & { [K in TName]: TFragment }\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 THandlerThisCont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B,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,MAAM;AAChC,SAAKC,qBAAsB,MAAM;AACjC,SAAKC,iBAAkB,MAAM;;;CAIjC,IAAI,OAAe;AACjB,SAAO,MAAKT;;;;;;;;;;;;;;;;;;;;;;;;CAyBd,iBACE,IAaA;AAEA,MACE,MAAKE,gBACL,MAAKC,iBACL,MAAKC,mBACL,MAAKE,wBACL,MAAKC,qBACL,MAAKC,mBAEL,SAAQ,KACN,qDAAqD,MAAKR,KAAM,kMAEjE;AAGH,SAAO,IAAI,0BAYT,MAAKA,MAAO;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,iBAAiB;GACjB,qBAAqB,MAAKK;GAE1B,sBAAsB;GACtB,mBAAmB;GACnB,oBAAoB;GACpB,gBAAgB,MAAKI;GACtB,CAAC;;;;;;CAOJ,oBACE,IAqBA;AACA,SAAO,IAAI,0BAYT,MAAKT,MAAO;GACZ,cAAc,MAAKC;GACnB,cAAc;GACd,eAAe,MAAKE;GACpB,iBAAiB,MAAKC;GACtB,qBAAqB,MAAKC;GAC1B,sBAAsB,MAAKC;GAC3B,mBAAmB,MAAKC;GACxB,oBAAoB,MAAKC;GACzB,gBAAgB,MAAKC;GACtB,CAAC;;;;;;CAOJ,gBACE,aACA,IA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,MAAKC;GACnB,cAAc,MAAKC;GACnB,eAAe,MAAKC;GACpB,iBAAiB,MAAKC;GACtB,qBAAqB,MAAKC;GAC1B,sBAAsB,MAAKC;GAC3B,mBAAmB,MAAKC;GACxB,oBAAoB,MAAKC;GACzB,gBAAgB,MAAKC;GACtB;;;;;;AAOL,SAAgB,eAOd,MAaA;AACA,QAAO,IAAI,0BAA0B,KAAK"}
@@ -1,27 +1,36 @@
1
1
  import { InferOrUnknown } from "../util/types-util.js";
2
- import { RouteHandlerInputOptions } from "./route-handler-input-options.js";
3
- import { FragnoPublicConfig } from "./shared-types.js";
4
- import { FragnoRouteConfig, HTTPMethod, RequestThisContext } from "./api.js";
5
- import { RequestContextStorage } from "./request-context-storage.js";
6
2
  import { BoundServices } from "./bind-services.js";
3
+ import { RequestContextStorage } from "./request-context-storage.js";
7
4
  import { AnyFragnoRouteConfig, AnyRouteOrFactory, FlattenRouteFactories } from "./route.js";
8
- import { ExtractRouteByPath, ExtractRoutePath } from "../client/client.js";
9
- import { FragnoMiddlewareCallback } from "./request-middleware.js";
10
- import { FragnoResponse } from "./fragno-response.js";
11
- import { instantiatedFragmentFakeSymbol } from "../internal/symbols.js";
5
+ import { FragnoPublicConfig } from "./shared-types.js";
12
6
  import { FragmentDefinition } from "./fragment-definition-builder.js";
7
+ import { instantiatedFragmentFakeSymbol } from "../internal/symbols.js";
8
+ import { FragnoResponse } from "./fragno-response.js";
9
+ import { FragnoMiddlewareCallback } from "./request-middleware.js";
10
+ import { RouteHandlerInputOptions } from "./route-handler-input-options.js";
11
+ import { ExtractRouteByPath, ExtractRoutePath } from "../client/client.js";
12
+ import { FragnoRouteConfig, HTTPMethod, RequestThisContext } from "./api.js";
13
13
  import { StandardSchemaV1 } from "@standard-schema/spec";
14
14
 
15
15
  //#region src/api/fragment-instantiator.d.ts
16
+ type CallRoutePath<TRoutes extends readonly AnyFragnoRouteConfig[], TMethod$1 extends HTTPMethod> = [ExtractRoutePath<TRoutes, TMethod$1>] extends [never] ? string : ExtractRoutePath<TRoutes, TMethod$1>;
17
+ type CallRouteMatch<TRoutes extends readonly AnyFragnoRouteConfig[], TMethod$1 extends HTTPMethod, TPath$1 extends string> = [ExtractRouteByPath<TRoutes, TPath$1, TMethod$1>] extends [never] ? AnyFragnoRouteConfig : ExtractRouteByPath<TRoutes, TPath$1, TMethod$1>;
18
+ type FragnoRequestLifecycleContext = {
19
+ waitUntil?: (promise: Promise<unknown>) => void;
20
+ };
16
21
  type InternalRoutePrefix = "/_internal";
17
22
  type JoinInternalRoutePath<TPath$1 extends string> = TPath$1 extends "" | "/" ? InternalRoutePrefix : TPath$1 extends `/${string}` ? `${InternalRoutePrefix}${TPath$1}` : `${InternalRoutePrefix}/${TPath$1}`;
18
23
  type PrefixInternalRoute<TRoute> = TRoute extends FragnoRouteConfig<infer TMethod, infer TPath, infer TInputSchema, infer TOutputSchema, infer TErrorCode, infer TQueryParameters, infer TThisContext> ? FragnoRouteConfig<TMethod, JoinInternalRoutePath<TPath>, TInputSchema, TOutputSchema, TErrorCode, TQueryParameters, TThisContext> : never;
19
- type PrefixInternalRoutes<TRoutes$1 extends readonly AnyFragnoRouteConfig[]> = TRoutes$1 extends readonly [...infer TRoutesTuple] ? { [K in keyof TRoutesTuple]: PrefixInternalRoute<TRoutesTuple[K]> } : readonly AnyFragnoRouteConfig[];
20
- type ExtractRoutesFromFragment<T> = T extends FragnoInstantiatedFragment<infer TRoutes, infer _TDeps, infer _TServices, infer _TServiceThisContext, infer _THandlerThisContext, infer _TRequestStorage, infer _TOptions, infer _TLinkedFragments> ? TRoutes : never;
21
- type InternalLinkedRoutes<TLinkedFragments$1> = TLinkedFragments$1 extends Record<string, AnyFragnoInstantiatedFragment> ? TLinkedFragments$1 extends {
22
- _fragno_internal: infer TInternal;
23
- } ? ExtractRoutesFromFragment<TInternal> extends readonly AnyFragnoRouteConfig[] ? PrefixInternalRoutes<ExtractRoutesFromFragment<TInternal>> : readonly [] : readonly [] : readonly [];
24
- type RoutesWithInternal<TRoutes$1 extends readonly AnyFragnoRouteConfig[], TLinkedFragments$1> = readonly [...TRoutes$1, ...InternalLinkedRoutes<TLinkedFragments$1>];
24
+ type PrefixInternalRoutes<TRoutes extends readonly AnyFragnoRouteConfig[]> = TRoutes extends readonly [...infer TRoutesTuple] ? { [K in keyof TRoutesTuple]: PrefixInternalRoute<TRoutesTuple[K]> } : readonly AnyFragnoRouteConfig[];
25
+ type InternalRoutesFromDefinition<TInternalRoutes$1 extends readonly AnyRouteOrFactory[]> = PrefixInternalRoutes<FlattenRouteFactories<TInternalRoutes$1>>;
26
+ type RoutesWithInternal<TRoutes extends readonly AnyFragnoRouteConfig[], TInternalRoutes$1 extends readonly AnyRouteOrFactory[]> = readonly [...TRoutes, ...InternalRoutesFromDefinition<TInternalRoutes$1>];
27
+ type ExtractServiceCallResult<T> = T extends undefined ? undefined : T extends {
28
+ _internal: {
29
+ finalResult?: infer R;
30
+ };
31
+ } ? R : Awaited<T>;
32
+ type ExtractServiceCallResults<T extends readonly unknown[]> = { [K in keyof T]: ExtractServiceCallResult<T[K]> };
33
+ type ExtractServiceCallResultsOrSingle<T> = T extends readonly unknown[] ? ExtractServiceCallResults<T> : ExtractServiceCallResult<T>;
25
34
  /**
26
35
  * Helper type to extract the instantiated fragment type from a fragment definition.
27
36
  * This is useful for typing functions that accept instantiated fragments based on their definition.
@@ -32,7 +41,7 @@ type RoutesWithInternal<TRoutes$1 extends readonly AnyFragnoRouteConfig[], TLink
32
41
  * type MyInstantiatedFragment = InstantiatedFragmentFromDefinition<typeof myFragmentDef>;
33
42
  * ```
34
43
  */
35
- type InstantiatedFragmentFromDefinition<TDef extends FragmentDefinition<any, any, any, any, any, any, any, any, any, any, any>> = TDef extends FragmentDefinition<infer _TConfig, infer TOptions, infer TDeps, infer TBaseServices, infer TServices, infer _TServiceDependencies, infer _TPrivateServices, infer TServiceThisContext, infer THandlerThisContext, infer TRequestStorage, infer TLinkedFragments> ? FragnoInstantiatedFragment<RoutesWithInternal<readonly AnyFragnoRouteConfig[], TLinkedFragments>, TDeps, BoundServices<TBaseServices & TServices>, TServiceThisContext, THandlerThisContext, TRequestStorage, TOptions, TLinkedFragments> : never;
44
+ type InstantiatedFragmentFromDefinition<TDef extends FragmentDefinition<any, any, any, any, any, any, any, any, any, any, any>> = TDef extends FragmentDefinition<infer _TConfig, infer TOptions, infer TDeps, infer TBaseServices, infer TServices, infer _TServiceDependencies, infer _TPrivateServices, infer TServiceThisContext, infer THandlerThisContext, infer TRequestStorage, infer TInternalRoutes> ? FragnoInstantiatedFragment<RoutesWithInternal<readonly AnyFragnoRouteConfig[], TInternalRoutes>, TDeps, BoundServices<TBaseServices & TServices>, TServiceThisContext, THandlerThisContext, TRequestStorage, TOptions> : never;
36
45
  type AstroHandlers = {
37
46
  ALL: (req: Request) => Promise<Response>;
38
47
  };
@@ -86,21 +95,21 @@ type HandlersByFramework = {
86
95
  "tanstack-start": TanStackStartHandlers;
87
96
  };
88
97
  type FullstackFrameworks = keyof HandlersByFramework;
89
- type AnyFragnoInstantiatedFragment = FragnoInstantiatedFragment<any, any, any, any, any, any, any, any>;
90
- interface FragnoFragmentSharedConfig<TRoutes$1 extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[]> {
98
+ type AnyFragnoInstantiatedFragment = FragnoInstantiatedFragment<any, any, any, any, any, any, any>;
99
+ interface FragnoFragmentSharedConfig<TRoutes extends readonly FragnoRouteConfig<HTTPMethod, string, StandardSchemaV1 | undefined, StandardSchemaV1 | undefined, string, string>[]> {
91
100
  name: string;
92
- routes: TRoutes$1;
101
+ routes: TRoutes;
93
102
  }
94
103
  /**
95
104
  * Instantiated fragment class with encapsulated state.
96
105
  * Provides the same public API as the old FragnoInstantiatedFragment but with better encapsulation.
97
106
  */
98
- declare class FragnoInstantiatedFragment<TRoutes$1 extends readonly AnyFragnoRouteConfig[], TDeps$1, TServices$1 extends Record<string, unknown>, TServiceThisContext$1 extends RequestThisContext, THandlerThisContext$1 extends RequestThisContext, TRequestStorage$1 = {}, TOptions$1 extends FragnoPublicConfig = FragnoPublicConfig, TLinkedFragments$1 extends Record<string, AnyFragnoInstantiatedFragment> = {}> implements IFragnoInstantiatedFragment {
107
+ declare class FragnoInstantiatedFragment<TRoutes extends readonly AnyFragnoRouteConfig[], TDeps$1, TServices$1 extends Record<string, unknown>, TServiceThisContext$1 extends RequestThisContext, THandlerThisContext$1 extends RequestThisContext, TRequestStorage$1 = {}, TOptions$1 extends FragnoPublicConfig = FragnoPublicConfig> implements IFragnoInstantiatedFragment {
99
108
  #private;
100
109
  readonly [instantiatedFragmentFakeSymbol]: "$fragno-instantiated-fragment";
101
110
  constructor(params: {
102
111
  name: string;
103
- routes: TRoutes$1;
112
+ routes: TRoutes;
104
113
  deps: TDeps$1;
105
114
  services: TServices$1;
106
115
  mountRoute: string;
@@ -109,11 +118,10 @@ declare class FragnoInstantiatedFragment<TRoutes$1 extends readonly AnyFragnoRou
109
118
  storage: RequestContextStorage<TRequestStorage$1>;
110
119
  createRequestStorage?: () => TRequestStorage$1;
111
120
  options: TOptions$1;
112
- linkedFragments?: TLinkedFragments$1;
113
121
  internalData?: Record<string, unknown>;
114
122
  });
115
123
  get name(): string;
116
- get routes(): TRoutes$1;
124
+ get routes(): TRoutes;
117
125
  get services(): TServices$1;
118
126
  get mountRoute(): string;
119
127
  /**
@@ -122,13 +130,12 @@ declare class FragnoInstantiatedFragment<TRoutes$1 extends readonly AnyFragnoRou
122
130
  get $internal(): {
123
131
  deps: TDeps$1;
124
132
  options: TOptions$1;
125
- linkedFragments: TLinkedFragments$1;
126
133
  };
127
134
  /**
128
135
  * Add middleware to this fragment.
129
136
  * Middleware can inspect and modify requests before they reach handlers.
130
137
  */
131
- withMiddleware(handler: FragnoMiddlewareCallback<TRoutes$1, TDeps$1, TServices$1>): this;
138
+ withMiddleware(handler: FragnoMiddlewareCallback<TRoutes, TDeps$1, TServices$1>): this;
132
139
  /**
133
140
  * Execute a callback within a request context.
134
141
  * Establishes an async context for the duration of the callback, allowing services
@@ -149,6 +156,13 @@ declare class FragnoInstantiatedFragment<TRoutes$1 extends readonly AnyFragnoRou
149
156
  */
150
157
  inContext<T>(callback: (this: THandlerThisContext$1) => T): T;
151
158
  inContext<T>(callback: (this: THandlerThisContext$1) => Promise<T>): Promise<T>;
159
+ /**
160
+ * Execute multiple service calls within a handler context.
161
+ * If called outside a request context, it will create one automatically.
162
+ * Pass a factory so service calls are created inside the active context.
163
+ * Primarily used by database fragments (handlerTx).
164
+ */
165
+ callServices<TServiceCalls>(serviceCalls: () => TServiceCalls): Promise<ExtractServiceCallResultsOrSingle<TServiceCalls>>;
152
166
  /**
153
167
  * Get framework-specific handlers for this fragment.
154
168
  * Use this to integrate the fragment with different fullstack frameworks.
@@ -158,17 +172,17 @@ declare class FragnoInstantiatedFragment<TRoutes$1 extends readonly AnyFragnoRou
158
172
  * Main request handler for this fragment.
159
173
  * Handles routing, middleware, and error handling.
160
174
  */
161
- handler(req: Request): Promise<Response>;
175
+ handler(req: Request, lifecycleContext?: FragnoRequestLifecycleContext): Promise<Response>;
162
176
  /**
163
177
  * Call a route directly with typed inputs and outputs.
164
178
  * Useful for testing and server-side route calls.
165
179
  */
166
- callRoute<TMethod$1 extends HTTPMethod, TPath$1 extends ExtractRoutePath<TRoutes$1, TMethod$1>>(method: TMethod$1, path: TPath$1, inputOptions?: RouteHandlerInputOptions<TPath$1, ExtractRouteByPath<TRoutes$1, TPath$1, TMethod$1>["inputSchema"]>): Promise<FragnoResponse<InferOrUnknown<NonNullable<ExtractRouteByPath<TRoutes$1, TPath$1, TMethod$1>["outputSchema"]>>>>;
180
+ callRoute<TMethod$1 extends HTTPMethod, TPath$1 extends CallRoutePath<TRoutes, TMethod$1>>(method: TMethod$1, path: TPath$1, inputOptions?: RouteHandlerInputOptions<TPath$1, CallRouteMatch<TRoutes, TMethod$1, TPath$1>["inputSchema"]>): Promise<FragnoResponse<InferOrUnknown<NonNullable<CallRouteMatch<TRoutes, TMethod$1, TPath$1>["outputSchema"]>>>>;
167
181
  /**
168
182
  * Call a route directly and get the raw Response object.
169
183
  * Useful for testing and server-side route calls.
170
184
  */
171
- callRouteRaw<TMethod$1 extends HTTPMethod, TPath$1 extends ExtractRoutePath<TRoutes$1, TMethod$1>>(method: TMethod$1, path: TPath$1, inputOptions?: RouteHandlerInputOptions<TPath$1, ExtractRouteByPath<TRoutes$1, TPath$1, TMethod$1>["inputSchema"]>): Promise<Response>;
185
+ callRouteRaw<TMethod$1 extends HTTPMethod, TPath$1 extends CallRoutePath<TRoutes, TMethod$1>>(method: TMethod$1, path: TPath$1, inputOptions?: RouteHandlerInputOptions<TPath$1, CallRouteMatch<TRoutes, TMethod$1, TPath$1>["inputSchema"]>): Promise<Response>;
172
186
  }
173
187
  /**
174
188
  * Options for fragment instantiation.
@@ -185,7 +199,7 @@ interface InstantiationOptions {
185
199
  * Core instantiation function that creates a fragment instance from a definition.
186
200
  * This function validates dependencies, calls all callbacks, and wires everything together.
187
201
  */
188
- declare function instantiateFragment<const TConfig, const TOptions$1 extends FragnoPublicConfig, const TDeps$1, const TBaseServices$1 extends Record<string, unknown>, const TServices$1 extends Record<string, unknown>, const TServiceDependencies, const TPrivateServices extends Record<string, unknown>, const TServiceThisContext$1 extends RequestThisContext, const THandlerThisContext$1 extends RequestThisContext, const TRequestStorage$1, const TRoutesOrFactories extends readonly AnyRouteOrFactory[], const TLinkedFragments$1 extends Record<string, AnyFragnoInstantiatedFragment>>(definition: FragmentDefinition<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TLinkedFragments$1>, config: TConfig, routesOrFactories: TRoutesOrFactories, options: TOptions$1, serviceImplementations?: TServiceDependencies, instantiationOptions?: InstantiationOptions): FragnoInstantiatedFragment<RoutesWithInternal<FlattenRouteFactories<TRoutesOrFactories>, TLinkedFragments$1>, TDeps$1, BoundServices<TBaseServices$1 & TServices$1>, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TOptions$1, TLinkedFragments$1>;
202
+ declare function instantiateFragment<const TConfig, const TOptions$1 extends FragnoPublicConfig, const TDeps$1, const TBaseServices$1 extends Record<string, unknown>, const TServices$1 extends Record<string, unknown>, const TServiceDependencies, const TPrivateServices extends Record<string, unknown>, const TServiceThisContext$1 extends RequestThisContext, const THandlerThisContext$1 extends RequestThisContext, const TRequestStorage$1, const TRoutesOrFactories extends readonly AnyRouteOrFactory[], const TInternalRoutes$1 extends readonly AnyRouteOrFactory[]>(definition: FragmentDefinition<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TInternalRoutes$1>, config: TConfig, routesOrFactories: TRoutesOrFactories, options: TOptions$1, serviceImplementations?: TServiceDependencies, instantiationOptions?: InstantiationOptions): FragnoInstantiatedFragment<RoutesWithInternal<FlattenRouteFactories<TRoutesOrFactories>, TInternalRoutes$1>, TDeps$1, BoundServices<TBaseServices$1 & TServices$1>, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TOptions$1>;
189
203
  /**
190
204
  * Interface that defines the public API for a fragment instantiation builder.
191
205
  * Used to ensure consistency between real implementations and stubs.
@@ -241,13 +255,13 @@ interface IFragnoInstantiatedFragment {
241
255
  get $internal(): {
242
256
  deps: unknown;
243
257
  options: unknown;
244
- linkedFragments: unknown;
245
258
  } & Record<string, unknown>;
246
259
  withMiddleware(handler: any): this;
247
260
  inContext<T>(callback: any): T;
248
261
  inContext<T>(callback: any): Promise<T>;
262
+ callServices(serviceCalls: () => any): Promise<any>;
249
263
  handlersFor(framework: FullstackFrameworks): any;
250
- handler(req: Request): Promise<Response>;
264
+ handler(req: Request, lifecycleContext?: FragnoRequestLifecycleContext): Promise<Response>;
251
265
  callRoute(method: HTTPMethod, path: string, inputOptions?: any): Promise<any>;
252
266
  callRouteRaw(method: HTTPMethod, path: string, inputOptions?: any): Promise<Response>;
253
267
  }
@@ -255,13 +269,13 @@ interface IFragnoInstantiatedFragment {
255
269
  * Fluent builder for instantiating fragments.
256
270
  * Provides a type-safe API for configuring and building fragment instances.
257
271
  */
258
- declare class FragmentInstantiationBuilder<TConfig, TOptions$1 extends FragnoPublicConfig, TDeps$1, TBaseServices$1 extends Record<string, unknown>, TServices$1 extends Record<string, unknown>, TServiceDependencies, TPrivateServices extends Record<string, unknown>, TServiceThisContext$1 extends RequestThisContext, THandlerThisContext$1 extends RequestThisContext, TRequestStorage$1, TRoutesOrFactories extends readonly AnyRouteOrFactory[], TLinkedFragments$1 extends Record<string, AnyFragnoInstantiatedFragment>> implements IFragmentInstantiationBuilder {
272
+ declare class FragmentInstantiationBuilder<TConfig, TOptions$1 extends FragnoPublicConfig, TDeps$1, TBaseServices$1 extends Record<string, unknown>, TServices$1 extends Record<string, unknown>, TServiceDependencies, TPrivateServices extends Record<string, unknown>, TServiceThisContext$1 extends RequestThisContext, THandlerThisContext$1 extends RequestThisContext, TRequestStorage$1, TRoutesOrFactories extends readonly AnyRouteOrFactory[], TInternalRoutes$1 extends readonly AnyRouteOrFactory[]> implements IFragmentInstantiationBuilder {
259
273
  #private;
260
- constructor(definition: FragmentDefinition<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TLinkedFragments$1>, routes?: TRoutesOrFactories);
274
+ constructor(definition: FragmentDefinition<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TInternalRoutes$1>, routes?: TRoutesOrFactories);
261
275
  /**
262
276
  * Get the fragment definition
263
277
  */
264
- get definition(): FragmentDefinition<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TLinkedFragments$1>;
278
+ get definition(): FragmentDefinition<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TInternalRoutes$1>;
265
279
  /**
266
280
  * Get the configured routes
267
281
  */
@@ -281,7 +295,7 @@ declare class FragmentInstantiationBuilder<TConfig, TOptions$1 extends FragnoPub
281
295
  /**
282
296
  * Set the routes for the fragment
283
297
  */
284
- withRoutes<const TNewRoutes extends readonly AnyRouteOrFactory[]>(routes: TNewRoutes): FragmentInstantiationBuilder<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TNewRoutes, TLinkedFragments$1>;
298
+ withRoutes<const TNewRoutes extends readonly AnyRouteOrFactory[]>(routes: TNewRoutes): FragmentInstantiationBuilder<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TNewRoutes, TInternalRoutes$1>;
285
299
  /**
286
300
  * Set the options for the fragment (e.g., mountRoute, databaseAdapter)
287
301
  */
@@ -293,7 +307,7 @@ declare class FragmentInstantiationBuilder<TConfig, TOptions$1 extends FragnoPub
293
307
  /**
294
308
  * Build and return the instantiated fragment
295
309
  */
296
- build(): FragnoInstantiatedFragment<RoutesWithInternal<FlattenRouteFactories<TRoutesOrFactories>, TLinkedFragments$1>, TDeps$1, BoundServices<TBaseServices$1 & TServices$1>, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TOptions$1, TLinkedFragments$1>;
310
+ build(): FragnoInstantiatedFragment<RoutesWithInternal<FlattenRouteFactories<TRoutesOrFactories>, TInternalRoutes$1>, TDeps$1, BoundServices<TBaseServices$1 & TServices$1>, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TOptions$1>;
297
311
  }
298
312
  /**
299
313
  * Create a fluent builder for instantiating a fragment.
@@ -307,7 +321,7 @@ declare class FragmentInstantiationBuilder<TConfig, TOptions$1 extends FragnoPub
307
321
  * .build();
308
322
  * ```
309
323
  */
310
- declare function instantiate<TConfig, TOptions$1 extends FragnoPublicConfig, TDeps$1, TBaseServices$1 extends Record<string, unknown>, TServices$1 extends Record<string, unknown>, TServiceDependencies, TPrivateServices extends Record<string, unknown>, TServiceThisContext$1 extends RequestThisContext, THandlerThisContext$1 extends RequestThisContext, TRequestStorage$1, TLinkedFragments$1 extends Record<string, AnyFragnoInstantiatedFragment>>(definition: FragmentDefinition<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TLinkedFragments$1>): FragmentInstantiationBuilder<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, readonly [], TLinkedFragments$1>;
324
+ declare function instantiate<TConfig, TOptions$1 extends FragnoPublicConfig, TDeps$1, TBaseServices$1 extends Record<string, unknown>, TServices$1 extends Record<string, unknown>, TServiceDependencies, TPrivateServices extends Record<string, unknown>, TServiceThisContext$1 extends RequestThisContext, THandlerThisContext$1 extends RequestThisContext, TRequestStorage$1, TInternalRoutes$1 extends readonly AnyRouteOrFactory[]>(definition: FragmentDefinition<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, TInternalRoutes$1>): FragmentInstantiationBuilder<TConfig, TOptions$1, TDeps$1, TBaseServices$1, TServices$1, TServiceDependencies, TPrivateServices, TServiceThisContext$1, THandlerThisContext$1, TRequestStorage$1, readonly [], TInternalRoutes$1>;
311
325
  //#endregion
312
- export { AnyFragnoInstantiatedFragment, type BoundServices, FragmentInstantiationBuilder, FragnoFragmentSharedConfig, FragnoInstantiatedFragment, type IFragmentInstantiationBuilder, type IFragnoInstantiatedFragment, InstantiatedFragmentFromDefinition, InstantiationOptions, RoutesWithInternal, instantiate, instantiateFragment };
326
+ export { AnyFragnoInstantiatedFragment, type BoundServices, FragmentInstantiationBuilder, FragnoFragmentSharedConfig, FragnoInstantiatedFragment, FragnoRequestLifecycleContext, type IFragmentInstantiationBuilder, type IFragnoInstantiatedFragment, InstantiatedFragmentFromDefinition, InstantiationOptions, RoutesWithInternal, instantiate, instantiateFragment };
313
327
  //# sourceMappingURL=fragment-instantiator.d.ts.map