@faasjs/dev 8.0.0-beta.5 → 8.0.0-beta.7
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 +21 -31
- package/dist/chunk-CtajNgzt.mjs +36 -0
- package/dist/cli.cjs +67 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.mjs +66 -0
- package/dist/index.cjs +311 -333
- package/dist/index.d.ts +72 -97
- package/dist/index.mjs +274 -310
- package/dist/typegen-C6t9LIyi.cjs +183 -0
- package/dist/typegen-D5s91_xL.mjs +166 -0
- package/faas-types.mjs +7 -0
- package/package.json +23 -19
package/dist/index.d.ts
CHANGED
|
@@ -1,45 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import { Plugin as Plugin$1 } from
|
|
1
|
+
import { n as __reExport, t as __exportAll } from "./chunk-CtajNgzt.mjs";
|
|
2
|
+
import { Logger } from "@faasjs/logger";
|
|
3
|
+
import { streamToObject, streamToString, streamToText } from "@faasjs/node-utils";
|
|
4
|
+
import { Config, Func, Plugin } from "@faasjs/func";
|
|
5
|
+
import { Plugin as Plugin$1 } from "vite";
|
|
6
|
+
export * from "@faasjs/func";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
/** key of `globalThis.FaasJS_Knex`, default is `knex` */
|
|
9
|
-
name?: string;
|
|
10
|
-
/** optional config metadata passed through to `@faasjs/knex` */
|
|
11
|
-
config?: Record<string, unknown>;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Create a knex instance backed by `knex-pglite`.
|
|
15
|
-
*/
|
|
16
|
-
declare function createPgliteKnex(config?: Partial<Knex.Config>, connection?: Record<string, unknown>): Knex;
|
|
17
|
-
/**
|
|
18
|
-
* Mount a knex adapter to `globalThis.FaasJS_Knex` for `@faasjs/knex`.
|
|
19
|
-
*/
|
|
20
|
-
declare function mountFaasKnex(db: Knex, options?: MountFaasKnexOptions): void;
|
|
21
|
-
/**
|
|
22
|
-
* Remove mounted knex adapter from `globalThis.FaasJS_Knex`.
|
|
23
|
-
*/
|
|
24
|
-
declare function unmountFaasKnex(name?: string): void;
|
|
25
|
-
/**
|
|
26
|
-
* Run a SQL string on a PGlite-backed knex instance.
|
|
27
|
-
*/
|
|
28
|
-
declare function runPgliteSql(db: Knex, sql: string): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Run SQL from file on a PGlite-backed knex instance.
|
|
31
|
-
*/
|
|
32
|
-
declare function runPgliteSqlFile(db: Knex, filePath: string, options?: {
|
|
33
|
-
stripUuidOsspExtension?: boolean;
|
|
34
|
-
}): Promise<void>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Convert ReadableStream to string.
|
|
38
|
-
* @param stream {ReadableStream<Uint8Array>} The stream to convert
|
|
39
|
-
* @returns {Promise<string>} The string content of stream
|
|
40
|
-
* @throws {TypeError} If stream is not a ReadableStream instance
|
|
41
|
-
*/
|
|
42
|
-
declare function streamToString(stream: ReadableStream<Uint8Array>): Promise<string>;
|
|
8
|
+
//#region src/test.d.ts
|
|
43
9
|
/**
|
|
44
10
|
* Test wrapper for a function.
|
|
45
11
|
*
|
|
@@ -53,51 +19,48 @@ declare function streamToString(stream: ReadableStream<Uint8Array>): Promise<str
|
|
|
53
19
|
* ```
|
|
54
20
|
*/
|
|
55
21
|
declare class FuncWarper {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
message: string;
|
|
99
|
-
};
|
|
100
|
-
}>;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
readonly file: string;
|
|
24
|
+
readonly staging: string;
|
|
25
|
+
readonly logger: Logger;
|
|
26
|
+
readonly func: Func;
|
|
27
|
+
readonly config: Config;
|
|
28
|
+
readonly plugins: Plugin[];
|
|
29
|
+
private readonly _handler;
|
|
30
|
+
/**
|
|
31
|
+
* @param initBy {Func} A FaasJS function
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { FuncWarper } from '@faasjs/dev'
|
|
34
|
+
*
|
|
35
|
+
* new FuncWarper(__dirname + '/../demo.func.ts')
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
constructor(initBy: Func);
|
|
39
|
+
mount(handler?: (func: FuncWarper) => Promise<void> | void): Promise<void>;
|
|
40
|
+
handler<TResult = any>(event?: any, context?: any): Promise<TResult>;
|
|
41
|
+
JSONhandler<TData = any>(body?: Record<string, any> | string | null, options?: {
|
|
42
|
+
headers?: {
|
|
43
|
+
[key: string]: any;
|
|
44
|
+
};
|
|
45
|
+
cookie?: {
|
|
46
|
+
[key: string]: any;
|
|
47
|
+
};
|
|
48
|
+
session?: {
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
};
|
|
51
|
+
}): Promise<{
|
|
52
|
+
statusCode: number;
|
|
53
|
+
headers: {
|
|
54
|
+
[key: string]: string;
|
|
55
|
+
};
|
|
56
|
+
cookie?: Record<string, any>;
|
|
57
|
+
session?: Record<string, any>;
|
|
58
|
+
body: any;
|
|
59
|
+
data?: TData;
|
|
60
|
+
error?: {
|
|
61
|
+
message: string;
|
|
62
|
+
};
|
|
63
|
+
}>;
|
|
101
64
|
}
|
|
102
65
|
/**
|
|
103
66
|
* A simple way to wrap a FaasJS function.
|
|
@@ -113,19 +76,31 @@ declare class FuncWarper {
|
|
|
113
76
|
* ```
|
|
114
77
|
*/
|
|
115
78
|
declare function test(initBy: Func): FuncWarper;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/typegen.d.ts
|
|
81
|
+
type GenerateFaasTypesOptions = {
|
|
82
|
+
/** faas project root path, default is process.cwd() */root?: string; /** optional logger instance */
|
|
83
|
+
logger?: Logger;
|
|
84
|
+
};
|
|
85
|
+
type GenerateFaasTypesResult = {
|
|
86
|
+
output: string;
|
|
87
|
+
changed: boolean;
|
|
88
|
+
fileCount: number;
|
|
89
|
+
routeCount: number;
|
|
122
90
|
};
|
|
91
|
+
declare function isTypegenSourceFile(filePath: string): boolean;
|
|
92
|
+
declare function generateFaasTypes(options?: GenerateFaasTypesOptions): Promise<GenerateFaasTypesResult>;
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/vite.d.ts
|
|
123
95
|
/**
|
|
124
96
|
* Create a Vite plugin that proxies POST requests to an in-process FaasJS server.
|
|
125
97
|
*
|
|
126
|
-
* It resolves
|
|
127
|
-
* before forwarding to `@faasjs/server`.
|
|
98
|
+
* It resolves server root/base from `src/faas.yaml` and strips `base` from
|
|
99
|
+
* request URL before forwarding to `@faasjs/server`.
|
|
128
100
|
*/
|
|
129
|
-
declare function viteFaasJsServer(
|
|
130
|
-
|
|
131
|
-
export { FuncWarper,
|
|
101
|
+
declare function viteFaasJsServer(): Plugin$1;
|
|
102
|
+
declare namespace index_d_exports {
|
|
103
|
+
export { FuncWarper, GenerateFaasTypesOptions, GenerateFaasTypesResult, generateFaasTypes, isTypegenSourceFile, streamToObject, streamToString, streamToText, test, viteFaasJsServer };
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { FuncWarper, GenerateFaasTypesOptions, GenerateFaasTypesResult, generateFaasTypes, isTypegenSourceFile, streamToObject, streamToString, streamToText, test, viteFaasJsServer };
|