@jaypie/fabric 0.1.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.
- package/README.md +677 -0
- package/dist/cjs/commander/FabricCommander.d.ts +94 -0
- package/dist/cjs/commander/createCommanderOptions.d.ts +25 -0
- package/dist/cjs/commander/fabricCommand.d.ts +43 -0
- package/dist/cjs/commander/index.cjs +1487 -0
- package/dist/cjs/commander/index.cjs.map +1 -0
- package/dist/cjs/commander/index.d.ts +6 -0
- package/dist/cjs/commander/parseCommanderOptions.d.ts +32 -0
- package/dist/cjs/commander/registerServiceCommand.d.ts +43 -0
- package/dist/cjs/commander/types.d.ts +107 -0
- package/dist/cjs/constants.d.ts +12 -0
- package/dist/cjs/convert-date.d.ts +47 -0
- package/dist/cjs/convert.d.ts +69 -0
- package/dist/cjs/data/FabricData.d.ts +42 -0
- package/dist/cjs/data/index.cjs +1575 -0
- package/dist/cjs/data/index.cjs.map +1 -0
- package/dist/cjs/data/index.d.ts +5 -0
- package/dist/cjs/data/services/archive.d.ts +8 -0
- package/dist/cjs/data/services/create.d.ts +8 -0
- package/dist/cjs/data/services/delete.d.ts +8 -0
- package/dist/cjs/data/services/execute.d.ts +8 -0
- package/dist/cjs/data/services/index.d.ts +7 -0
- package/dist/cjs/data/services/list.d.ts +8 -0
- package/dist/cjs/data/services/read.d.ts +8 -0
- package/dist/cjs/data/services/update.d.ts +8 -0
- package/dist/cjs/data/transforms.d.ts +80 -0
- package/dist/cjs/data/types.d.ts +190 -0
- package/dist/cjs/express/FabricRouter.d.ts +29 -0
- package/dist/cjs/express/fabricExpress.d.ts +16 -0
- package/dist/cjs/express/index.cjs +505 -0
- package/dist/cjs/express/index.cjs.map +1 -0
- package/dist/cjs/express/index.d.ts +3 -0
- package/dist/cjs/express/types.d.ts +51 -0
- package/dist/cjs/helpers/fallback.d.ts +21 -0
- package/dist/cjs/helpers/index.d.ts +3 -0
- package/dist/cjs/helpers/resolvedName.d.ts +24 -0
- package/dist/cjs/http/FabricHttpServer.d.ts +31 -0
- package/dist/cjs/http/authorization.d.ts +30 -0
- package/dist/cjs/http/cors.d.ts +40 -0
- package/dist/cjs/http/fabricHttp.d.ts +28 -0
- package/dist/cjs/http/httpTransform.d.ts +36 -0
- package/dist/cjs/http/index.cjs +1820 -0
- package/dist/cjs/http/index.cjs.map +1 -0
- package/dist/cjs/http/index.d.ts +10 -0
- package/dist/cjs/http/stream.d.ts +185 -0
- package/dist/cjs/http/types.d.ts +343 -0
- package/dist/cjs/index/index.d.ts +8 -0
- package/dist/cjs/index/keyBuilder.d.ts +81 -0
- package/dist/cjs/index/registry.d.ts +56 -0
- package/dist/cjs/index/types.d.ts +54 -0
- package/dist/cjs/index.cjs +1674 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.ts +18 -0
- package/dist/cjs/lambda/createLambdaService.d.ts +33 -0
- package/dist/cjs/lambda/fabricLambda.d.ts +36 -0
- package/dist/cjs/lambda/index.cjs +967 -0
- package/dist/cjs/lambda/index.cjs.map +1 -0
- package/dist/cjs/lambda/index.d.ts +2 -0
- package/dist/cjs/lambda/types.d.ts +68 -0
- package/dist/cjs/llm/createLlmTool.d.ts +40 -0
- package/dist/cjs/llm/fabricTool.d.ts +40 -0
- package/dist/cjs/llm/index.cjs +1107 -0
- package/dist/cjs/llm/index.cjs.map +1 -0
- package/dist/cjs/llm/index.d.ts +3 -0
- package/dist/cjs/llm/inputToJsonSchema.d.ts +32 -0
- package/dist/cjs/llm/types.d.ts +61 -0
- package/dist/cjs/mcp/fabricMcp.d.ts +38 -0
- package/dist/cjs/mcp/index.cjs +938 -0
- package/dist/cjs/mcp/index.cjs.map +1 -0
- package/dist/cjs/mcp/index.d.ts +2 -0
- package/dist/cjs/mcp/registerMcpTool.d.ts +38 -0
- package/dist/cjs/mcp/types.d.ts +60 -0
- package/dist/cjs/models/base.d.ts +209 -0
- package/dist/cjs/resolve-date.d.ts +47 -0
- package/dist/cjs/resolve.d.ts +69 -0
- package/dist/cjs/resolveService.d.ts +49 -0
- package/dist/cjs/service.d.ts +13 -0
- package/dist/cjs/status.d.ts +30 -0
- package/dist/cjs/types/elementaryTypes.d.ts +84 -0
- package/dist/cjs/types/fieldCategory.d.ts +20 -0
- package/dist/cjs/types/fieldDefinition.d.ts +46 -0
- package/dist/cjs/types/index.d.ts +4 -0
- package/dist/cjs/types.d.ts +56 -0
- package/dist/esm/commander/FabricCommander.d.ts +94 -0
- package/dist/esm/commander/createCommanderOptions.d.ts +25 -0
- package/dist/esm/commander/fabricCommand.d.ts +43 -0
- package/dist/esm/commander/index.d.ts +6 -0
- package/dist/esm/commander/index.js +1482 -0
- package/dist/esm/commander/index.js.map +1 -0
- package/dist/esm/commander/parseCommanderOptions.d.ts +32 -0
- package/dist/esm/commander/registerServiceCommand.d.ts +43 -0
- package/dist/esm/commander/types.d.ts +107 -0
- package/dist/esm/constants.d.ts +12 -0
- package/dist/esm/convert-date.d.ts +47 -0
- package/dist/esm/convert.d.ts +69 -0
- package/dist/esm/data/FabricData.d.ts +42 -0
- package/dist/esm/data/index.d.ts +5 -0
- package/dist/esm/data/index.js +1548 -0
- package/dist/esm/data/index.js.map +1 -0
- package/dist/esm/data/services/archive.d.ts +8 -0
- package/dist/esm/data/services/create.d.ts +8 -0
- package/dist/esm/data/services/delete.d.ts +8 -0
- package/dist/esm/data/services/execute.d.ts +8 -0
- package/dist/esm/data/services/index.d.ts +7 -0
- package/dist/esm/data/services/list.d.ts +8 -0
- package/dist/esm/data/services/read.d.ts +8 -0
- package/dist/esm/data/services/update.d.ts +8 -0
- package/dist/esm/data/transforms.d.ts +80 -0
- package/dist/esm/data/types.d.ts +190 -0
- package/dist/esm/express/FabricRouter.d.ts +29 -0
- package/dist/esm/express/fabricExpress.d.ts +16 -0
- package/dist/esm/express/index.d.ts +3 -0
- package/dist/esm/express/index.js +500 -0
- package/dist/esm/express/index.js.map +1 -0
- package/dist/esm/express/types.d.ts +51 -0
- package/dist/esm/helpers/fallback.d.ts +21 -0
- package/dist/esm/helpers/index.d.ts +3 -0
- package/dist/esm/helpers/resolvedName.d.ts +24 -0
- package/dist/esm/http/FabricHttpServer.d.ts +31 -0
- package/dist/esm/http/authorization.d.ts +30 -0
- package/dist/esm/http/cors.d.ts +40 -0
- package/dist/esm/http/fabricHttp.d.ts +28 -0
- package/dist/esm/http/httpTransform.d.ts +36 -0
- package/dist/esm/http/index.d.ts +10 -0
- package/dist/esm/http/index.js +1775 -0
- package/dist/esm/http/index.js.map +1 -0
- package/dist/esm/http/stream.d.ts +185 -0
- package/dist/esm/http/types.d.ts +343 -0
- package/dist/esm/index/index.d.ts +8 -0
- package/dist/esm/index/keyBuilder.d.ts +81 -0
- package/dist/esm/index/registry.d.ts +56 -0
- package/dist/esm/index/types.d.ts +54 -0
- package/dist/esm/index.d.ts +18 -0
- package/dist/esm/index.js +1606 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lambda/createLambdaService.d.ts +33 -0
- package/dist/esm/lambda/fabricLambda.d.ts +36 -0
- package/dist/esm/lambda/index.d.ts +2 -0
- package/dist/esm/lambda/index.js +965 -0
- package/dist/esm/lambda/index.js.map +1 -0
- package/dist/esm/lambda/types.d.ts +68 -0
- package/dist/esm/llm/createLlmTool.d.ts +40 -0
- package/dist/esm/llm/fabricTool.d.ts +40 -0
- package/dist/esm/llm/index.d.ts +3 -0
- package/dist/esm/llm/index.js +1104 -0
- package/dist/esm/llm/index.js.map +1 -0
- package/dist/esm/llm/inputToJsonSchema.d.ts +32 -0
- package/dist/esm/llm/types.d.ts +61 -0
- package/dist/esm/mcp/fabricMcp.d.ts +38 -0
- package/dist/esm/mcp/index.d.ts +2 -0
- package/dist/esm/mcp/index.js +936 -0
- package/dist/esm/mcp/index.js.map +1 -0
- package/dist/esm/mcp/registerMcpTool.d.ts +38 -0
- package/dist/esm/mcp/types.d.ts +60 -0
- package/dist/esm/models/base.d.ts +209 -0
- package/dist/esm/resolve-date.d.ts +47 -0
- package/dist/esm/resolve.d.ts +69 -0
- package/dist/esm/resolveService.d.ts +49 -0
- package/dist/esm/service.d.ts +13 -0
- package/dist/esm/status.d.ts +30 -0
- package/dist/esm/types/elementaryTypes.d.ts +84 -0
- package/dist/esm/types/fieldCategory.d.ts +20 -0
- package/dist/esm/types/fieldDefinition.d.ts +46 -0
- package/dist/esm/types/index.d.ts +4 -0
- package/dist/esm/types.d.ts +56 -0
- package/package.json +122 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Request, RequestHandler, Response, Router } from "express";
|
|
2
|
+
import type { AuthorizationConfig, CorsOption, FabricHttpService, HttpMethod } from "../http/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for fabricExpress middleware
|
|
5
|
+
*/
|
|
6
|
+
export interface FabricExpressConfig<TInput extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown, TAuth = unknown> {
|
|
7
|
+
/** The fabric HTTP service to wrap */
|
|
8
|
+
service: FabricHttpService<TInput, TOutput, TAuth>;
|
|
9
|
+
/** Override path pattern (defaults to /${alias}) */
|
|
10
|
+
path?: string;
|
|
11
|
+
/** HTTP methods to handle (defaults to DEFAULT_HTTP_METHODS) */
|
|
12
|
+
methods?: HttpMethod[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Express middleware returned by fabricExpress
|
|
16
|
+
*/
|
|
17
|
+
export interface FabricExpressMiddleware extends RequestHandler {
|
|
18
|
+
/** The wrapped fabric HTTP service */
|
|
19
|
+
service: FabricHttpService;
|
|
20
|
+
/** Path pattern for the middleware */
|
|
21
|
+
path: string;
|
|
22
|
+
/** HTTP methods handled */
|
|
23
|
+
methods: HttpMethod[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Service entry for FabricRouter - either a service or a config object
|
|
27
|
+
*/
|
|
28
|
+
export type FabricRouterServiceEntry<TInput extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown, TAuth = unknown> = FabricHttpService<TInput, TOutput, TAuth> | FabricExpressConfig<TInput, TOutput, TAuth>;
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for FabricRouter
|
|
31
|
+
*/
|
|
32
|
+
export interface FabricRouterConfig {
|
|
33
|
+
/** Services to register in the router */
|
|
34
|
+
services: FabricRouterServiceEntry[];
|
|
35
|
+
/** Global authorization (applied to all services without their own) */
|
|
36
|
+
authorization?: AuthorizationConfig;
|
|
37
|
+
/** Global CORS configuration */
|
|
38
|
+
cors?: CorsOption;
|
|
39
|
+
/** Prefix for all routes (e.g., "/api" or "/v1") */
|
|
40
|
+
prefix?: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Extended Express Router with fabric metadata
|
|
44
|
+
*/
|
|
45
|
+
export interface FabricExpressRouter extends Router {
|
|
46
|
+
/** Registered services */
|
|
47
|
+
services: FabricHttpService[];
|
|
48
|
+
/** Route prefix */
|
|
49
|
+
prefix?: string;
|
|
50
|
+
}
|
|
51
|
+
export type { Request, Response, Router };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fallback Resolution Helper
|
|
3
|
+
*
|
|
4
|
+
* Resolves a field value with a fallback chain.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a field value with fallbacks
|
|
8
|
+
*
|
|
9
|
+
* @param entity - The entity to read from
|
|
10
|
+
* @param field - The primary field name
|
|
11
|
+
* @param fallbacks - Fallback field names in priority order
|
|
12
|
+
* @returns First defined value, or undefined
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const model = { title: undefined, name: "My Model", description: "A description" };
|
|
17
|
+
* resolveWithFallback(model, "title", ["name", "description"]);
|
|
18
|
+
* // Returns "My Model"
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveWithFallback(entity: Record<string, unknown>, field: string, fallbacks?: string[]): unknown;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolved Name Helper
|
|
3
|
+
*
|
|
4
|
+
* Computes a resolved name from model fields using a priority chain.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Model with optional name fields
|
|
8
|
+
*/
|
|
9
|
+
export interface ResolvedNameModel {
|
|
10
|
+
abbreviation?: string;
|
|
11
|
+
alias?: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Compute resolved name from model fields
|
|
17
|
+
*
|
|
18
|
+
* Priority: name > alias > abbreviation > description
|
|
19
|
+
* Result is lowercase for consistent sorting/indexing
|
|
20
|
+
*
|
|
21
|
+
* @param model - The model to compute the resolved name from
|
|
22
|
+
* @returns The resolved name (lowercase) or undefined if no name fields exist
|
|
23
|
+
*/
|
|
24
|
+
export declare function computeResolvedName(model: ResolvedNameModel): string | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { FabricHttpServer as FabricHttpServerType, FabricHttpServerConfig } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Create a standalone HTTP server for Lambda
|
|
4
|
+
*
|
|
5
|
+
* Routes multiple FabricHttpService instances without Express:
|
|
6
|
+
* - Parses API Gateway v1 and v2 events
|
|
7
|
+
* - Matches routes by path pattern and HTTP method
|
|
8
|
+
* - Handles CORS preflight and response headers
|
|
9
|
+
* - Returns JSON:API formatted responses
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { FabricHttpServer } from "@jaypie/fabric/http";
|
|
14
|
+
* import { lambdaHandler } from "@jaypie/lambda";
|
|
15
|
+
*
|
|
16
|
+
* const server = FabricHttpServer({
|
|
17
|
+
* services: [
|
|
18
|
+
* userService,
|
|
19
|
+
* { service: productService, path: "/products/:id", methods: ["GET", "PUT"] },
|
|
20
|
+
* ],
|
|
21
|
+
* prefix: "/api",
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* export const handler = lambdaHandler(server);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function FabricHttpServer(config: FabricHttpServerConfig): FabricHttpServerType;
|
|
28
|
+
/**
|
|
29
|
+
* Check if a value is a FabricHttpServer
|
|
30
|
+
*/
|
|
31
|
+
export declare function isFabricHttpServer(value: unknown): value is FabricHttpServerType;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AuthorizationConfig } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Extract token from Authorization header
|
|
4
|
+
* Removes "Bearer " prefix (case insensitive) and strips whitespace
|
|
5
|
+
*
|
|
6
|
+
* Examples:
|
|
7
|
+
* - "Bearer eyJhbGc..." → "eyJhbGc..."
|
|
8
|
+
* - "bearer eyJhbGc..." → "eyJhbGc..."
|
|
9
|
+
* - "BEARER eyJhbGc..." → "eyJhbGc..."
|
|
10
|
+
* - "eyJhbGc..." → "eyJhbGc..."
|
|
11
|
+
* - " eyJhbGc... " → "eyJhbGc..."
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractToken(authHeader: string | null | undefined): string;
|
|
14
|
+
/**
|
|
15
|
+
* Get authorization header from Headers object
|
|
16
|
+
*/
|
|
17
|
+
export declare function getAuthHeader(headers: Headers): string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Validate authorization and return auth context
|
|
20
|
+
*
|
|
21
|
+
* @param headers - Request headers
|
|
22
|
+
* @param config - Authorization configuration (function or false)
|
|
23
|
+
* @returns Auth context from the authorization function, or undefined if public
|
|
24
|
+
* @throws UnauthorizedError if authorization fails
|
|
25
|
+
*/
|
|
26
|
+
export declare function validateAuthorization<TAuth = unknown>(headers: Headers, config: AuthorizationConfig<TAuth>): Promise<TAuth | undefined>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if authorization is required
|
|
29
|
+
*/
|
|
30
|
+
export declare function isAuthorizationRequired(config: AuthorizationConfig<unknown>): boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CorsConfig, CorsHeaders, CorsOption, HttpMethod } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default CORS configuration
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_CORS_CONFIG: CorsConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Default allowed methods for CORS
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_CORS_METHODS: HttpMethod[];
|
|
10
|
+
/**
|
|
11
|
+
* Normalize CORS option to CorsConfig
|
|
12
|
+
* - true → default config
|
|
13
|
+
* - false → disabled (returns undefined)
|
|
14
|
+
* - CorsConfig → merged with defaults
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeCorsConfig(option: CorsOption | undefined): CorsConfig | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Get the allowed origin for a request
|
|
19
|
+
* @param config - CORS configuration
|
|
20
|
+
* @param requestOrigin - Origin header from request
|
|
21
|
+
* @returns The origin to allow, or undefined if not allowed
|
|
22
|
+
*/
|
|
23
|
+
export declare function getAllowedOrigin(config: CorsConfig, requestOrigin: string | null): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Build CORS headers for a response
|
|
26
|
+
* @param config - CORS configuration
|
|
27
|
+
* @param requestOrigin - Origin header from request
|
|
28
|
+
* @param methods - Allowed HTTP methods
|
|
29
|
+
* @returns Object with CORS headers, or empty object if CORS is disabled
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildCorsHeaders(config: CorsConfig | undefined, requestOrigin: string | null, methods?: HttpMethod[]): CorsHeaders;
|
|
32
|
+
/**
|
|
33
|
+
* Check if request is a CORS preflight request
|
|
34
|
+
*/
|
|
35
|
+
export declare function isPreflightRequest(method: string, headers: Headers): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Build preflight response headers
|
|
38
|
+
* Includes all CORS headers needed for preflight response
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildPreflightHeaders(config: CorsConfig | undefined, requestOrigin: string | null, requestMethod: string | null, requestHeaders: string | null, methods?: HttpMethod[]): CorsHeaders;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ServiceContext } from "../types.js";
|
|
2
|
+
import type { FabricHttpConfig, FabricHttpService, HttpContext } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Extended service context with auth information
|
|
5
|
+
*/
|
|
6
|
+
export interface HttpServiceContext<TAuth = unknown> extends ServiceContext {
|
|
7
|
+
/** Authorization result (returned from authorization function) */
|
|
8
|
+
auth?: TAuth;
|
|
9
|
+
/** HTTP context for advanced use cases */
|
|
10
|
+
http?: HttpContext;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Create an HTTP-aware fabric service
|
|
14
|
+
*
|
|
15
|
+
* Extends fabricService with:
|
|
16
|
+
* - HTTP context transformation (body, headers, method, path, query, params)
|
|
17
|
+
* - Authorization handling (token extraction from Authorization header)
|
|
18
|
+
* - CORS configuration (enabled by default)
|
|
19
|
+
*
|
|
20
|
+
* Accepts either:
|
|
21
|
+
* - Inline service definition (with `service` function)
|
|
22
|
+
* - Pre-built `fabricService` instance (via `service` property)
|
|
23
|
+
*/
|
|
24
|
+
export declare function fabricHttp<TInput extends Record<string, unknown> = Record<string, unknown>, TOutput = unknown, TAuth = unknown>(config: FabricHttpConfig<TInput, TOutput, TAuth>): FabricHttpService<TInput, TOutput, TAuth>;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a service is an HTTP service (has http, authorization, cors properties)
|
|
27
|
+
*/
|
|
28
|
+
export declare function isFabricHttpService<TInput extends Record<string, unknown>, TOutput, TAuth>(value: unknown): value is FabricHttpService<TInput, TOutput, TAuth>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HttpContext, HttpTransformFunction } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default HTTP transformation function
|
|
4
|
+
* Merges query parameters with body (body takes precedence)
|
|
5
|
+
*/
|
|
6
|
+
export declare const defaultHttpTransform: HttpTransformFunction;
|
|
7
|
+
/**
|
|
8
|
+
* Parse query string into URLSearchParams
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseQueryString(queryString: string): URLSearchParams;
|
|
11
|
+
/**
|
|
12
|
+
* Parse path parameters from a URL path using a route pattern
|
|
13
|
+
* @param path - The actual URL path (e.g., "/users/123")
|
|
14
|
+
* @param pattern - The route pattern (e.g., "/users/:id")
|
|
15
|
+
* @returns Object with extracted parameters
|
|
16
|
+
*/
|
|
17
|
+
export declare function parsePathParams(path: string, pattern: string): Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Parse request body from string or return as-is if already parsed
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseBody(body: unknown): unknown;
|
|
22
|
+
/**
|
|
23
|
+
* Create HTTP context from raw request data
|
|
24
|
+
*/
|
|
25
|
+
export declare function createHttpContext(options: {
|
|
26
|
+
body?: unknown;
|
|
27
|
+
headers?: Headers | Record<string, string>;
|
|
28
|
+
method?: string;
|
|
29
|
+
path?: string;
|
|
30
|
+
queryString?: string;
|
|
31
|
+
params?: Record<string, string>;
|
|
32
|
+
}): HttpContext;
|
|
33
|
+
/**
|
|
34
|
+
* Apply HTTP transformation to get service input
|
|
35
|
+
*/
|
|
36
|
+
export declare function transformHttpToInput<TInput = Record<string, unknown>>(context: HttpContext, transform?: HttpTransformFunction<TInput>): Promise<TInput>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { fabricHttp, isFabricHttpService } from "./fabricHttp.js";
|
|
2
|
+
export type { HttpServiceContext } from "./fabricHttp.js";
|
|
3
|
+
export { FabricHttpServer, isFabricHttpServer } from "./FabricHttpServer.js";
|
|
4
|
+
export { extractToken, getAuthHeader, isAuthorizationRequired, validateAuthorization, } from "./authorization.js";
|
|
5
|
+
export { buildCorsHeaders, buildPreflightHeaders, DEFAULT_CORS_CONFIG, DEFAULT_CORS_METHODS, getAllowedOrigin, isPreflightRequest, normalizeCorsConfig, } from "./cors.js";
|
|
6
|
+
export { createHttpContext, defaultHttpTransform, parseBody, parsePathParams, parseQueryString, transformHttpToInput, } from "./httpTransform.js";
|
|
7
|
+
export { collectStreamEvents, createCompleteEvent, createDataEvent, createErrorEvent, createMessageEvent, createNoopEvent, createStreamContext, createTextEvent, createToolCallEvent, createToolResultEvent, DEFAULT_STREAM_CONFIG, formatNdjsonEvent, formatSseEvent, formatStreamEvent, getStreamContentType, isAsyncIterable, isStreamingEnabled, llmChunkToHttpEvent, normalizeStreamConfig, pipeLlmStream, pipeLlmStreamToWriter, wrapServiceForStreaming, } from "./stream.js";
|
|
8
|
+
export type { HttpStreamContext, LlmStreamChunk, PipeLlmStreamOptions, StreamWriter, } from "./stream.js";
|
|
9
|
+
export type { ApiGatewayEvent, ApiGatewayResponse, ApiGatewayV1Event, ApiGatewayV2Event, AuthorizationConfig, AuthorizationFunction, CorsConfig, CorsHeaders, CorsOption, DataResponse, ErrorObject, ErrorResponse, FabricHttpConfig, FabricHttpServer as FabricHttpServerInterface, FabricHttpServerConfig, FabricHttpServerHandler, FabricHttpServerRoute, FabricHttpServerServiceEntry, FabricHttpService, HttpContext, HttpMethod, HttpStreamEvent, HttpStreamEventBase, HttpStreamEventComplete, HttpStreamEventData, HttpStreamEventError, HttpStreamEventMessage, HttpStreamEventNoop, HttpStreamEventText, HttpStreamEventToolCall, HttpStreamEventToolResult, HttpTransformFunction, RegisteredRoute, RouteMatch, StreamConfig, StreamingServiceFunction, StreamOption, } from "./types.js";
|
|
10
|
+
export { DEFAULT_HTTP_METHODS, HttpStreamEventType } from "./types.js";
|