spiceflow 0.0.1 → 0.0.2
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 +20 -18
- package/context.js +1 -1
- package/dist/babel.test.js +13 -18
- package/dist/babel.test.js.map +1 -1
- package/dist/babelDebugOutputs.d.ts +1 -1
- package/dist/babelDebugOutputs.d.ts.map +1 -1
- package/dist/babelDebugOutputs.js +12 -18
- package/dist/babelDebugOutputs.js.map +1 -1
- package/dist/babelTransformRpc.d.ts +3 -1
- package/dist/babelTransformRpc.d.ts.map +1 -1
- package/dist/babelTransformRpc.js +17 -27
- package/dist/babelTransformRpc.js.map +1 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +8 -15
- package/dist/browser.js.map +1 -1
- package/dist/build.d.ts +9 -9
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +101 -84
- package/dist/build.js.map +1 -1
- package/dist/cli.js +29 -33
- package/dist/cli.js.map +1 -1
- package/dist/context-internal.js +8 -14
- package/dist/context-internal.js.map +1 -1
- package/dist/context.d.ts +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +1 -7
- package/dist/context.js.map +1 -1
- package/dist/expose.js +5 -12
- package/dist/expose.js.map +1 -1
- package/dist/headers.d.ts +1 -0
- package/dist/headers.js +1 -1
- package/dist/headers.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -44
- package/dist/index.js.map +1 -1
- package/dist/jsonRpc.js +1 -2
- package/dist/jsonRpc.js.map +1 -1
- package/dist/server.js +12 -21
- package/dist/server.js.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +16 -12
- package/dist/utils.js.map +1 -1
- package/headers.js +1 -1
- package/package.json +3 -2
- package/src/babelDebugOutputs.ts +2 -2
- package/src/babelTransformRpc.ts +8 -8
- package/src/browser.ts +1 -2
- package/src/build.ts +80 -33
- package/src/cli.ts +7 -2
- package/src/context.ts +5 -1
- package/src/expose.ts +1 -1
- package/src/index.ts +12 -20
- package/src/server.ts +3 -3
- package/src/utils.ts +15 -3
package/src/cli.ts
CHANGED
|
@@ -14,14 +14,19 @@ export const cli = cac();
|
|
|
14
14
|
|
|
15
15
|
cli
|
|
16
16
|
.command('', 'Generate an SDK package for your functions')
|
|
17
|
+
.alias('build')
|
|
17
18
|
.option('--watch', 'Watch for changes')
|
|
18
19
|
.option('--url <url>', 'URL of the package, including the base path', {
|
|
19
20
|
default: 'http://localhost:3333',
|
|
20
21
|
})
|
|
22
|
+
.option(
|
|
23
|
+
'--openapi',
|
|
24
|
+
'[experimental] Creates an openapi.json schema based on your functions',
|
|
25
|
+
)
|
|
21
26
|
.action(async (options) => {
|
|
22
|
-
const { url, watch } = options;
|
|
27
|
+
const { url, watch, openapi } = options;
|
|
23
28
|
const rootDir = await findRootDir(process.cwd());
|
|
24
|
-
await build({ rootDir, url, watch });
|
|
29
|
+
await build({ rootDir, url, openapi, watch });
|
|
25
30
|
});
|
|
26
31
|
cli
|
|
27
32
|
.command('init', 'Generate a new spiceflow project')
|
package/src/context.ts
CHANGED
package/src/expose.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
import { PluginOptions } from './babelTransformRpc';
|
|
3
|
+
import { PluginOptions } from './babelTransformRpc.js';
|
|
4
4
|
|
|
5
|
-
import { WrapMethod } from './server';
|
|
5
|
+
import { WrapMethod, WrapMethodMeta } from './server.js';
|
|
6
6
|
|
|
7
7
|
export interface WithRpcConfig {}
|
|
8
8
|
|
|
9
9
|
export { WrapMethod };
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}: PluginOptions) {
|
|
16
|
-
const rpcPluginOptions: PluginOptions = {
|
|
17
|
-
isServer,
|
|
18
|
-
rootDir: nextDir,
|
|
19
|
-
url,
|
|
20
|
-
};
|
|
11
|
+
import pluginSyntaxJsx from '@babel/plugin-syntax-jsx';
|
|
12
|
+
import pluginTransformTypescript from '@babel/plugin-transform-typescript';
|
|
13
|
+
import babelTransformRpc from './babelTransformRpc.js';
|
|
14
|
+
import babelDebugOutputs from './babelDebugOutputs.js';
|
|
21
15
|
|
|
16
|
+
export function plugins(options: PluginOptions) {
|
|
22
17
|
return [
|
|
23
|
-
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
process.env.DEBUG_ACTIONS && [
|
|
27
|
-
|
|
28
|
-
rpcPluginOptions,
|
|
29
|
-
],
|
|
30
|
-
].filter(Boolean) as any[];
|
|
18
|
+
pluginSyntaxJsx,
|
|
19
|
+
[pluginTransformTypescript, { isTSX: true }],
|
|
20
|
+
[babelTransformRpc, options],
|
|
21
|
+
process.env.DEBUG_ACTIONS && [babelDebugOutputs, options],
|
|
22
|
+
].filter(Boolean);
|
|
31
23
|
}
|
|
32
24
|
|
|
33
25
|
export function findRootDir(dir: string): string {
|
package/src/server.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
2
2
|
import superjson from 'superjson';
|
|
3
|
-
import { asyncLocalStorage } from './context-internal';
|
|
4
|
-
import { JsonRpcRequest, JsonRpcResponse } from './jsonRpc';
|
|
5
|
-
import { jsonRpcError } from './utils';
|
|
3
|
+
import { asyncLocalStorage } from './context-internal.js';
|
|
4
|
+
import { JsonRpcRequest, JsonRpcResponse } from './jsonRpc.js';
|
|
5
|
+
import { jsonRpcError } from './utils.js';
|
|
6
6
|
|
|
7
7
|
export type Method<P extends any[], R> = (
|
|
8
8
|
...params: P
|
package/src/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PluginPass, parse } from '@babel/core';
|
|
1
|
+
import { PluginPass, parse, traverse } from '@babel/core';
|
|
2
2
|
|
|
3
3
|
import { Node, types } from '@babel/core';
|
|
4
|
-
import { JsonRpcError, JsonRpcErrorResponse } from './jsonRpc';
|
|
4
|
+
import { JsonRpcError, JsonRpcErrorResponse } from './jsonRpc.js';
|
|
5
5
|
|
|
6
6
|
const PURE_ANNOTATION = '#__PURE__';
|
|
7
7
|
|
|
@@ -40,7 +40,7 @@ export function getFileName(state: PluginPass) {
|
|
|
40
40
|
|
|
41
41
|
return filename;
|
|
42
42
|
}
|
|
43
|
-
export const directive =
|
|
43
|
+
export const directive = 'use spiceflow';
|
|
44
44
|
|
|
45
45
|
export const serverEntryName = '_function_server_file';
|
|
46
46
|
|
|
@@ -59,3 +59,15 @@ export function jsonRpcError({
|
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
export function camelCaseCapitalized(str: string) {
|
|
64
|
+
// functionName -> FunctionName
|
|
65
|
+
// CamelCase -> CamelCase
|
|
66
|
+
// camelCase -> CamelCase
|
|
67
|
+
|
|
68
|
+
if (str.length === 0) {
|
|
69
|
+
return str;
|
|
70
|
+
}
|
|
71
|
+
const first = str[0].toUpperCase();
|
|
72
|
+
return first + str.slice(1);
|
|
73
|
+
}
|