@pikku/cli 0.8.3 → 0.9.1
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/CHANGELOG.md +16 -0
- package/bin/pikku-all.ts +47 -33
- package/bin/pikku-fetch.ts +1 -1
- package/bin/pikku-openapi.ts +2 -2
- package/bin/pikku-queue-service.ts +2 -2
- package/bin/pikku-websocket.ts +1 -1
- package/cli.schema.json +30 -30
- package/dist/bin/pikku-all.js +38 -33
- package/dist/bin/pikku-fetch.js +1 -1
- package/dist/bin/pikku-openapi.js +2 -2
- package/dist/bin/pikku-queue-service.js +2 -2
- package/dist/bin/pikku-websocket.js +1 -1
- package/dist/src/inspector-glob.js +2 -2
- package/dist/src/pikku-cli-config.d.ts +17 -17
- package/dist/src/pikku-cli-config.js +31 -31
- package/dist/src/runtimes/nextjs/pikku-command-nextjs.js +3 -3
- package/dist/src/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +29 -29
- package/dist/src/runtimes/nextjs/serialize-nextjs-http-wrapper.js +28 -28
- package/dist/src/schema-generator.d.ts +2 -2
- package/dist/src/schema-generator.js +2 -2
- package/dist/src/serialize-pikku-types.js +67 -67
- package/dist/src/utils.d.ts +5 -1
- package/dist/src/utils.js +17 -6
- package/dist/src/wirings/channels/pikku-channels.js +9 -0
- package/dist/src/wirings/channels/pikku-command-channels.js +9 -0
- package/dist/src/{events → wirings}/channels/serialize-typed-channel-map.js +3 -3
- package/dist/src/{events → wirings}/channels/serialize-websocket-wrapper.js +19 -5
- package/dist/src/{events → wirings}/fetch/index.js +2 -2
- package/dist/src/{events → wirings}/http/openapi-spec-generator.d.ts +2 -2
- package/dist/src/wirings/http/pikku-command-http-map.js +8 -0
- package/dist/src/{events → wirings}/http/pikku-command-http-routes.js +3 -3
- package/dist/src/{events → wirings}/http/pikku-http-routes.js +3 -3
- package/dist/src/wirings/http/serialize-fetch-wrapper.js +67 -0
- package/dist/src/wirings/http/serialize-typed-http-map.d.ts +4 -0
- package/dist/src/{events → wirings}/http/serialize-typed-http-map.js +13 -13
- package/dist/src/{events → wirings}/mcp/pikku-command-mcp.js +3 -3
- package/dist/src/wirings/queue/pikku-command-queue-service.js +15 -0
- package/dist/src/{events → wirings}/queue/pikku-command-queue.js +3 -3
- package/dist/src/{events → wirings}/queue/pikku-queue.js +3 -3
- package/dist/src/wirings/rpc/pikku-command-rpc-client.js +15 -0
- package/dist/src/wirings/rpc/pikku-command-rpc.js +6 -0
- package/dist/src/wirings/rpc/pikku-rpc.js +6 -0
- package/dist/src/wirings/rpc/serialize-rpc-wrapper.js +68 -0
- package/dist/src/{events → wirings}/scheduler/pikku-command-scheduler.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/inspector-glob.ts +2 -2
- package/src/pikku-cli-config.ts +67 -52
- package/src/runtimes/nextjs/pikku-command-nextjs.ts +3 -3
- package/src/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +29 -29
- package/src/runtimes/nextjs/serialize-nextjs-http-wrapper.ts +28 -28
- package/src/schema-generator.ts +3 -3
- package/src/serialize-pikku-types.ts +67 -67
- package/src/utils.ts +26 -6
- package/src/{events → wirings}/channels/pikku-channels.ts +5 -4
- package/src/{events → wirings}/channels/pikku-command-channels.ts +5 -4
- package/src/{events → wirings}/channels/serialize-typed-channel-map.ts +3 -3
- package/src/{events → wirings}/channels/serialize-websocket-wrapper.ts +19 -5
- package/src/{events → wirings}/fetch/index.ts +2 -2
- package/src/{events → wirings}/http/openapi-spec-generator.ts +3 -3
- package/src/{events → wirings}/http/pikku-command-http-map.ts +5 -5
- package/src/{events → wirings}/http/pikku-command-http-routes.ts +5 -5
- package/src/{events → wirings}/http/pikku-http-routes.ts +5 -5
- package/src/wirings/http/serialize-fetch-wrapper.ts +67 -0
- package/src/{events → wirings}/http/serialize-typed-http-map.ts +17 -17
- package/src/{events → wirings}/mcp/pikku-command-mcp.ts +5 -5
- package/src/{events → wirings}/queue/pikku-command-queue-service.ts +9 -6
- package/src/{events → wirings}/queue/pikku-command-queue.ts +8 -5
- package/src/{events → wirings}/queue/pikku-queue.ts +8 -5
- package/src/{events → wirings}/rpc/pikku-command-rpc-client.ts +9 -6
- package/src/{events → wirings}/rpc/pikku-command-rpc.ts +2 -2
- package/src/{events → wirings}/rpc/pikku-rpc.ts +2 -2
- package/src/wirings/rpc/serialize-rpc-wrapper.ts +68 -0
- package/src/{events → wirings}/scheduler/pikku-command-scheduler.ts +8 -4
- package/dist/src/events/channels/pikku-channels.js +0 -9
- package/dist/src/events/channels/pikku-command-channels.js +0 -9
- package/dist/src/events/http/pikku-command-http-map.js +0 -8
- package/dist/src/events/http/serialize-fetch-wrapper.js +0 -67
- package/dist/src/events/http/serialize-typed-http-map.d.ts +0 -4
- package/dist/src/events/queue/pikku-command-queue-service.js +0 -12
- package/dist/src/events/rpc/pikku-command-rpc-client.js +0 -12
- package/dist/src/events/rpc/pikku-command-rpc.js +0 -6
- package/dist/src/events/rpc/pikku-rpc.js +0 -6
- package/dist/src/events/rpc/serialize-rpc-wrapper.js +0 -29
- package/src/events/http/serialize-fetch-wrapper.ts +0 -67
- package/src/events/rpc/serialize-rpc-wrapper.ts +0 -29
- /package/dist/src/{events → wirings}/channels/pikku-channels.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-channels-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-channels-map.js +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-channels.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-websocket-typed.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-websocket-typed.js +0 -0
- /package/dist/src/{events → wirings}/channels/serialize-typed-channel-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/serialize-websocket-wrapper.d.ts +0 -0
- /package/dist/src/{events → wirings}/fetch/index.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-function-types.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-function-types.js +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-functions.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-functions.js +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-services.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-services.js +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-function-types.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-function-types.js +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-functions.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-functions.js +0 -0
- /package/dist/src/{events → wirings}/http/openapi-spec-generator.js +0 -0
- /package/dist/src/{events → wirings}/http/pikku-command-http-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/http/pikku-command-http-routes.d.ts +0 -0
- /package/dist/src/{events → wirings}/http/pikku-command-openapi.d.ts +0 -0
- /package/dist/src/{events → wirings}/http/pikku-command-openapi.js +0 -0
- /package/dist/src/{events → wirings}/http/pikku-http-routes.d.ts +0 -0
- /package/dist/src/{events → wirings}/http/serialize-fetch-wrapper.d.ts +0 -0
- /package/dist/src/{events → wirings}/mcp/pikku-command-mcp-json.d.ts +0 -0
- /package/dist/src/{events → wirings}/mcp/pikku-command-mcp-json.js +0 -0
- /package/dist/src/{events → wirings}/mcp/pikku-command-mcp.d.ts +0 -0
- /package/dist/src/{events → wirings}/mcp/serialize-mcp-json.d.ts +0 -0
- /package/dist/src/{events → wirings}/mcp/serialize-mcp-json.js +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-command-queue-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-command-queue-map.js +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-command-queue-service.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-command-queue.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-queue-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-queue-map.js +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-queue.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-map.js +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-meta.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-meta.js +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-wrapper.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-wrapper.js +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-command-rpc-client.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-command-rpc-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-command-rpc-map.js +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-command-rpc.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-rpc.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/serialize-rpc-wrapper.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/serialize-typed-rpc-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/serialize-typed-rpc-map.js +0 -0
- /package/dist/src/{events → wirings}/scheduler/pikku-command-scheduler.d.ts +0 -0
- /package/dist/src/{events → wirings}/scheduler/serialize-scheduler-meta.d.ts +0 -0
- /package/dist/src/{events → wirings}/scheduler/serialize-scheduler-meta.js +0 -0
- /package/src/{events → wirings}/channels/pikku-command-channels-map.ts +0 -0
- /package/src/{events → wirings}/channels/pikku-command-websocket-typed.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-command-function-types.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-command-functions.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-command-services.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-function-types.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-functions.ts +0 -0
- /package/src/{events → wirings}/http/pikku-command-openapi.ts +0 -0
- /package/src/{events → wirings}/mcp/pikku-command-mcp-json.ts +0 -0
- /package/src/{events → wirings}/mcp/serialize-mcp-json.ts +0 -0
- /package/src/{events → wirings}/queue/pikku-command-queue-map.ts +0 -0
- /package/src/{events → wirings}/queue/pikku-queue-map.ts +0 -0
- /package/src/{events → wirings}/queue/serialize-queue-map.ts +0 -0
- /package/src/{events → wirings}/queue/serialize-queue-meta.ts +0 -0
- /package/src/{events → wirings}/queue/serialize-queue-wrapper.ts +0 -0
- /package/src/{events → wirings}/rpc/pikku-command-rpc-map.ts +0 -0
- /package/src/{events → wirings}/rpc/serialize-typed-rpc-map.ts +0 -0
- /package/src/{events → wirings}/scheduler/serialize-scheduler-meta.ts +0 -0
|
@@ -3,7 +3,7 @@ import { PikkuCommand } from '../../types.js'
|
|
|
3
3
|
|
|
4
4
|
export const pikkuRPC: PikkuCommand = async (
|
|
5
5
|
logger,
|
|
6
|
-
{
|
|
6
|
+
{ rpcWiringMetaFile },
|
|
7
7
|
{ rpc }
|
|
8
8
|
) => {
|
|
9
9
|
return await logCommandInfoAndTime(
|
|
@@ -14,7 +14,7 @@ export const pikkuRPC: PikkuCommand = async (
|
|
|
14
14
|
async () => {
|
|
15
15
|
await writeFileInDir(
|
|
16
16
|
logger,
|
|
17
|
-
|
|
17
|
+
rpcWiringMetaFile,
|
|
18
18
|
`import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.meta, null, 2)})`
|
|
19
19
|
)
|
|
20
20
|
}
|
|
@@ -3,7 +3,7 @@ import { PikkuCommand } from '../../types.js'
|
|
|
3
3
|
|
|
4
4
|
export const pikkuRPC: PikkuCommand = async (
|
|
5
5
|
logger,
|
|
6
|
-
{
|
|
6
|
+
{ rpcWiringMetaFile },
|
|
7
7
|
{ rpc }
|
|
8
8
|
) => {
|
|
9
9
|
return await logCommandInfoAndTime(
|
|
@@ -14,7 +14,7 @@ export const pikkuRPC: PikkuCommand = async (
|
|
|
14
14
|
async () => {
|
|
15
15
|
await writeFileInDir(
|
|
16
16
|
logger,
|
|
17
|
-
|
|
17
|
+
rpcWiringMetaFile,
|
|
18
18
|
`import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.meta, null, 2)})`
|
|
19
19
|
)
|
|
20
20
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export const serializeRPCWrapper = (rpcMapPath: string) => {
|
|
2
|
+
return `
|
|
3
|
+
import { PikkuFetch } from "./pikku-fetch.gen.js"
|
|
4
|
+
import type { RPCInvoke } from '${rpcMapPath}'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* PikkuRPC provides a type-safe client for making Remote Procedure Calls (RPC)
|
|
8
|
+
* to your Pikku server. It wraps the underlying HTTP client and provides a
|
|
9
|
+
* simple interface for invoking server-side functions.
|
|
10
|
+
*/
|
|
11
|
+
export class PikkuRPC {
|
|
12
|
+
/** The underlying HTTP client used for making RPC calls */
|
|
13
|
+
pikkuFetch = new PikkuFetch()
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Sets a custom PikkuFetch instance to use for RPC calls.
|
|
17
|
+
* This allows you to configure custom settings or use a shared client instance.
|
|
18
|
+
*
|
|
19
|
+
* @param pikkuFetch - The PikkuFetch instance to use
|
|
20
|
+
*/
|
|
21
|
+
setPikkuFetch(pikkuFetch: PikkuFetch): void {
|
|
22
|
+
this.pikkuFetch = pikkuFetch
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Sets the base server URL for all RPC calls.
|
|
27
|
+
*
|
|
28
|
+
* @param serverUrl - The base URL of your Pikku server (e.g., 'https://api.example.com')
|
|
29
|
+
*/
|
|
30
|
+
setServerUrl(serverUrl: string): void {
|
|
31
|
+
this.pikkuFetch.setServerUrl(serverUrl)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Sets the JWT token for authorization on all RPC calls.
|
|
36
|
+
*
|
|
37
|
+
* @param jwt - The JWT token to use for authorization, or null to remove authorization
|
|
38
|
+
*/
|
|
39
|
+
setAuthorizationJWT(jwt: string | null): void {
|
|
40
|
+
this.pikkuFetch.setAuthorizationJWT(jwt)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Sets the API key for authorization on all RPC calls.
|
|
45
|
+
*
|
|
46
|
+
* @param apiKey - The API key to use for authorization, or null to remove the API key
|
|
47
|
+
*/
|
|
48
|
+
setAPIKey(apiKey: string | null): void {
|
|
49
|
+
this.pikkuFetch.setAPIKey(apiKey)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Invokes a remote procedure call on the server.
|
|
54
|
+
* This is a generic method that routes to the appropriate server function
|
|
55
|
+
* based on the function name and passes the provided data.
|
|
56
|
+
*
|
|
57
|
+
* @param name - The name of the server function to invoke
|
|
58
|
+
* @param data - The data to pass to the server function
|
|
59
|
+
* @returns A promise that resolves with the function's return value
|
|
60
|
+
*/
|
|
61
|
+
invoke: RPCInvoke = async (name, data) => {
|
|
62
|
+
return await this.pikkuFetch.post('/rpc', { name, data })
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const pikkuRPC = new PikkuRPC();
|
|
67
|
+
`
|
|
68
|
+
}
|
|
@@ -17,19 +17,23 @@ export const pikkuScheduler: PikkuCommand = async (
|
|
|
17
17
|
'Found scheduled tasks',
|
|
18
18
|
[visitState.scheduledTasks.files.size === 0],
|
|
19
19
|
async () => {
|
|
20
|
-
const {
|
|
20
|
+
const {
|
|
21
|
+
schedulersWiringFile,
|
|
22
|
+
schedulersWiringMetaFile,
|
|
23
|
+
packageMappings,
|
|
24
|
+
} = cliConfig
|
|
21
25
|
const { scheduledTasks } = visitState
|
|
22
26
|
await writeFileInDir(
|
|
23
27
|
logger,
|
|
24
|
-
|
|
28
|
+
schedulersWiringMetaFile,
|
|
25
29
|
serializeSchedulerMeta(scheduledTasks.meta)
|
|
26
30
|
)
|
|
27
31
|
await writeFileInDir(
|
|
28
32
|
logger,
|
|
29
|
-
|
|
33
|
+
schedulersWiringFile,
|
|
30
34
|
serializeFileImports(
|
|
31
35
|
'addScheduledTasks',
|
|
32
|
-
|
|
36
|
+
schedulersWiringFile,
|
|
33
37
|
scheduledTasks.files,
|
|
34
38
|
packageMappings
|
|
35
39
|
)
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
|
-
export const pikkuChannels = async (logger, cliConfig, visitState) => {
|
|
3
|
-
return await logCommandInfoAndTime(logger, 'Finding Channels', 'Found channels', [visitState.channels.files.size === 0], async () => {
|
|
4
|
-
const { channelsFile, channelsMetaFile, packageMappings } = cliConfig;
|
|
5
|
-
const { channels } = visitState;
|
|
6
|
-
await writeFileInDir(logger, channelsFile, serializeFileImports('addChannel', channelsFile, channels.files, packageMappings));
|
|
7
|
-
await writeFileInDir(logger, channelsMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`);
|
|
8
|
-
});
|
|
9
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
|
-
export const pikkuChannels = async (logger, cliConfig, visitState) => {
|
|
3
|
-
return await logCommandInfoAndTime(logger, 'Finding Channels', 'Found channels', [visitState.channels.files.size === 0], async () => {
|
|
4
|
-
const { channelsFile, channelsMetaFile, packageMappings } = cliConfig;
|
|
5
|
-
const { channels } = visitState;
|
|
6
|
-
await writeFileInDir(logger, channelsFile, serializeFileImports('addChannel', channelsFile, channels.files, packageMappings));
|
|
7
|
-
await writeFileInDir(logger, channelsMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`);
|
|
8
|
-
});
|
|
9
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
|
|
2
|
-
import { serializeTypedRoutesMap } from './serialize-typed-http-map.js';
|
|
3
|
-
export const pikkuHTTPMap = async (logger, { httpRoutesMapDeclarationFile, packageMappings }, { http, functions }) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Creating HTTP map', 'Created HTTP map', [http.files.size === 0], async () => {
|
|
5
|
-
const content = serializeTypedRoutesMap(httpRoutesMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, http.meta, http.metaInputTypes);
|
|
6
|
-
await writeFileInDir(logger, httpRoutesMapDeclarationFile, content);
|
|
7
|
-
});
|
|
8
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export const serializeFetchWrapper = (routesMapPath) => {
|
|
2
|
-
return `
|
|
3
|
-
import { CorePikkuFetch, HTTPMethod } from '@pikku/fetch'
|
|
4
|
-
import type { RoutesMap, RouteHandlerOf, RoutesWithMethod } from '${routesMapPath}'
|
|
5
|
-
|
|
6
|
-
export class PikkuFetch extends CorePikkuFetch {
|
|
7
|
-
public async post<Route extends RoutesWithMethod<'POST'>>(
|
|
8
|
-
route: Route,
|
|
9
|
-
...args: null extends RouteHandlerOf<Route, 'POST'>['input']
|
|
10
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'POST'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
11
|
-
: [data: RouteHandlerOf<Route, 'POST'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
12
|
-
): Promise<RouteHandlerOf<Route, 'POST'>['output']> {
|
|
13
|
-
const [data, options] = args;
|
|
14
|
-
return super.api(route, 'POST', data, options);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public async get<Route extends RoutesWithMethod<'GET'>>(
|
|
18
|
-
route: Route,
|
|
19
|
-
...args: null extends RouteHandlerOf<Route, 'GET'>['input']
|
|
20
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'GET'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
21
|
-
: [data: RouteHandlerOf<Route, 'GET'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
22
|
-
): Promise<RouteHandlerOf<Route, 'GET'>['output']> {
|
|
23
|
-
const [data, options] = args;
|
|
24
|
-
return super.api(route, 'GET', data, options);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public async patch<Route extends RoutesWithMethod<'PATCH'>>(
|
|
28
|
-
route: Route,
|
|
29
|
-
...args: null extends RouteHandlerOf<Route, 'PATCH'>['input']
|
|
30
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'PATCH'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
31
|
-
: [data: RouteHandlerOf<Route, 'PATCH'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
32
|
-
): Promise<RouteHandlerOf<Route, 'PATCH'>['output']> {
|
|
33
|
-
const [data, options] = args;
|
|
34
|
-
return super.api(route, 'PATCH', data, options);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public async head<Route extends RoutesWithMethod<'HEAD'>>(
|
|
38
|
-
route: Route,
|
|
39
|
-
...args: null extends RouteHandlerOf<Route, 'HEAD'>['input']
|
|
40
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'HEAD'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
41
|
-
: [data: RouteHandlerOf<Route, 'HEAD'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
42
|
-
): Promise<RouteHandlerOf<Route, 'HEAD'>['output']> {
|
|
43
|
-
const [data, options] = args;
|
|
44
|
-
return super.api(route, 'HEAD', data, options);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public async delete<Route extends RoutesWithMethod<'DELETE'>>(
|
|
48
|
-
route: Route,
|
|
49
|
-
...args: null extends RouteHandlerOf<Route, 'DELETE'>['input']
|
|
50
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'DELETE'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
51
|
-
: [data: RouteHandlerOf<Route, 'DELETE'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
52
|
-
): Promise<RouteHandlerOf<Route, 'DELETE'>['output']> {
|
|
53
|
-
const [data, options] = args;
|
|
54
|
-
return super.api(route, 'DELETE', data, options);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public async fetch<
|
|
58
|
-
Route extends keyof RoutesMap,
|
|
59
|
-
Method extends keyof RoutesMap[Route]
|
|
60
|
-
>(route: Route, method: Method, data: RouteHandlerOf<Route, Method>['input'], options?: Omit<RequestInit, 'body'>): Promise<Response> {
|
|
61
|
-
return await super.fetch(route, method as HTTPMethod, data, options);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const pikkuFetch = new PikkuFetch();
|
|
66
|
-
`;
|
|
67
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { HTTPRoutesMeta } from '@pikku/core/http';
|
|
2
|
-
import { MetaInputTypes, TypesMap } from '@pikku/inspector';
|
|
3
|
-
import { FunctionsMeta } from '@pikku/core';
|
|
4
|
-
export declare const serializeTypedRoutesMap: (relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, functionsMeta: FunctionsMeta, routesMeta: HTTPRoutesMeta, metaTypes: MetaInputTypes) => string;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { serializeQueueWrapper } from './serialize-queue-wrapper.js';
|
|
2
|
-
import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
|
|
3
|
-
export const pikkuQueueService = async (logger, { queueFile, queueMapDeclarationFile, packageMappings }) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Generating queue service wrapper', 'Generated queue service wrapper', [queueFile === undefined, "queueFile isn't set in the pikku config"], async () => {
|
|
5
|
-
if (!queueFile) {
|
|
6
|
-
throw new Error("queueFile is isn't set in the pikku config");
|
|
7
|
-
}
|
|
8
|
-
const queueMapDeclarationPath = getFileImportRelativePath(queueFile, queueMapDeclarationFile, packageMappings);
|
|
9
|
-
const content = [serializeQueueWrapper(queueMapDeclarationPath)];
|
|
10
|
-
await writeFileInDir(logger, queueFile, content.join('\n'));
|
|
11
|
-
});
|
|
12
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { serializeRPCWrapper } from './serialize-rpc-wrapper.js';
|
|
2
|
-
import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
|
|
3
|
-
export const pikkuRPCClient = async (logger, { rpcFile, rpcMapDeclarationFile, packageMappings }) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Generating RPC wrapper', 'Generated RPC wrapper', [rpcFile === undefined, "rpcFile isn't set in the pikku config"], async () => {
|
|
5
|
-
if (!rpcFile) {
|
|
6
|
-
throw new Error("rpcFile isn't set in the pikku config");
|
|
7
|
-
}
|
|
8
|
-
const rpcMapDeclarationPath = getFileImportRelativePath(rpcFile, rpcMapDeclarationFile, packageMappings);
|
|
9
|
-
const content = [serializeRPCWrapper(rpcMapDeclarationPath)];
|
|
10
|
-
await writeFileInDir(logger, rpcFile, content.join('\n'));
|
|
11
|
-
});
|
|
12
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
|
|
2
|
-
export const pikkuRPC = async (logger, { rpcMetaFile }, { rpc }) => {
|
|
3
|
-
return await logCommandInfoAndTime(logger, 'Finding RPCs tasks', 'Found RPCs', [false], async () => {
|
|
4
|
-
await writeFileInDir(logger, rpcMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.meta, null, 2)})`);
|
|
5
|
-
});
|
|
6
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
|
|
2
|
-
export const pikkuRPC = async (logger, { rpcMetaFile }, { rpc }) => {
|
|
3
|
-
return await logCommandInfoAndTime(logger, 'Finding RPCs tasks', 'Found RPCs', [false], async () => {
|
|
4
|
-
await writeFileInDir(logger, rpcMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.meta, null, 2)})`);
|
|
5
|
-
});
|
|
6
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const serializeRPCWrapper = (rpcMapPath) => {
|
|
2
|
-
return `
|
|
3
|
-
import { PikkuFetch } from "./pikku-fetch.gen.js"
|
|
4
|
-
import type { RPCInvoke } from '${rpcMapPath}'
|
|
5
|
-
|
|
6
|
-
export class PikkuRPC {
|
|
7
|
-
pikkuFetch = new PikkuFetch()
|
|
8
|
-
|
|
9
|
-
setPikkuFetch(pikkuFetch: PikkuFetch): void {
|
|
10
|
-
this.pikkuFetch = pikkuFetch
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
setServerUrl(serverUrl: string): void {
|
|
14
|
-
this.pikkuFetch.setServerUrl(serverUrl)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
setAuthorizationJWT(jwt: string | null): void {
|
|
18
|
-
this.pikkuFetch.setAuthorizationJWT(jwt)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Generic RPC invoke method
|
|
22
|
-
invoke: RPCInvoke = async (name, data) => {
|
|
23
|
-
return await this.pikkuFetch.post('/rpc', { name, data })
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const pikkuRPC = new PikkuRPC();
|
|
28
|
-
`;
|
|
29
|
-
};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
export const serializeFetchWrapper = (routesMapPath: string) => {
|
|
2
|
-
return `
|
|
3
|
-
import { CorePikkuFetch, HTTPMethod } from '@pikku/fetch'
|
|
4
|
-
import type { RoutesMap, RouteHandlerOf, RoutesWithMethod } from '${routesMapPath}'
|
|
5
|
-
|
|
6
|
-
export class PikkuFetch extends CorePikkuFetch {
|
|
7
|
-
public async post<Route extends RoutesWithMethod<'POST'>>(
|
|
8
|
-
route: Route,
|
|
9
|
-
...args: null extends RouteHandlerOf<Route, 'POST'>['input']
|
|
10
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'POST'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
11
|
-
: [data: RouteHandlerOf<Route, 'POST'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
12
|
-
): Promise<RouteHandlerOf<Route, 'POST'>['output']> {
|
|
13
|
-
const [data, options] = args;
|
|
14
|
-
return super.api(route, 'POST', data, options);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public async get<Route extends RoutesWithMethod<'GET'>>(
|
|
18
|
-
route: Route,
|
|
19
|
-
...args: null extends RouteHandlerOf<Route, 'GET'>['input']
|
|
20
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'GET'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
21
|
-
: [data: RouteHandlerOf<Route, 'GET'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
22
|
-
): Promise<RouteHandlerOf<Route, 'GET'>['output']> {
|
|
23
|
-
const [data, options] = args;
|
|
24
|
-
return super.api(route, 'GET', data, options);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public async patch<Route extends RoutesWithMethod<'PATCH'>>(
|
|
28
|
-
route: Route,
|
|
29
|
-
...args: null extends RouteHandlerOf<Route, 'PATCH'>['input']
|
|
30
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'PATCH'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
31
|
-
: [data: RouteHandlerOf<Route, 'PATCH'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
32
|
-
): Promise<RouteHandlerOf<Route, 'PATCH'>['output']> {
|
|
33
|
-
const [data, options] = args;
|
|
34
|
-
return super.api(route, 'PATCH', data, options);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public async head<Route extends RoutesWithMethod<'HEAD'>>(
|
|
38
|
-
route: Route,
|
|
39
|
-
...args: null extends RouteHandlerOf<Route, 'HEAD'>['input']
|
|
40
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'HEAD'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
41
|
-
: [data: RouteHandlerOf<Route, 'HEAD'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
42
|
-
): Promise<RouteHandlerOf<Route, 'HEAD'>['output']> {
|
|
43
|
-
const [data, options] = args;
|
|
44
|
-
return super.api(route, 'HEAD', data, options);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public async delete<Route extends RoutesWithMethod<'DELETE'>>(
|
|
48
|
-
route: Route,
|
|
49
|
-
...args: null extends RouteHandlerOf<Route, 'DELETE'>['input']
|
|
50
|
-
? [data?: Exclude<RouteHandlerOf<Route, 'DELETE'>['input'], null>, options?: Omit<RequestInit, 'body'>]
|
|
51
|
-
: [data: RouteHandlerOf<Route, 'DELETE'>['input'], options?: Omit<RequestInit, 'body'>]
|
|
52
|
-
): Promise<RouteHandlerOf<Route, 'DELETE'>['output']> {
|
|
53
|
-
const [data, options] = args;
|
|
54
|
-
return super.api(route, 'DELETE', data, options);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
public async fetch<
|
|
58
|
-
Route extends keyof RoutesMap,
|
|
59
|
-
Method extends keyof RoutesMap[Route]
|
|
60
|
-
>(route: Route, method: Method, data: RouteHandlerOf<Route, Method>['input'], options?: Omit<RequestInit, 'body'>): Promise<Response> {
|
|
61
|
-
return await super.fetch(route, method as HTTPMethod, data, options);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const pikkuFetch = new PikkuFetch();
|
|
66
|
-
`
|
|
67
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const serializeRPCWrapper = (rpcMapPath: string) => {
|
|
2
|
-
return `
|
|
3
|
-
import { PikkuFetch } from "./pikku-fetch.gen.js"
|
|
4
|
-
import type { RPCInvoke } from '${rpcMapPath}'
|
|
5
|
-
|
|
6
|
-
export class PikkuRPC {
|
|
7
|
-
pikkuFetch = new PikkuFetch()
|
|
8
|
-
|
|
9
|
-
setPikkuFetch(pikkuFetch: PikkuFetch): void {
|
|
10
|
-
this.pikkuFetch = pikkuFetch
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
setServerUrl(serverUrl: string): void {
|
|
14
|
-
this.pikkuFetch.setServerUrl(serverUrl)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
setAuthorizationJWT(jwt: string | null): void {
|
|
18
|
-
this.pikkuFetch.setAuthorizationJWT(jwt)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Generic RPC invoke method
|
|
22
|
-
invoke: RPCInvoke = async (name, data) => {
|
|
23
|
-
return await this.pikkuFetch.post('/rpc', { name, data })
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const pikkuRPC = new PikkuRPC();
|
|
28
|
-
`
|
|
29
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|