@ecopages/core 0.3.1 → 0.4.0

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 (67) hide show
  1. package/README.md +17 -1
  2. package/package.json +3 -3
  3. package/src/adapters/node/create-app.d.ts +31 -20
  4. package/src/adapters/node/create-app.js +44 -43
  5. package/src/adapters/node/dev-session.d.ts +3 -1
  6. package/src/adapters/node/dev-session.js +4 -1
  7. package/src/adapters/node/runtime-host.d.ts +5 -0
  8. package/src/adapters/node/runtime-host.js +8 -1
  9. package/src/adapters/node/server-adapter.js +5 -1
  10. package/src/adapters/shared/hmr/hmr-manager.d.ts +12 -2
  11. package/src/adapters/shared/hmr/hmr-manager.js +20 -16
  12. package/src/adapters/shared/http/define-api-handler.d.ts +41 -26
  13. package/src/adapters/shared/http/define-api-handler.js +15 -1
  14. package/src/adapters/shared/http/endpoint-route-handler.d.ts +46 -0
  15. package/src/adapters/shared/http/endpoint-route-handler.js +96 -0
  16. package/src/adapters/shared/runtime/bind-runtime-server.js +3 -1
  17. package/src/adapters/shared/runtime/copy-runtime-public-dir.js +10 -9
  18. package/src/adapters/shared/runtime/port-manager.d.ts +6 -0
  19. package/src/adapters/shared/runtime/port-manager.js +16 -2
  20. package/src/adapters/shared/runtime/server-request-pipeline.d.ts +20 -3
  21. package/src/adapters/shared/runtime/server-request-pipeline.js +45 -12
  22. package/src/adapters/shared/runtime/server-route-handler.d.ts +8 -3
  23. package/src/adapters/shared/runtime/server-route-handler.js +12 -6
  24. package/src/adapters/shared/runtime/server-static-builder.d.ts +14 -1
  25. package/src/adapters/shared/runtime/server-static-builder.js +13 -2
  26. package/src/assets/app-browser-client-build.js +1 -2
  27. package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +8 -8
  28. package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +4 -4
  29. package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +12 -8
  30. package/src/assets/asset-processing-service/processors/script/file-script.processor.js +36 -16
  31. package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +11 -6
  32. package/src/assets/browser-asset-output.d.ts +19 -0
  33. package/src/assets/browser-asset-output.js +30 -0
  34. package/src/assets/hashed-browser-asset.d.ts +8 -6
  35. package/src/assets/hashed-browser-asset.js +8 -6
  36. package/src/build/build-graph.js +2 -2
  37. package/src/build/preserve-import-meta-transform.js +2 -2
  38. package/src/build/rolldown/app-package-declarations.js +3 -3
  39. package/src/build/rolldown/rolldown-adapter-helpers.js +3 -3
  40. package/src/build/rolldown/server-side-css-shim-plugin.js +3 -3
  41. package/src/build/server-bundle-deploy-manifest.d.ts +1 -1
  42. package/src/build/server-bundle-deploy-manifest.js +1 -1
  43. package/src/build/server-bundle-publication.js +4 -5
  44. package/src/config/assembly/finalize-config.js +5 -0
  45. package/src/config/config-module-files.js +2 -3
  46. package/src/diagnostics/startup-trace.js +2 -5
  47. package/src/html-pages/html-page-module-scripts.js +4 -3
  48. package/src/html-pages/html-page-renderer.js +2 -3
  49. package/src/index.d.ts +1 -1
  50. package/src/index.js +1 -1
  51. package/src/plugins/component-import-discovery.js +4 -4
  52. package/src/plugins/foreign-jsx-override-plugin.js +2 -2
  53. package/src/plugins/tsconfig-import-resolver.js +12 -12
  54. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +0 -17
  55. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +0 -23
  56. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +2 -2
  57. package/src/route-renderer/page-loading/page-dependency-bundling.js +5 -5
  58. package/src/router/server/route-registry.d.ts +18 -9
  59. package/src/router/server/route-registry.js +50 -32
  60. package/src/router/server/segment-path-matcher.d.ts +8 -0
  61. package/src/router/server/segment-path-matcher.js +15 -0
  62. package/src/static-site-generator/static-site-generator.js +1 -1
  63. package/src/types/contracts.d.ts +87 -61
  64. package/src/types/contracts.js +4 -1
  65. package/src/types/public-types.d.ts +1 -1
  66. package/src/utils/endpoint-file-extensions.d.ts +11 -0
  67. package/src/utils/endpoint-file-extensions.js +13 -0
@@ -1137,27 +1137,19 @@ export interface ApiHandlerContext<TRequest extends Request = Request, TServer =
1137
1137
  */
1138
1138
  services: ApiHandlerServices;
1139
1139
  /**
1140
- * Parsed and optionally validated request body.
1140
+ * Request body validated by `schema.body`.
1141
1141
  *
1142
- * - Without schema: Contains the parsed JSON body as `unknown`
1143
- * - With schema: Contains the validated and type-safe body data
1142
+ * - Without `schema.body`: `undefined`
1143
+ * - With `schema.body`: the validated body, typed from the schema
1144
1144
  *
1145
1145
  * For raw access to the request body stream, use `ctx.request.body`.
1146
1146
  *
1147
- * @example Without validation
1148
- * ```typescript
1149
- * app.post('/posts', async (ctx) => {
1150
- * const data = ctx.body; // [unknown] - parsed JSON
1151
- * return ctx.json({ received: data });
1152
- * });
1153
- * ```
1154
- *
1155
1147
  * @example With validation
1156
1148
  * ```typescript
1157
1149
  * import { z } from 'zod';
1158
1150
  *
1159
1151
  * app.post('/posts', async (ctx) => {
1160
- * const { title, author } = ctx.body; // [type-safe]
1152
+ * const { title, author } = ctx.body; // { title: string; author: string }
1161
1153
  * return ctx.json({ title, author });
1162
1154
  * }, {
1163
1155
  * schema: {
@@ -1172,8 +1164,8 @@ export interface ApiHandlerContext<TRequest extends Request = Request, TServer =
1172
1164
  /**
1173
1165
  * Parsed and optionally validated query parameters.
1174
1166
  *
1175
- * - Without schema: Contains query params as strings, or arrays when a key is repeated
1176
- * - With schema: Contains the validated and type-safe query data
1167
+ * - Without `schema.query`: query params as strings, or arrays when a key is repeated
1168
+ * - With `schema.query`: the validated query, typed from the schema
1177
1169
  *
1178
1170
  * Repeated query keys are represented as arrays, matching `PageQuery` on page props.
1179
1171
  *
@@ -1211,12 +1203,12 @@ export interface ApiHandlerContext<TRequest extends Request = Request, TServer =
1211
1203
  * });
1212
1204
  * ```
1213
1205
  */
1214
- query?: unknown;
1206
+ query: PageQuery;
1215
1207
  /**
1216
- * Parsed and optionally validated request headers.
1208
+ * Request headers validated by `schema.headers`.
1217
1209
  *
1218
- * - Without schema: Contains the parsed headers as a string record
1219
- * - With schema: Contains the validated and type-safe header data
1210
+ * - Without `schema.headers`: `undefined`
1211
+ * - With `schema.headers`: the validated headers, typed from the schema
1220
1212
  *
1221
1213
  * For raw access to headers, use `ctx.request.headers`.
1222
1214
  *
@@ -1278,15 +1270,15 @@ export interface ApiHandlerContext<TRequest extends Request = Request, TServer =
1278
1270
  *
1279
1271
  * Page middleware can mutate locals, short-circuit the request, and use the
1280
1272
  * response helpers, but final document rendering stays owned by the page route
1281
- * execution path.
1273
+ * execution path. The query string is not parsed for page middleware; read it from `request.url`.
1282
1274
  */
1283
- export interface FileRouteMiddlewareContext<TRequest extends Request = Request, TServer = any> extends Omit<ApiHandlerContext<TRequest, TServer>, 'render' | 'renderPartial' | 'importServerModule' | 'renderServerModule'> {
1275
+ export interface FileRouteMiddlewareContext<TRequest extends Request = Request, TServer = any> extends Omit<ApiHandlerContext<TRequest, TServer>, 'render' | 'renderPartial' | 'importServerModule' | 'renderServerModule' | 'query'> {
1284
1276
  }
1285
1277
  /**
1286
1278
  * Next function for middleware chain.
1287
1279
  * Call to continue to the next middleware or final handler.
1288
1280
  */
1289
- type MiddlewareNext = () => Promise<Response>;
1281
+ export type MiddlewareNext = () => Promise<Response>;
1290
1282
  /**
1291
1283
  * Middleware function signature.
1292
1284
  * Receives the request context and a next function to continue the chain.
@@ -1342,6 +1334,11 @@ export type FileRouteMiddleware<TRequest extends Request = Request, TServer = an
1342
1334
  * ```
1343
1335
  */
1344
1336
  export type EcoMiddleware<TContext extends ApiHandlerContext<any, any>> = TContext extends ApiHandlerContext<infer TRequest, infer TServer> ? Middleware<TRequest, TServer, TContext> : never;
1337
+ /**
1338
+ * The request methods an `ApiHandler` answers, in the order an endpoint's `Allow` header lists them.
1339
+ */
1340
+ export declare const API_HANDLER_METHODS: readonly ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD", "QUERY"];
1341
+ export type ApiHandlerMethod = (typeof API_HANDLER_METHODS)[number];
1345
1342
  /**
1346
1343
  * Represents an API handler in EcoPages.
1347
1344
  * Defines the path, method, handler function, optional middleware, and validation schemas.
@@ -1403,11 +1400,15 @@ export type EcoMiddleware<TContext extends ApiHandlerContext<any, any>> = TConte
1403
1400
  * ```
1404
1401
  */
1405
1402
  export interface ApiHandler<TPath extends string = string, TRequest extends Request = Request, TServer = any> {
1403
+ /**
1404
+ * The URL pattern. `''` for a handler built without `path`, which an endpoint file exports;
1405
+ * its Template Route gives the URL.
1406
+ */
1406
1407
  path: TPath;
1407
- method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
1408
+ method: ApiHandlerMethod;
1408
1409
  handler: (context: ApiHandlerContext<TRequest, TServer>) => Promise<Response> | Response;
1409
1410
  /** Optional middleware chain executed before the handler */
1410
- middleware?: Middleware<TRequest, TServer, any>[];
1411
+ middleware?: MiddlewareList<TRequest, TServer>;
1411
1412
  /** Optional validation schemas for request body, query parameters, and headers */
1412
1413
  schema?: {
1413
1414
  body?: StandardSchema;
@@ -1424,11 +1425,38 @@ export interface ApiHandler<TPath extends string = string, TRequest extends Requ
1424
1425
  export type ErrorHandler<TRequest extends Request = Request, TServer = any> = (error: unknown, context: ApiHandlerContext<TRequest, TServer>) => Promise<Response> | Response;
1425
1426
  /**
1426
1427
  * Options for route handlers.
1428
+ *
1429
+ * @typeParam TMiddleware - The route's middleware; inferred as a tuple so the handler sees what each one adds
1430
+ * @typeParam TSchema - The route's schema; each field it declares types the matching context field
1427
1431
  */
1428
- export interface RouteOptions<TRequest extends Request = Request, TServer = any, TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>> {
1429
- middleware?: Middleware<TRequest, TServer, TContext>[];
1430
- schema?: RouteSchema;
1432
+ export interface RouteOptions<TRequest extends Request = Request, TServer = any, TSchema extends RouteSchema = RouteSchema, TMiddleware extends MiddlewareList<TRequest, TServer> = MiddlewareList<TRequest, TServer>> {
1433
+ middleware?: TMiddleware;
1434
+ schema?: TSchema;
1431
1435
  }
1436
+ /**
1437
+ * A middleware list, whatever context each middleware declares.
1438
+ *
1439
+ * @remarks
1440
+ * Each element is a method signature, so its context parameter is checked bivariantly: a middleware typed with
1441
+ * the wider context it adds, such as `EcoMiddleware<AuthContext>`, still fits. An inline middleware function in
1442
+ * the list is typed with the base context, also inside a group; type it as `EcoMiddleware` to read what the
1443
+ * group middleware adds. A list holding an unannotated inline function is inferred only after the arguments before it, so a handler
1444
+ * written before the list (`app.get(path, handler, options)`, or `handler` before `middleware` in a define call)
1445
+ * sees none of the list's contexts. Put `middleware` first, or declare the inline function as a `Middleware` constant.
1446
+ */
1447
+ export type MiddlewareList<TRequest extends Request = Request, TServer = any> = readonly {
1448
+ middleware(context: ApiHandlerContext<TRequest, TServer>, next: MiddlewareNext): Promise<Response> | Response;
1449
+ }['middleware'][];
1450
+ /**
1451
+ * The context a list of middleware adds: the intersection of the context each one declares.
1452
+ *
1453
+ * @remarks
1454
+ * Inferring one parameter from the union of the middleware types, a contravariant position, yields the
1455
+ * intersection of their contexts. An empty list adds nothing.
1456
+ */
1457
+ export type MiddlewareContext<TMiddleware extends readonly unknown[]> = [TMiddleware[number]] extends [
1458
+ (context: infer TAdded, next: never) => unknown
1459
+ ] ? [TAdded] extends [never] ? unknown : TAdded : unknown;
1432
1460
  export interface RouteSchema {
1433
1461
  body?: StandardSchema;
1434
1462
  query?: StandardSchema;
@@ -1436,51 +1464,49 @@ export interface RouteSchema {
1436
1464
  params?: StandardSchema;
1437
1465
  }
1438
1466
  /**
1439
- * Helper type to extract inferred types from a schema, with fallback to unknown.
1467
+ * The context a handler receives: the base or middleware context, with each field the schema declares
1468
+ * replaced by that schema's output.
1469
+ *
1470
+ * @remarks
1471
+ * A field the schema omits keeps the type it has on `TContext`, so a schema with only `body` still
1472
+ * gives `params` as {@link PageParams}. `params` is typed only by `TSchema['params']`; the route's
1473
+ * path string never narrows it.
1440
1474
  */
1441
- type InferSchemaOutput<T> = T extends StandardSchema ? InferOutput<T> : unknown;
1475
+ export type RouteHandlerContext<TSchema extends RouteSchema, TContext extends ApiHandlerContext<any, any>> = Omit<TContext, RouteSchemaField> & {
1476
+ [K in RouteSchemaField]: TSchema[K] extends StandardSchema ? InferOutput<TSchema[K]> : TContext[K];
1477
+ };
1442
1478
  /**
1443
- * Context type that combines schema-typed fields with an extended base context.
1444
- * Used by RouteGroupBuilder to merge schema validation types with middleware-extended context.
1445
- * Note: Path parameter typing (e.g., :id -> params.id) comes from the TContext.request type.
1479
+ * @remarks
1480
+ * Mapping over this alias instead of `keyof RouteSchema` keeps the mapped type from copying the optional
1481
+ * modifiers of {@link RouteSchema}, so each field is required and an optional schema still types its
1482
+ * output with `undefined`.
1446
1483
  */
1447
- export type TypedGroupHandlerContext<TSchema extends RouteSchema, TContext extends ApiHandlerContext<any, any>> = Omit<TContext, 'body' | 'query' | 'headers' | 'params'> & {
1448
- body: InferSchemaOutput<TSchema['body']>;
1449
- query: InferSchemaOutput<TSchema['query']>;
1450
- headers: InferSchemaOutput<TSchema['headers']>;
1451
- params: InferSchemaOutput<TSchema['params']>;
1452
- };
1484
+ type RouteSchemaField = keyof RouteSchema;
1485
+ /**
1486
+ * Registers an inline route: the handler is typed from the route's `schema` and from the context every
1487
+ * one of its `middleware` adds on top of `TContext`.
1488
+ *
1489
+ * @typeParam TReturn - What the call returns, for chaining
1490
+ * @typeParam TContext - The context the route starts from: the base context, or the group's
1491
+ *
1492
+ * @remarks
1493
+ * `TRouteContext` has no inference site; passing it explicitly types a context that the route's
1494
+ * middleware list does not declare.
1495
+ */
1496
+ export type RouteMethod<TReturn, TRequest extends Request = Request, TServer = any, TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>> = <TSchema extends RouteSchema = RouteSchema, TRouteContext extends TContext = TContext, const TMiddleware extends MiddlewareList<TRequest, TServer> = MiddlewareList<TRequest, TServer>>(path: string, handler: (context: RouteHandlerContext<TSchema, TRouteContext & MiddlewareContext<TMiddleware>>) => Promise<Response> | Response, options?: RouteOptions<TRequest, TServer, TSchema, TMiddleware>) => TReturn;
1453
1497
  /**
1454
- * Builder interface for defining routes within a group.
1498
+ * Builder for defining routes within a group, one method per HTTP method.
1455
1499
  * Provides chainable methods for registering routes with shared prefix and middleware.
1456
1500
  *
1457
1501
  * @typeParam TRequest - The request type
1458
1502
  * @typeParam TServer - The server type
1459
1503
  * @typeParam TContext - Extended context type from group middleware
1504
+ *
1505
+ * @remarks `query` registers the HTTP QUERY method, not a handler for `ctx.query`.
1460
1506
  */
1461
- export interface RouteGroupBuilder<TRequest extends Request = Request, TServer = any, TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>> {
1462
- get<P extends string, TSchema extends RouteSchema = RouteSchema>(path: P, handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response, options?: RouteOptions<TRequest, TServer, TContext> & {
1463
- schema?: TSchema;
1464
- }): RouteGroupBuilder<TRequest, TServer, TContext>;
1465
- post<P extends string, TSchema extends RouteSchema = RouteSchema>(path: P, handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response, options?: RouteOptions<TRequest, TServer, TContext> & {
1466
- schema?: TSchema;
1467
- }): RouteGroupBuilder<TRequest, TServer, TContext>;
1468
- put<P extends string, TSchema extends RouteSchema = RouteSchema>(path: P, handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response, options?: RouteOptions<TRequest, TServer, TContext> & {
1469
- schema?: TSchema;
1470
- }): RouteGroupBuilder<TRequest, TServer, TContext>;
1471
- delete<P extends string, TSchema extends RouteSchema = RouteSchema>(path: P, handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response, options?: RouteOptions<TRequest, TServer, TContext> & {
1472
- schema?: TSchema;
1473
- }): RouteGroupBuilder<TRequest, TServer, TContext>;
1474
- patch<P extends string, TSchema extends RouteSchema = RouteSchema>(path: P, handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response, options?: RouteOptions<TRequest, TServer, TContext> & {
1475
- schema?: TSchema;
1476
- }): RouteGroupBuilder<TRequest, TServer, TContext>;
1477
- options<P extends string, TSchema extends RouteSchema = RouteSchema>(path: P, handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response, options?: RouteOptions<TRequest, TServer, TContext> & {
1478
- schema?: TSchema;
1479
- }): RouteGroupBuilder<TRequest, TServer, TContext>;
1480
- head<P extends string, TSchema extends RouteSchema = RouteSchema>(path: P, handler: (context: TypedGroupHandlerContext<TSchema, TContext>) => Promise<Response> | Response, options?: RouteOptions<TRequest, TServer, TContext> & {
1481
- schema?: TSchema;
1482
- }): RouteGroupBuilder<TRequest, TServer, TContext>;
1483
- }
1507
+ export type RouteGroupBuilder<TRequest extends Request = Request, TServer = any, TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>> = {
1508
+ [M in ApiHandler['method'] as Lowercase<M>]: RouteMethod<RouteGroupBuilder<TRequest, TServer, TContext>, TRequest, TServer, TContext>;
1509
+ };
1484
1510
  /**
1485
1511
  * A function that dynamically imports a view module.
1486
1512
  * Used by `app.static()` and the HTML error-page helpers (`app.notFound()`,
@@ -1 +1,4 @@
1
- export {};
1
+ /**
2
+ * The request methods an `ApiHandler` answers, in the order an endpoint's `Allow` header lists them.
3
+ */
4
+ export const API_HANDLER_METHODS = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD', 'QUERY'];
@@ -1,3 +1,3 @@
1
- export type { ApiHandler, ApiHandlerContext, EcoComponent, EcoComponentConfig, EcoComponentDependencies, DependencyAttributes, EcoChildren, EcoFunctionComponent, EcoPageComponent, EcoPageFile, EcoPagesAppConfig, EcoPagesElement, EcoPageLayoutEntry, EcoPageLayoutSpec, EcoPageLayouts, EcoHtmlComponent, EcoLayoutComponent, EcoMiddleware, ErrorHandler, ErrorPageTemplateProps, EcopagesRouteInfo, EcopagesSocket, EcopagesWebSocketHandler, FileRouteMiddleware, FileRouteMiddlewareContext, FileOwnedDependencyContribution, GetPageDependencies, GetPageDependenciesContext, GetMetadata, GetMetadataContext, GetStaticPaths, GetStaticProps, HtmlTemplateProps, LayoutProps, LayoutPropsContext, Middleware, OutgoingWebSocketMessage, IncomingWebSocketMessage, PageHeadProps, PageMetadataProps, PageParams, PageQuery, PageDependenciesInput, PageDependenciesResult, PageProps, PagePropsFor, PageRequires, PageRobotsMetadata, RequestLocals, RequestPageContext, RenderContext, RenderOptions, RouteGroupBuilder, RouteOptions, RouteSchema, SitemapConfig, StandardSchema, StandardSchemaFailureResult, StandardSchemaIssue, StandardSchemaResult, StandardSchemaSuccessResult, StandardSchemaV1, StaticPageContext, StaticPath, TypedGroupHandlerContext, WebSocketCloseInfo, WithLocals, } from './contracts.js';
1
+ export type { ApiHandler, ApiHandlerContext, EcoComponent, EcoComponentConfig, EcoComponentDependencies, DependencyAttributes, EcoChildren, EcoFunctionComponent, EcoPageComponent, EcoPageFile, EcoPagesAppConfig, EcoPagesElement, EcoPageLayoutEntry, EcoPageLayoutSpec, EcoPageLayouts, EcoHtmlComponent, EcoLayoutComponent, EcoMiddleware, ErrorHandler, ErrorPageTemplateProps, EcopagesRouteInfo, EcopagesSocket, EcopagesWebSocketHandler, FileRouteMiddleware, FileRouteMiddlewareContext, FileOwnedDependencyContribution, GetPageDependencies, GetPageDependenciesContext, GetMetadata, GetMetadataContext, GetStaticPaths, GetStaticProps, HtmlTemplateProps, LayoutProps, LayoutPropsContext, Middleware, MiddlewareList, MiddlewareNext, OutgoingWebSocketMessage, IncomingWebSocketMessage, PageHeadProps, PageMetadataProps, PageParams, PageQuery, PageDependenciesInput, PageDependenciesResult, PageProps, PagePropsFor, PageRequires, PageRobotsMetadata, RequestLocals, RequestPageContext, RenderContext, RenderOptions, RouteGroupBuilder, RouteHandlerContext, RouteMethod, RouteOptions, RouteSchema, SitemapConfig, StandardSchema, StandardSchemaFailureResult, StandardSchemaIssue, StandardSchemaResult, StandardSchemaSuccessResult, StandardSchemaV1, StaticPageContext, StaticPath, WebSocketCloseInfo, WithLocals, } from './contracts.js';
2
2
  export type { CacheConfig, CacheStrategy } from './cache-types.js';
3
3
  export type { CallableComponentOf, ChildrenOf, ComponentOptions, Eco, EcoEmbedProps, EmbedPropsOf, HtmlOptions, LayoutOptions, LazyTrigger, PageOptions, PageOptionsBase, PagePropsForWithLocals, PropsOf, ResultOf, } from './eco-api-types.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Suffixes that mark a file under the pages directory as an endpoint rather than a Page: `.api.`
3
+ * followed by a script extension the server-module loader compiles.
4
+ *
5
+ * @remarks
6
+ * Never a template extension: an endpoint has no Integration owner, Layout or Cache Strategy, so
7
+ * config assembly rejects an Integration whose extensions end in one of these.
8
+ */
9
+ export declare const ENDPOINT_FILE_EXTENSIONS: readonly string[];
10
+ /** Returns the endpoint marker `file` ends with, or `undefined` for any other file. */
11
+ export declare function findEndpointFileExtension(file: string): string | undefined;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Suffixes that mark a file under the pages directory as an endpoint rather than a Page: `.api.`
3
+ * followed by a script extension the server-module loader compiles.
4
+ *
5
+ * @remarks
6
+ * Never a template extension: an endpoint has no Integration owner, Layout or Cache Strategy, so
7
+ * config assembly rejects an Integration whose extensions end in one of these.
8
+ */
9
+ export const ENDPOINT_FILE_EXTENSIONS = ['.api.ts', '.api.tsx', '.api.js', '.api.jsx'];
10
+ /** Returns the endpoint marker `file` ends with, or `undefined` for any other file. */
11
+ export function findEndpointFileExtension(file) {
12
+ return ENDPOINT_FILE_EXTENSIONS.find((extension) => file.endsWith(extension));
13
+ }