@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/dist/index.d.ts CHANGED
@@ -1,45 +1,11 @@
1
- import { Knex } from 'knex';
2
- import { Func, Config, Plugin } from '@faasjs/func';
3
- export * from '@faasjs/func';
4
- import { Logger } from '@faasjs/logger';
5
- import { Plugin as Plugin$1 } from 'vite';
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
- type MountFaasKnexOptions = {
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
- [key: string]: any;
57
- readonly file: string;
58
- readonly staging: string;
59
- readonly logger: Logger;
60
- readonly func: Func;
61
- readonly config: Config;
62
- readonly plugins: Plugin[];
63
- private readonly _handler;
64
- /**
65
- * @param file {string} Full file path
66
- * @param func {Func} A FaasJs function
67
- * ```ts
68
- * import { FuncWarper } from '@faasjs/dev'
69
- *
70
- * new FuncWarper(__dirname + '/../demo.func.ts')
71
- * ```
72
- */
73
- constructor(initBy: Func);
74
- mount(handler?: (func: FuncWarper) => Promise<void> | void): Promise<void>;
75
- handler<TResult = any>(event?: any, context?: any): Promise<TResult>;
76
- JSONhandler<TData = any>(body?: {
77
- [key: string]: any;
78
- }, options?: {
79
- headers?: {
80
- [key: string]: any;
81
- };
82
- cookie?: {
83
- [key: string]: any;
84
- };
85
- session?: {
86
- [key: string]: any;
87
- };
88
- }): Promise<{
89
- statusCode: number;
90
- headers: {
91
- [key: string]: string;
92
- };
93
- cookie?: Record<string, any>;
94
- session?: Record<string, any>;
95
- body: any;
96
- data?: TData;
97
- error?: {
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
- type ViteFaasJsServerOptions = {
118
- /** faas project root path, default is vite's root */
119
- root: string;
120
- /** faas server base path, default is vite's base */
121
- base: string;
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 project root/base from Vite config and strips `base` from request URL
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(options?: Partial<ViteFaasJsServerOptions> & Record<string, unknown>): Plugin$1;
130
-
131
- export { FuncWarper, type MountFaasKnexOptions, type ViteFaasJsServerOptions, createPgliteKnex, mountFaasKnex, runPgliteSql, runPgliteSqlFile, streamToString, test, unmountFaasKnex, viteFaasJsServer };
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 };