|
1 | 1 | declare namespace BreezeRuntime { |
2 | | - export interface Env { |
3 | | - /** |
4 | | - * Retrieves the value of an environment variable. |
5 | | - * @param key The name of the environment variable. |
6 | | - * @returns The value of the environment variable, or undefined if it is not set. |
7 | | - * |
8 | | - * @example |
9 | | - * ```ts |
10 | | - * BreezeRuntime.env.get("foo"); |
11 | | - * // Returns "bar" if the environment variable "foo" is set to "bar". |
12 | | - * ``` |
13 | | - */ |
14 | | - get(key: string): string | undefined; |
15 | | - |
16 | | - /** |
17 | | - * Retrieves all environment variables. |
18 | | - * @returns A map of all environment variables. |
19 | | - * |
20 | | - * @example |
21 | | - * ```ts |
22 | | - * BreezeRuntime.env.toObject(); |
23 | | - * // Returns { foo: "bar" } if the environment variable "foo" is set to "bar". |
24 | | - * ``` |
25 | | - */ |
26 | | - toObject(): Record<string, string | undefined>; |
27 | | - |
28 | | - /** |
29 | | - * Checks whether an environment variable is set. |
30 | | - * @param key The name of the environment variable. |
31 | | - * @returns Whether the environment variable is set. |
32 | | - * |
33 | | - * @example |
34 | | - * ```ts |
35 | | - * BreezeRuntime.env.has("foo"); |
36 | | - * // Returns true if the environment variable "foo" is set. |
37 | | - * ``` |
38 | | - */ |
39 | | - has(key: string): boolean; |
| 2 | + export interface DeploymentInfo { |
| 3 | + projectId: string; |
| 4 | + environmentId: string; |
| 5 | + functionId: string; |
40 | 6 | } |
41 | 7 |
|
42 | 8 | export interface Plugin { |
43 | | - /** |
44 | | - * Retrieves the plugin's endpoint. |
45 | | - * |
46 | | - * @example |
47 | | - * |
48 | | - * To retrieve the endpoint of the kv plugin: |
49 | | - * ```ts |
50 | | - * BreezeRuntime.plugins.kv.getEndpoint(); |
51 | | - * // Returns new URL("breeze://kv.plugins") |
52 | | - * ``` |
53 | | - * |
54 | | - * To retrieve the endpoint of the kv plugin under a subpath: |
55 | | - * ```ts |
56 | | - * BreezeRuntime.plugins.kv.getEndpoint("/put"); |
57 | | - * // Returns new URL("breeze://kv.plugins/put") |
58 | | - * ``` |
59 | | - */ |
60 | | - getEndpoint(subpath?: string): Promise<URL>; |
| 9 | + id: string; |
| 10 | + endpoint: string; |
61 | 11 | } |
62 | 12 |
|
63 | 13 | /** |
64 | | - * The environment variables. |
| 14 | + * An JWT token generated by Breeze to authorize plugin or workflow requests. |
65 | 15 | */ |
66 | | - export const env: Env; |
| 16 | + export type Token = string; |
67 | 17 |
|
68 | | - /** |
69 | | - * A map of all plugins. |
70 | | - */ |
71 | | - export const plugins: Record<string, Plugin>; |
| 18 | + export interface TokenOptions { |
| 19 | + /** |
| 20 | + * The instance name of plugin. |
| 21 | + */ |
| 22 | + plugin?: string; |
| 23 | + } |
72 | 24 |
|
73 | | - /** |
74 | | - * Provides an interface to handle HTTP request and responses over TCP connections. |
75 | | - * See detail at https://deno.land/api?s=Deno.serveHttp |
76 | | - * @example |
77 | | - * ```ts |
78 | | - * import { Hono } from "https://deno.land/x/hono@v3.4.1/mod.ts"; |
79 | | - * const app = new Hono(); |
80 | | - * |
81 | | - * app.get("/", (c) => c.text("Hello world!")); |
82 | | - * app.get("/greet/:name", (c) => { |
83 | | - * const name = c.req.param("name"); |
84 | | - * return c.text(`Hi, ${name}`); |
85 | | - * }); |
86 | | - * app.notFound((c) => { |
87 | | - * return c.text("Not found", 404); |
88 | | - * }); |
89 | | - * |
90 | | - * BreezeRuntime.serveHttp(app.fetch); |
91 | | - * ``` |
92 | | - */ |
93 | | - export function serveHttp( |
94 | | - handler: (req: Request) => Response | Promise<Response>, |
95 | | - ): void; |
| 25 | + export function getDeploymentInfo(): DeploymentInfo; |
| 26 | + |
| 27 | + export function getPlugin(plugin: string): Plugin | null; |
| 28 | + |
| 29 | + export function generateToken(opts?: TokenOptions): Token; |
| 30 | + |
| 31 | + export function pluginFetch( |
| 32 | + plugin: string, |
| 33 | + opts: RequestInit, |
| 34 | + ): Promise<Response>; |
96 | 35 | } |
0 commit comments