@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 CHANGED
@@ -14,7 +14,6 @@ npm install @faasjs/dev
14
14
  ## Features
15
15
 
16
16
  - Vite integration for in-process FaasJS API during local development.
17
- - PGlite helpers for lightweight database setup in tests.
18
17
  - Test helpers to invoke and assert FaasJS functions.
19
18
 
20
19
  ## Usage: Vite integration
@@ -27,24 +26,6 @@ export default defineConfig({
27
26
  })
28
27
  ```
29
28
 
30
- ## Usage: PGlite helpers
31
-
32
- ```ts
33
- import {
34
- createPgliteKnex,
35
- mountFaasKnex,
36
- unmountFaasKnex,
37
- } from '@faasjs/dev'
38
-
39
- const db = createPgliteKnex()
40
- mountFaasKnex(db)
41
-
42
- // run tests...
43
-
44
- await db.destroy()
45
- unmountFaasKnex()
46
- ```
47
-
48
29
  ## Usage: Test helpers
49
30
 
50
31
  ```ts
@@ -60,22 +41,18 @@ expect(response.data).toEqual({ message: 'Hello, FaasJS' })
60
41
 
61
42
  ## API
62
43
 
63
- - Vite: [viteFaasJsServer](functions/viteFaasJsServer.md), [ViteFaasJsServerOptions](type-aliases/ViteFaasJsServerOptions.md)
64
- - PGlite: [createPgliteKnex](functions/createPgliteKnex.md), [mountFaasKnex](functions/mountFaasKnex.md), [runPgliteSql](functions/runPgliteSql.md), [runPgliteSqlFile](functions/runPgliteSqlFile.md), [unmountFaasKnex](functions/unmountFaasKnex.md), [MountFaasKnexOptions](type-aliases/MountFaasKnexOptions.md)
65
- - Test: [test](functions/test.md), [FuncWarper](classes/FuncWarper.md), [streamToString](functions/streamToString.md)
44
+ - Vite: [viteFaasJsServer](functions/viteFaasJsServer.md)
45
+ - Test: [test](functions/test.md), [FuncWarper](classes/FuncWarper.md), [streamToText](functions/streamToText.md), [streamToObject](functions/streamToObject.md), [streamToString](variables/streamToString.md)
66
46
 
67
47
  ## Functions
68
48
 
69
- - [createPgliteKnex](functions/createPgliteKnex.md)
70
- - [defineFunc](functions/defineFunc.md)
71
- - [mountFaasKnex](functions/mountFaasKnex.md)
49
+ - [generateFaasTypes](functions/generateFaasTypes.md)
50
+ - [isTypegenSourceFile](functions/isTypegenSourceFile.md)
72
51
  - [nameFunc](functions/nameFunc.md)
73
52
  - [parseFuncFilenameFromStack](functions/parseFuncFilenameFromStack.md)
74
- - [runPgliteSql](functions/runPgliteSql.md)
75
- - [runPgliteSqlFile](functions/runPgliteSqlFile.md)
76
- - [streamToString](functions/streamToString.md)
53
+ - [streamToObject](functions/streamToObject.md)
54
+ - [streamToText](functions/streamToText.md)
77
55
  - [test](functions/test.md)
78
- - [unmountFaasKnex](functions/unmountFaasKnex.md)
79
56
  - [useFunc](functions/useFunc.md)
80
57
  - [usePlugin](functions/usePlugin.md)
81
58
  - [viteFaasJsServer](functions/viteFaasJsServer.md)
@@ -85,6 +62,10 @@ expect(response.data).toEqual({ message: 'Hello, FaasJS' })
85
62
  - [Func](classes/Func.md)
86
63
  - [FuncWarper](classes/FuncWarper.md)
87
64
 
65
+ ## Interfaces
66
+
67
+ - [FaasPluginEventMap](interfaces/FaasPluginEventMap.md)
68
+
88
69
  ## Type Aliases
89
70
 
90
71
  - [Config](type-aliases/Config.md)
@@ -92,12 +73,21 @@ expect(response.data).toEqual({ message: 'Hello, FaasJS' })
92
73
  - [FuncConfig](type-aliases/FuncConfig.md)
93
74
  - [FuncEventType](type-aliases/FuncEventType.md)
94
75
  - [FuncReturnType](type-aliases/FuncReturnType.md)
76
+ - [GenerateFaasTypesOptions](type-aliases/GenerateFaasTypesOptions.md)
77
+ - [GenerateFaasTypesResult](type-aliases/GenerateFaasTypesResult.md)
95
78
  - [Handler](type-aliases/Handler.md)
79
+ - [InferPluginEvent](type-aliases/InferPluginEvent.md)
96
80
  - [InvokeData](type-aliases/InvokeData.md)
97
81
  - [LifeCycleKey](type-aliases/LifeCycleKey.md)
98
82
  - [MountData](type-aliases/MountData.md)
99
- - [MountFaasKnexOptions](type-aliases/MountFaasKnexOptions.md)
100
83
  - [Next](type-aliases/Next.md)
84
+ - [NormalizePluginType](type-aliases/NormalizePluginType.md)
101
85
  - [Plugin](type-aliases/Plugin.md)
86
+ - [ResolvePluginEvent](type-aliases/ResolvePluginEvent.md)
87
+ - [Simplify](type-aliases/Simplify.md)
88
+ - [UnionToIntersection](type-aliases/UnionToIntersection.md)
102
89
  - [UseifyPlugin](type-aliases/UseifyPlugin.md)
103
- - [ViteFaasJsServerOptions](type-aliases/ViteFaasJsServerOptions.md)
90
+
91
+ ## Variables
92
+
93
+ - [streamToString](variables/streamToString.md)
@@ -0,0 +1,36 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __exportAll = (all, no_symbols) => {
7
+ let target = {};
8
+ for (var name in all) {
9
+ __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ }
14
+ if (!no_symbols) {
15
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
16
+ }
17
+ return target;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
22
+ key = keys[i];
23
+ if (!__hasOwnProp.call(to, key) && key !== except) {
24
+ __defProp(to, key, {
25
+ get: ((k) => from[k]).bind(null, key),
26
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
27
+ });
28
+ }
29
+ }
30
+ }
31
+ return to;
32
+ };
33
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
34
+
35
+ //#endregion
36
+ export { __reExport as n, __exportAll as t };
package/dist/cli.cjs ADDED
@@ -0,0 +1,67 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_typegen = require('./typegen-C6t9LIyi.cjs');
3
+
4
+ //#region package.json
5
+ var version = "8.0.0-beta.6";
6
+
7
+ //#endregion
8
+ //#region src/cli.ts
9
+ const HelpText = `Generate FaasJS API/event type declarations.
10
+
11
+ Usage:
12
+ faas-types [options]
13
+
14
+ Options:
15
+ --root <path> Project root path (default: process.cwd())
16
+ -h, --help Show help
17
+ -v, --version Show version
18
+ `;
19
+ function parseCliArgs(argv) {
20
+ const args = argv.slice(2);
21
+ const options = {};
22
+ const readValue = (index, name) => {
23
+ const value = args[index + 1];
24
+ if (!value || value.startsWith("-")) throw Error(`[faas-types] Missing value for ${name}`);
25
+ return value;
26
+ };
27
+ for (let i = 0; i < args.length; i++) {
28
+ const arg = args[i];
29
+ if (arg === "-h" || arg === "--help") return {
30
+ showHelp: true,
31
+ options
32
+ };
33
+ if (arg === "-v" || arg === "--version") return {
34
+ showVersion: true,
35
+ options
36
+ };
37
+ if (arg === "--root") {
38
+ options.root = readValue(i, arg);
39
+ i++;
40
+ continue;
41
+ }
42
+ throw Error(`[faas-types] Unknown option: ${arg}`);
43
+ }
44
+ return { options };
45
+ }
46
+ async function main(argv = process.argv) {
47
+ try {
48
+ const parsed = parseCliArgs(argv);
49
+ if (parsed.showHelp) {
50
+ console.log(HelpText);
51
+ return 0;
52
+ }
53
+ if (parsed.showVersion) {
54
+ console.log(version);
55
+ return 0;
56
+ }
57
+ const result = await require_typegen.generateFaasTypes(parsed.options);
58
+ console.log(`[faas-types] ${result.changed ? "Generated" : "Up to date"} ${result.output} (${result.routeCount} routes from ${result.fileCount} files)`);
59
+ return 0;
60
+ } catch (error) {
61
+ console.error(error?.message || error);
62
+ return 1;
63
+ }
64
+ }
65
+
66
+ //#endregion
67
+ exports.main = main;
package/dist/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ //#region src/cli.d.ts
2
+ declare function main(argv?: string[]): Promise<number>;
3
+ //#endregion
4
+ export { main };
package/dist/cli.mjs ADDED
@@ -0,0 +1,66 @@
1
+ import { t as generateFaasTypes } from "./typegen-D5s91_xL.mjs";
2
+
3
+ //#region package.json
4
+ var version = "8.0.0-beta.6";
5
+
6
+ //#endregion
7
+ //#region src/cli.ts
8
+ const HelpText = `Generate FaasJS API/event type declarations.
9
+
10
+ Usage:
11
+ faas-types [options]
12
+
13
+ Options:
14
+ --root <path> Project root path (default: process.cwd())
15
+ -h, --help Show help
16
+ -v, --version Show version
17
+ `;
18
+ function parseCliArgs(argv) {
19
+ const args = argv.slice(2);
20
+ const options = {};
21
+ const readValue = (index, name) => {
22
+ const value = args[index + 1];
23
+ if (!value || value.startsWith("-")) throw Error(`[faas-types] Missing value for ${name}`);
24
+ return value;
25
+ };
26
+ for (let i = 0; i < args.length; i++) {
27
+ const arg = args[i];
28
+ if (arg === "-h" || arg === "--help") return {
29
+ showHelp: true,
30
+ options
31
+ };
32
+ if (arg === "-v" || arg === "--version") return {
33
+ showVersion: true,
34
+ options
35
+ };
36
+ if (arg === "--root") {
37
+ options.root = readValue(i, arg);
38
+ i++;
39
+ continue;
40
+ }
41
+ throw Error(`[faas-types] Unknown option: ${arg}`);
42
+ }
43
+ return { options };
44
+ }
45
+ async function main(argv = process.argv) {
46
+ try {
47
+ const parsed = parseCliArgs(argv);
48
+ if (parsed.showHelp) {
49
+ console.log(HelpText);
50
+ return 0;
51
+ }
52
+ if (parsed.showVersion) {
53
+ console.log(version);
54
+ return 0;
55
+ }
56
+ const result = await generateFaasTypes(parsed.options);
57
+ console.log(`[faas-types] ${result.changed ? "Generated" : "Up to date"} ${result.output} (${result.routeCount} routes from ${result.fileCount} files)`);
58
+ return 0;
59
+ } catch (error) {
60
+ console.error(error?.message || error);
61
+ return 1;
62
+ }
63
+ }
64
+
65
+ //#endregion
66
+ export { main };