azion
Version:
Azion Packages for Edge Computing.
95 lines (93 loc) • 2.85 kB
TypeScript
declare namespace Azion {
namespace Storage {
interface StorageInstance {
list(): Promise<{
entries: {
key: string;
content_length?: number;
}[];
}>;
put(key: string, value: ArrayBuffer, options?: {
'content-length'?: string;
'content-type'?: string;
}): Promise<void>;
delete(key: string): Promise<void>;
get(key: string): Promise<StorageObject>;
}
interface StorageObject {
arrayBuffer(): Promise<ArrayBuffer>;
metadata: Map<string, string>;
contentType: string;
contentLength: number;
}
}
namespace Sql {
interface Connection {
query: (sql: string) => Promise<Rows>;
execute: (sql: string) => Promise<null>;
}
export interface Rows {
next: () => Promise<Row>;
columnCount: () => number;
columnName: (index: number) => string;
columnType: (index: number) => string;
}
export interface Row {
columnName: (index: number) => string;
columnType: (index: number) => string;
getValue: (index: number) => any;
getString: (index: number) => string;
}
export interface Database {
connection: Connection;
open?: (name: string) => Promise<Connection>;
}
export { };
}
}
interface Metadata {
geoip_asn: string;
geoip_city: string;
geoip_city_continent_code: string;
geoip_city_country_code: string;
geoip_city_country_name: string;
geoip_continent_code: string;
geoip_country_code: string;
geoip_country_name: string;
geoip_region: string;
geoip_region_name: string;
remote_addr: string;
remote_port: string;
remote_user: string;
server_protocol: string;
ssl_cipher: string;
ssl_protocol: string;
[key: string]: string;
}
/**
* Represents the FetchEvent interface.
*/
interface FetchEvent extends Event {
request: Request & {
metadata: Metadata;
};
waitUntil(promise: Promise<any>): void;
respondWith(response: Response | Promise<Response>): void;
}
/**
* Represents the FirewallEvent interface.
*/
interface FirewallEvent extends Event {
request: Request & {
headers: Headers;
metadata: Metadata;
};
waitUntil(promise: Promise<any>): void;
deny(): void;
drop(): void;
addRequestHeader(name: string, value: string): void;
addResponseHeader(name: string, value: string): void;
respondWith(response: Response | Promise<Response>): void;
continue(): void;
}
export { Azion, type FetchEvent, type FirewallEvent, type Metadata };