opinionated-machine
Version:
Very opinionated DI framework for fastify, built on top of awilix
322 lines (321 loc) • 14.3 kB
TypeScript
import { z } from 'zod/v4';
export declare const gatewayManifestRouteSchema: z.ZodObject<{
id: z.ZodString;
method: z.ZodEnum<{
GET: "GET";
POST: "POST";
PUT: "PUT";
PATCH: "PATCH";
DELETE: "DELETE";
HEAD: "HEAD";
OPTIONS: "OPTIONS";
}>;
path: z.ZodString;
controller: z.ZodString;
routeKey: z.ZodString;
metadata: z.ZodObject<{
id: z.ZodOptional<z.ZodString>;
upstream: z.ZodOptional<z.ZodString>;
visibility: z.ZodOptional<z.ZodEnum<{
public: "public";
internal: "internal";
admin: "admin";
}>>;
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
match: z.ZodOptional<z.ZodObject<{
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
exact: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
prefix: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
regex: z.ZodString;
}, z.core.$strip>]>>>;
customHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
exact: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
prefix: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
regex: z.ZodString;
}, z.core.$strip>]>>>;
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
exact: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
prefix: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
regex: z.ZodString;
}, z.core.$strip>]>>>;
customQuery: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
exact: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
prefix: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
regex: z.ZodString;
}, z.core.$strip>]>>>;
host: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
}, z.core.$strict>>;
rewrite: z.ZodOptional<z.ZodObject<{
stripPrefix: z.ZodOptional<z.ZodString>;
replacePrefix: z.ZodOptional<z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>>;
}, z.core.$strict>>;
timeouts: z.ZodOptional<z.ZodObject<{
request: z.ZodOptional<z.ZodString>;
idle: z.ZodOptional<z.ZodString>;
connect: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
retry: z.ZodOptional<z.ZodObject<{
attempts: z.ZodOptional<z.ZodNumber>;
on: z.ZodOptional<z.ZodArray<z.ZodEnum<{
"5xx": "5xx";
"gateway-error": "gateway-error";
"connect-failure": "connect-failure";
reset: "reset";
"retriable-4xx": "retriable-4xx";
}>>>;
perTryTimeout: z.ZodOptional<z.ZodString>;
backoff: z.ZodOptional<z.ZodObject<{
base: z.ZodOptional<z.ZodString>;
max: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
}, z.core.$strict>>;
circuitBreaker: z.ZodOptional<z.ZodObject<{
maxConnections: z.ZodOptional<z.ZodNumber>;
maxPendingRequests: z.ZodOptional<z.ZodNumber>;
maxRequests: z.ZodOptional<z.ZodNumber>;
maxRetries: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>;
rateLimit: z.ZodOptional<z.ZodObject<{
requests: z.ZodNumber;
per: z.ZodString;
key: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ip">, z.ZodObject<{
header: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
customHeader: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
query: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
customQuery: z.ZodString;
}, z.core.$strict>]>>;
}, z.core.$strict>>;
traffic: z.ZodOptional<z.ZodObject<{
weights: z.ZodOptional<z.ZodArray<z.ZodObject<{
upstream: z.ZodString;
weight: z.ZodNumber;
}, z.core.$strict>>>;
shadow: z.ZodOptional<z.ZodObject<{
upstream: z.ZodString;
percent: z.ZodNumber;
}, z.core.$strict>>;
}, z.core.$strict>>;
cors: z.ZodOptional<z.ZodObject<{
origins: z.ZodArray<z.ZodString>;
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
GET: "GET";
POST: "POST";
PUT: "PUT";
PATCH: "PATCH";
DELETE: "DELETE";
HEAD: "HEAD";
OPTIONS: "OPTIONS";
}>>>;
headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
exposeHeaders: z.ZodOptional<z.ZodArray<z.ZodString>>;
credentials: z.ZodOptional<z.ZodBoolean>;
maxAge: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
auth: z.ZodOptional<z.ZodObject<{
required: z.ZodOptional<z.ZodBoolean>;
jwt: z.ZodOptional<z.ZodObject<{
issuer: z.ZodString;
audiences: z.ZodOptional<z.ZodArray<z.ZodString>>;
jwksUri: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
mTLS: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strict>>;
cache: z.ZodOptional<z.ZodObject<{
ttl: z.ZodString;
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
GET: "GET";
HEAD: "HEAD";
}>>>;
vary: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
headers: z.ZodOptional<z.ZodObject<{
request: z.ZodOptional<z.ZodObject<{
add: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
response: z.ZodOptional<z.ZodObject<{
add: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
}, z.core.$strict>>;
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>;
}, z.core.$strict>;
}, z.core.$strict>;
export declare const gatewayManifestSchema: z.ZodObject<{
manifestVersion: z.ZodLiteral<"1">;
service: z.ZodString;
version: z.ZodOptional<z.ZodString>;
generatedAt: z.ZodString;
routes: z.ZodArray<z.ZodObject<{
id: z.ZodString;
method: z.ZodEnum<{
GET: "GET";
POST: "POST";
PUT: "PUT";
PATCH: "PATCH";
DELETE: "DELETE";
HEAD: "HEAD";
OPTIONS: "OPTIONS";
}>;
path: z.ZodString;
controller: z.ZodString;
routeKey: z.ZodString;
metadata: z.ZodObject<{
id: z.ZodOptional<z.ZodString>;
upstream: z.ZodOptional<z.ZodString>;
visibility: z.ZodOptional<z.ZodEnum<{
public: "public";
internal: "internal";
admin: "admin";
}>>;
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
match: z.ZodOptional<z.ZodObject<{
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
exact: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
prefix: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
regex: z.ZodString;
}, z.core.$strip>]>>>;
customHeaders: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
exact: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
prefix: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
regex: z.ZodString;
}, z.core.$strip>]>>>;
query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
exact: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
prefix: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
regex: z.ZodString;
}, z.core.$strip>]>>>;
customQuery: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
exact: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
prefix: z.ZodString;
}, z.core.$strip>, z.ZodObject<{
regex: z.ZodString;
}, z.core.$strip>]>>>;
host: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
}, z.core.$strict>>;
rewrite: z.ZodOptional<z.ZodObject<{
stripPrefix: z.ZodOptional<z.ZodString>;
replacePrefix: z.ZodOptional<z.ZodObject<{
from: z.ZodString;
to: z.ZodString;
}, z.core.$strict>>;
}, z.core.$strict>>;
timeouts: z.ZodOptional<z.ZodObject<{
request: z.ZodOptional<z.ZodString>;
idle: z.ZodOptional<z.ZodString>;
connect: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
retry: z.ZodOptional<z.ZodObject<{
attempts: z.ZodOptional<z.ZodNumber>;
on: z.ZodOptional<z.ZodArray<z.ZodEnum<{
"5xx": "5xx";
"gateway-error": "gateway-error";
"connect-failure": "connect-failure";
reset: "reset";
"retriable-4xx": "retriable-4xx";
}>>>;
perTryTimeout: z.ZodOptional<z.ZodString>;
backoff: z.ZodOptional<z.ZodObject<{
base: z.ZodOptional<z.ZodString>;
max: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
}, z.core.$strict>>;
circuitBreaker: z.ZodOptional<z.ZodObject<{
maxConnections: z.ZodOptional<z.ZodNumber>;
maxPendingRequests: z.ZodOptional<z.ZodNumber>;
maxRequests: z.ZodOptional<z.ZodNumber>;
maxRetries: z.ZodOptional<z.ZodNumber>;
}, z.core.$strict>>;
rateLimit: z.ZodOptional<z.ZodObject<{
requests: z.ZodNumber;
per: z.ZodString;
key: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"ip">, z.ZodObject<{
header: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
customHeader: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
query: z.ZodString;
}, z.core.$strict>, z.ZodObject<{
customQuery: z.ZodString;
}, z.core.$strict>]>>;
}, z.core.$strict>>;
traffic: z.ZodOptional<z.ZodObject<{
weights: z.ZodOptional<z.ZodArray<z.ZodObject<{
upstream: z.ZodString;
weight: z.ZodNumber;
}, z.core.$strict>>>;
shadow: z.ZodOptional<z.ZodObject<{
upstream: z.ZodString;
percent: z.ZodNumber;
}, z.core.$strict>>;
}, z.core.$strict>>;
cors: z.ZodOptional<z.ZodObject<{
origins: z.ZodArray<z.ZodString>;
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
GET: "GET";
POST: "POST";
PUT: "PUT";
PATCH: "PATCH";
DELETE: "DELETE";
HEAD: "HEAD";
OPTIONS: "OPTIONS";
}>>>;
headers: z.ZodOptional<z.ZodArray<z.ZodString>>;
exposeHeaders: z.ZodOptional<z.ZodArray<z.ZodString>>;
credentials: z.ZodOptional<z.ZodBoolean>;
maxAge: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
auth: z.ZodOptional<z.ZodObject<{
required: z.ZodOptional<z.ZodBoolean>;
jwt: z.ZodOptional<z.ZodObject<{
issuer: z.ZodString;
audiences: z.ZodOptional<z.ZodArray<z.ZodString>>;
jwksUri: z.ZodOptional<z.ZodString>;
}, z.core.$strict>>;
mTLS: z.ZodOptional<z.ZodBoolean>;
}, z.core.$strict>>;
cache: z.ZodOptional<z.ZodObject<{
ttl: z.ZodString;
methods: z.ZodOptional<z.ZodArray<z.ZodEnum<{
GET: "GET";
HEAD: "HEAD";
}>>>;
vary: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
headers: z.ZodOptional<z.ZodObject<{
request: z.ZodOptional<z.ZodObject<{
add: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
response: z.ZodOptional<z.ZodObject<{
add: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
}, z.core.$strict>>;
}, z.core.$strict>>;
extensions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>>;
}, z.core.$strict>;
}, z.core.$strict>>;
}, z.core.$strict>;
export type GatewayManifestRoute = z.infer<typeof gatewayManifestRouteSchema>;
export type GatewayManifest = z.infer<typeof gatewayManifestSchema>;