@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
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { OpenAPISpecInfo } from './
|
|
1
|
+
import { OpenAPISpecInfo } from './wirings/http/openapi-spec-generator.js';
|
|
2
2
|
import { InspectorFilters } from '@pikku/inspector';
|
|
3
|
-
import {
|
|
3
|
+
import { PikkuWiringTypes } from '@pikku/core';
|
|
4
4
|
export interface PikkuCLICoreOutputFiles {
|
|
5
5
|
outDir?: string;
|
|
6
6
|
schemaDirectory: string;
|
|
7
7
|
typesDeclarationFile: string;
|
|
8
8
|
functionsFile: string;
|
|
9
9
|
functionsMetaFile: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
httpWiringsFile: string;
|
|
11
|
+
httpWiringMetaFile: string;
|
|
12
|
+
httpMapDeclarationFile: string;
|
|
13
|
+
channelsWiringFile: string;
|
|
14
|
+
channelsWiringMetaFile: string;
|
|
15
15
|
channelsMapDeclarationFile: string;
|
|
16
|
-
|
|
16
|
+
rpcWiringMetaFile: string;
|
|
17
17
|
rpcMapDeclarationFile: string;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
schedulersWiringFile: string;
|
|
19
|
+
schedulersWiringMetaFile: string;
|
|
20
|
+
queueWorkersWiringFile: string;
|
|
21
|
+
queueWorkersWiringMetaFile: string;
|
|
22
22
|
queueMapDeclarationFile: string;
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
mcpWiringsFile: string;
|
|
24
|
+
mcpWiringsMetaFile: string;
|
|
25
25
|
servicesFile: string;
|
|
26
26
|
bootstrapFile: string;
|
|
27
|
-
bootstrapFiles: Record<
|
|
27
|
+
bootstrapFiles: Record<PikkuWiringTypes, string>;
|
|
28
28
|
}
|
|
29
29
|
export type PikkuCLIConfig = {
|
|
30
30
|
$schema?: string;
|
|
@@ -39,8 +39,8 @@ export type PikkuCLIConfig = {
|
|
|
39
39
|
nextHTTPFile?: string;
|
|
40
40
|
fetchFile?: string;
|
|
41
41
|
websocketFile?: string;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
rpcWiringsFile?: string;
|
|
43
|
+
queueWiringsFile?: string;
|
|
44
44
|
mcpJsonFile?: string;
|
|
45
45
|
openAPI?: {
|
|
46
46
|
outputFile: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { join, dirname, resolve, isAbsolute } from 'path';
|
|
2
2
|
import { readdir, readFile } from 'fs/promises';
|
|
3
|
-
import {
|
|
3
|
+
import { PikkuWiringTypes } from '@pikku/core';
|
|
4
4
|
const CONFIG_DIR_FILES = [
|
|
5
5
|
'nextBackendFile',
|
|
6
6
|
'nextHTTPFile',
|
|
7
7
|
'fetchFile',
|
|
8
8
|
'websocketFile',
|
|
9
|
-
'
|
|
10
|
-
'
|
|
9
|
+
'rpcWiringsFile',
|
|
10
|
+
'queueWiringsFile',
|
|
11
11
|
'mcpJsonFile',
|
|
12
12
|
];
|
|
13
13
|
export const getPikkuCLIConfig = async (configFile = undefined, requiredFields, filters = {}, exitProcess = false) => {
|
|
@@ -80,48 +80,48 @@ const _getPikkuCLIConfig = async (configFile = undefined, requiredFields, filter
|
|
|
80
80
|
result.typesDeclarationFile = join(result.outDir, 'pikku-types.gen.ts');
|
|
81
81
|
}
|
|
82
82
|
// HTTP
|
|
83
|
-
if (!result.
|
|
84
|
-
result.
|
|
83
|
+
if (!result.httpWiringsFile) {
|
|
84
|
+
result.httpWiringsFile = join(httpDir, 'pikku-http-wirings.gen.ts');
|
|
85
85
|
}
|
|
86
|
-
if (!result.
|
|
87
|
-
result.
|
|
86
|
+
if (!result.httpWiringMetaFile) {
|
|
87
|
+
result.httpWiringMetaFile = join(httpDir, 'pikku-http-wirings-meta.gen.ts');
|
|
88
88
|
}
|
|
89
|
-
if (!result.
|
|
90
|
-
result.
|
|
89
|
+
if (!result.httpMapDeclarationFile) {
|
|
90
|
+
result.httpMapDeclarationFile = join(httpDir, 'pikku-http-wirings-map.gen.d.ts');
|
|
91
91
|
}
|
|
92
92
|
// Channels/WebSocket
|
|
93
|
-
if (!result.
|
|
94
|
-
result.
|
|
93
|
+
if (!result.channelsWiringFile) {
|
|
94
|
+
result.channelsWiringFile = join(channelDir, 'pikku-channels.gen.ts');
|
|
95
95
|
}
|
|
96
|
-
if (!result.
|
|
97
|
-
result.
|
|
96
|
+
if (!result.channelsWiringMetaFile) {
|
|
97
|
+
result.channelsWiringMetaFile = join(channelDir, 'pikku-channels-meta.gen.ts');
|
|
98
98
|
}
|
|
99
99
|
if (!result.channelsMapDeclarationFile) {
|
|
100
100
|
result.channelsMapDeclarationFile = join(channelDir, 'pikku-channels-map.gen.d.ts');
|
|
101
101
|
}
|
|
102
102
|
// RPC
|
|
103
|
-
if (!result.
|
|
104
|
-
result.
|
|
103
|
+
if (!result.rpcWiringMetaFile) {
|
|
104
|
+
result.rpcWiringMetaFile = join(rpcDir, 'pikku-rpc-wirings-meta.gen.ts');
|
|
105
105
|
}
|
|
106
106
|
if (!result.rpcMapDeclarationFile) {
|
|
107
|
-
result.rpcMapDeclarationFile = join(rpcDir, 'pikku-rpc-map.gen.ts');
|
|
107
|
+
result.rpcMapDeclarationFile = join(rpcDir, 'pikku-rpc-wirings-map.gen.d.ts');
|
|
108
108
|
}
|
|
109
109
|
// Scheduler
|
|
110
|
-
if (!result.
|
|
111
|
-
result.
|
|
110
|
+
if (!result.schedulersWiringFile) {
|
|
111
|
+
result.schedulersWiringFile = join(schedulerDir, 'pikku-schedulers-wirings.gen.ts');
|
|
112
112
|
}
|
|
113
|
-
if (!result.
|
|
114
|
-
result.
|
|
113
|
+
if (!result.schedulersWiringMetaFile) {
|
|
114
|
+
result.schedulersWiringMetaFile = join(schedulerDir, 'pikku-schedulers-wirings-meta.gen.ts');
|
|
115
115
|
}
|
|
116
116
|
// Queue
|
|
117
|
-
if (!result.
|
|
118
|
-
result.
|
|
117
|
+
if (!result.queueWorkersWiringFile) {
|
|
118
|
+
result.queueWorkersWiringFile = join(queueDir, 'pikku-queue-workers-wirings.gen.ts');
|
|
119
119
|
}
|
|
120
|
-
if (!result.
|
|
121
|
-
result.
|
|
120
|
+
if (!result.queueWorkersWiringMetaFile) {
|
|
121
|
+
result.queueWorkersWiringMetaFile = join(queueDir, 'pikku-queue-workers-wirings-meta.gen.ts');
|
|
122
122
|
}
|
|
123
123
|
if (!result.queueMapDeclarationFile) {
|
|
124
|
-
result.queueMapDeclarationFile = join(queueDir, 'pikku-queue-map.gen.ts');
|
|
124
|
+
result.queueMapDeclarationFile = join(queueDir, 'pikku-queue-workers-wirings-map.gen.d.ts');
|
|
125
125
|
}
|
|
126
126
|
// Services
|
|
127
127
|
if (!result.servicesFile) {
|
|
@@ -132,17 +132,17 @@ const _getPikkuCLIConfig = async (configFile = undefined, requiredFields, filter
|
|
|
132
132
|
result.bootstrapFile = join(result.outDir, 'pikku-bootstrap.gen.ts');
|
|
133
133
|
}
|
|
134
134
|
// MCP
|
|
135
|
-
if (!result.
|
|
136
|
-
result.
|
|
135
|
+
if (!result.mcpWiringsMetaFile) {
|
|
136
|
+
result.mcpWiringsMetaFile = join(mcpDir, 'pikku-mcp-wirings-meta.gen.ts');
|
|
137
137
|
}
|
|
138
|
-
if (!result.
|
|
139
|
-
result.
|
|
138
|
+
if (!result.mcpWiringsFile) {
|
|
139
|
+
result.mcpWiringsFile = join(mcpDir, 'pikku-mcp-wirings.gen.ts');
|
|
140
140
|
}
|
|
141
141
|
if (!result.mcpJsonFile) {
|
|
142
|
-
result.mcpJsonFile = join(mcpDir, 'mcp.gen.json');
|
|
142
|
+
result.mcpJsonFile = join(mcpDir, 'pikku-mcp.gen.json');
|
|
143
143
|
}
|
|
144
144
|
result.bootstrapFiles = result.bootstrapFiles || {};
|
|
145
|
-
for (const key of Object.keys(
|
|
145
|
+
for (const key of Object.keys(PikkuWiringTypes)) {
|
|
146
146
|
const eventDir = join(result.outDir, key.toLowerCase());
|
|
147
147
|
result.bootstrapFiles[key] = join(eventDir, `pikku-bootstrap-${key}.gen.ts`);
|
|
148
148
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logCommandInfoAndTime, getPikkuFilesAndMethods, getFileImportRelativePath, writeFileInDir, } from '../../utils.js';
|
|
2
2
|
import { serializeNextJsBackendWrapper as serializeNextBackendWrapper } from './serialize-nextjs-backend-wrapper.js';
|
|
3
3
|
import { serializeNextJsHTTPWrapper as serializeNextHTTPWrapper } from './serialize-nextjs-http-wrapper.js';
|
|
4
|
-
export const pikkuNext = async (logger, { nextBackendFile, nextHTTPFile,
|
|
4
|
+
export const pikkuNext = async (logger, { nextBackendFile, nextHTTPFile, httpMapDeclarationFile, packageMappings, fetchFile, bootstrapFiles, }, visitState, options = {}) => {
|
|
5
5
|
return await logCommandInfoAndTime(logger, 'Generating nextjs wrapper', 'Generated nextjs wrapper', [
|
|
6
6
|
nextBackendFile === undefined && nextHTTPFile === undefined,
|
|
7
7
|
'nextjs outfile is not defined',
|
|
@@ -22,12 +22,12 @@ export const pikkuNext = async (logger, { nextBackendFile, nextHTTPFile, httpRou
|
|
|
22
22
|
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`;
|
|
23
23
|
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`;
|
|
24
24
|
const httpBootstrapPath = getFileImportRelativePath(nextBackendFile, bootstrapFiles.http, packageMappings);
|
|
25
|
-
const routesMapDeclarationPath = getFileImportRelativePath(nextBackendFile,
|
|
25
|
+
const routesMapDeclarationPath = getFileImportRelativePath(nextBackendFile, httpMapDeclarationFile, packageMappings);
|
|
26
26
|
const content = serializeNextBackendWrapper(httpBootstrapPath, routesMapDeclarationPath, pikkuConfigImport, singletonServicesImport, sessionServicesImport);
|
|
27
27
|
await writeFileInDir(logger, nextBackendFile, content);
|
|
28
28
|
}
|
|
29
29
|
if (nextHTTPFile && fetchFile) {
|
|
30
|
-
const routesMapDeclarationPath = getFileImportRelativePath(nextHTTPFile,
|
|
30
|
+
const routesMapDeclarationPath = getFileImportRelativePath(nextHTTPFile, httpMapDeclarationFile, packageMappings);
|
|
31
31
|
const fetchPath = getFileImportRelativePath(nextHTTPFile, fetchFile, packageMappings);
|
|
32
32
|
const content = serializeNextHTTPWrapper(routesMapDeclarationPath, fetchPath);
|
|
33
33
|
await writeFileInDir(logger, nextHTTPFile, content);
|
|
@@ -6,7 +6,7 @@ export const serializeNextJsBackendWrapper = (httpBootstrapPath, routesMapPath,
|
|
|
6
6
|
* It ensures type safety for route handling methods when integrating with the @pikku/core framework.
|
|
7
7
|
*/
|
|
8
8
|
import { PikkuNextJS } from '@pikku/next'
|
|
9
|
-
import type {
|
|
9
|
+
import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
|
|
10
10
|
|
|
11
11
|
${configImport}
|
|
12
12
|
${singleServicesFactoryImport}
|
|
@@ -34,7 +34,7 @@ export const pikku = (_options?: any) => {
|
|
|
34
34
|
* Makes a dynamic action request for a specified route and method.
|
|
35
35
|
* Dynamic requests may access headers and cookies and are therefore unsuitable for precompile stages.
|
|
36
36
|
*
|
|
37
|
-
* @template Route - The route key from the
|
|
37
|
+
* @template Route - The route key from the HTTPWiringsMap.
|
|
38
38
|
* @template Method - The method key from the specified route.
|
|
39
39
|
* @param route - The route identifier.
|
|
40
40
|
* @param method - The HTTP method to be used for the request.
|
|
@@ -42,13 +42,13 @@ export const pikku = (_options?: any) => {
|
|
|
42
42
|
* @returns A promise that resolves to the output of the route handler.
|
|
43
43
|
*/
|
|
44
44
|
const dynamicActionRequest = async <
|
|
45
|
-
Route extends keyof
|
|
46
|
-
Method extends keyof
|
|
45
|
+
Route extends keyof HTTPWiringsMap,
|
|
46
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
47
47
|
>(
|
|
48
48
|
route: Route,
|
|
49
49
|
method: Method,
|
|
50
|
-
data:
|
|
51
|
-
): Promise<
|
|
50
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
51
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
52
52
|
return _pikku!.actionRequest(route, method, data as any)
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -56,7 +56,7 @@ export const pikku = (_options?: any) => {
|
|
|
56
56
|
* Makes a static action request for a specified route and method.
|
|
57
57
|
* Static requests do not depend on headers or cookies and are suitable for precompile stages.
|
|
58
58
|
*
|
|
59
|
-
* @template Route - The route key from the
|
|
59
|
+
* @template Route - The route key from the HTTPWiringsMap.
|
|
60
60
|
* @template Method - The method key from the specified route.
|
|
61
61
|
* @param route - The route identifier.
|
|
62
62
|
* @param method - The HTTP method to be used for the request.
|
|
@@ -64,13 +64,13 @@ export const pikku = (_options?: any) => {
|
|
|
64
64
|
* @returns A promise that resolves to the output of the route handler.
|
|
65
65
|
*/
|
|
66
66
|
const staticActionRequest = async <
|
|
67
|
-
Route extends keyof
|
|
68
|
-
Method extends keyof
|
|
67
|
+
Route extends keyof HTTPWiringsMap,
|
|
68
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
69
69
|
>(
|
|
70
70
|
route: Route,
|
|
71
71
|
method: Method,
|
|
72
|
-
data:
|
|
73
|
-
): Promise<
|
|
72
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
73
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
74
74
|
return _pikku!.staticActionRequest(route, method, data as any)
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -82,10 +82,10 @@ export const pikku = (_options?: any) => {
|
|
|
82
82
|
* @param data - The input data for the POST request, defaults to null.
|
|
83
83
|
* @returns A promise that resolves to the output of the POST handler.
|
|
84
84
|
*/
|
|
85
|
-
const dynamicPost = <Route extends
|
|
85
|
+
const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
86
86
|
route: Route,
|
|
87
|
-
data:
|
|
88
|
-
): Promise<
|
|
87
|
+
data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
|
|
88
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
89
89
|
return dynamicActionRequest(route, 'POST', data)
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -97,10 +97,10 @@ export const pikku = (_options?: any) => {
|
|
|
97
97
|
* @param data - The input data for the GET request, defaults to null.
|
|
98
98
|
* @returns A promise that resolves to the output of the GET handler.
|
|
99
99
|
*/
|
|
100
|
-
const dynamicGet = <Route extends
|
|
100
|
+
const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
101
101
|
route: Route,
|
|
102
|
-
data:
|
|
103
|
-
): Promise<
|
|
102
|
+
data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
|
|
103
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
104
104
|
return dynamicActionRequest(route, 'GET', data)
|
|
105
105
|
}
|
|
106
106
|
|
|
@@ -112,10 +112,10 @@ export const pikku = (_options?: any) => {
|
|
|
112
112
|
* @param data - The input data for the PATCH request, defaults to null.
|
|
113
113
|
* @returns A promise that resolves to the output of the PATCH handler.
|
|
114
114
|
*/
|
|
115
|
-
const dynamicPatch = <Route extends
|
|
115
|
+
const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
|
|
116
116
|
route: Route,
|
|
117
|
-
data:
|
|
118
|
-
): Promise<
|
|
117
|
+
data: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] = null
|
|
118
|
+
): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
|
|
119
119
|
return dynamicActionRequest(route, 'PATCH', data)
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -127,10 +127,10 @@ export const pikku = (_options?: any) => {
|
|
|
127
127
|
* @param data - The input data for the DELETE request, defaults to null.
|
|
128
128
|
* @returns A promise that resolves to the output of the DELETE handler.
|
|
129
129
|
*/
|
|
130
|
-
const dynamicDel = <Route extends
|
|
130
|
+
const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
|
|
131
131
|
route: Route,
|
|
132
|
-
data:
|
|
133
|
-
): Promise<
|
|
132
|
+
data: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] = null
|
|
133
|
+
): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
|
|
134
134
|
return dynamicActionRequest(route, 'DELETE', data)
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -144,10 +144,10 @@ export const pikku = (_options?: any) => {
|
|
|
144
144
|
* @param data - The input data for the POST request, defaults to null.
|
|
145
145
|
* @returns A promise that resolves to the output of the POST handler.
|
|
146
146
|
*/
|
|
147
|
-
const staticPost = <Route extends
|
|
147
|
+
const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
148
148
|
route: Route,
|
|
149
|
-
data:
|
|
150
|
-
): Promise<
|
|
149
|
+
data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
|
|
150
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
151
151
|
return staticActionRequest(route, 'POST', data)
|
|
152
152
|
}
|
|
153
153
|
|
|
@@ -159,10 +159,10 @@ export const pikku = (_options?: any) => {
|
|
|
159
159
|
* @param data - The input data for the GET request, defaults to null.
|
|
160
160
|
* @returns A promise that resolves to the output of the GET handler.
|
|
161
161
|
*/
|
|
162
|
-
const staticGet = <Route extends
|
|
162
|
+
const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
163
163
|
route: Route,
|
|
164
|
-
data:
|
|
165
|
-
): Promise<
|
|
164
|
+
data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
|
|
165
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
166
166
|
return staticActionRequest(route, 'GET', data)
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -6,7 +6,7 @@ export const serializeNextJsHTTPWrapper = (routesMapPath, pikkuFetchImport) => {
|
|
|
6
6
|
* It ensures type safety for route handling methods when integrating with the @pikku/core framework.
|
|
7
7
|
*/
|
|
8
8
|
import { CorePikkuFetchOptions } from '@pikku/fetch'
|
|
9
|
-
import type {
|
|
9
|
+
import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
|
|
10
10
|
import { PikkuFetch } from '${pikkuFetchImport}'
|
|
11
11
|
|
|
12
12
|
let _pikku: PikkuFetch | undefined
|
|
@@ -22,13 +22,13 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const dynamicActionRequest = async <
|
|
25
|
-
Route extends keyof
|
|
26
|
-
Method extends keyof
|
|
25
|
+
Route extends keyof HTTPWiringsMap,
|
|
26
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
27
27
|
>(
|
|
28
28
|
route: Route,
|
|
29
29
|
method: Method,
|
|
30
|
-
data:
|
|
31
|
-
): Promise<
|
|
30
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
31
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
32
32
|
return (_pikku! as any)[(method as string).toLowerCase()](route, data as any)
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
36
36
|
* Makes a static action request for a specified route and method.
|
|
37
37
|
* Static requests do not depend on headers or cookies and are suitable for precompile stages.
|
|
38
38
|
*
|
|
39
|
-
* @template Route - The route key from the
|
|
39
|
+
* @template Route - The route key from the HTTPWiringsMap.
|
|
40
40
|
* @template Method - The method key from the specified route.
|
|
41
41
|
* @param route - The route identifier.
|
|
42
42
|
* @param method - The HTTP method to be used for the request.
|
|
@@ -44,13 +44,13 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
44
44
|
* @returns A promise that resolves to the output of the route handler.
|
|
45
45
|
*/
|
|
46
46
|
const staticActionRequest = async <
|
|
47
|
-
Route extends keyof
|
|
48
|
-
Method extends keyof
|
|
47
|
+
Route extends keyof HTTPWiringsMap,
|
|
48
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
49
49
|
>(
|
|
50
50
|
route: Route,
|
|
51
51
|
method: Method,
|
|
52
|
-
data:
|
|
53
|
-
): Promise<
|
|
52
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
53
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
54
54
|
return (_pikku! as any)[(method as string).toLowerCase()](route, data as any)
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -62,10 +62,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
62
62
|
* @param data - The input data for the POST request, defaults to null.
|
|
63
63
|
* @returns A promise that resolves to the output of the POST handler.
|
|
64
64
|
*/
|
|
65
|
-
const dynamicPost = <Route extends
|
|
65
|
+
const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
66
66
|
route: Route,
|
|
67
|
-
data:
|
|
68
|
-
): Promise<
|
|
67
|
+
data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
|
|
68
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
69
69
|
return dynamicActionRequest(route, 'POST', data)
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -77,10 +77,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
77
77
|
* @param data - The input data for the GET request, defaults to null.
|
|
78
78
|
* @returns A promise that resolves to the output of the GET handler.
|
|
79
79
|
*/
|
|
80
|
-
const dynamicGet = <Route extends
|
|
80
|
+
const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
81
81
|
route: Route,
|
|
82
|
-
data:
|
|
83
|
-
): Promise<
|
|
82
|
+
data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
|
|
83
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
84
84
|
return dynamicActionRequest(route, 'GET', data)
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -92,10 +92,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
92
92
|
* @param data - The input data for the PATCH request, defaults to null.
|
|
93
93
|
* @returns A promise that resolves to the output of the PATCH handler.
|
|
94
94
|
*/
|
|
95
|
-
const dynamicPatch = <Route extends
|
|
95
|
+
const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
|
|
96
96
|
route: Route,
|
|
97
|
-
data:
|
|
98
|
-
): Promise<
|
|
97
|
+
data: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] = null
|
|
98
|
+
): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
|
|
99
99
|
return dynamicActionRequest(route, 'PATCH', data)
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -107,10 +107,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
107
107
|
* @param data - The input data for the DELETE request, defaults to null.
|
|
108
108
|
* @returns A promise that resolves to the output of the DELETE handler.
|
|
109
109
|
*/
|
|
110
|
-
const dynamicDel = <Route extends
|
|
110
|
+
const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
|
|
111
111
|
route: Route,
|
|
112
|
-
data:
|
|
113
|
-
): Promise<
|
|
112
|
+
data: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] = null
|
|
113
|
+
): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
|
|
114
114
|
return dynamicActionRequest(route, 'DELETE', data)
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -124,10 +124,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
124
124
|
* @param data - The input data for the POST request, defaults to null.
|
|
125
125
|
* @returns A promise that resolves to the output of the POST handler.
|
|
126
126
|
*/
|
|
127
|
-
const staticPost = <Route extends
|
|
127
|
+
const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
128
128
|
route: Route,
|
|
129
|
-
data:
|
|
130
|
-
): Promise<
|
|
129
|
+
data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
|
|
130
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
131
131
|
return staticActionRequest(route, 'POST', data)
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -139,10 +139,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
139
139
|
* @param data - The input data for the GET request, defaults to null.
|
|
140
140
|
* @returns A promise that resolves to the output of the GET handler.
|
|
141
141
|
*/
|
|
142
|
-
const staticGet = <Route extends
|
|
142
|
+
const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
143
143
|
route: Route,
|
|
144
|
-
data:
|
|
145
|
-
): Promise<
|
|
144
|
+
data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
|
|
145
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
146
146
|
return staticActionRequest(route, 'GET', data)
|
|
147
147
|
}
|
|
148
148
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLILogger } from './utils.js';
|
|
2
2
|
import { FunctionsMeta, JSONValue } from '@pikku/core';
|
|
3
|
-
import {
|
|
3
|
+
import { HTTPWiringsMeta } from '@pikku/core/http';
|
|
4
4
|
import { TypesMap } from '@pikku/inspector';
|
|
5
|
-
export declare function generateSchemas(logger: CLILogger, tsconfig: string, typesMap: TypesMap, functionMeta: FunctionsMeta,
|
|
5
|
+
export declare function generateSchemas(logger: CLILogger, tsconfig: string, typesMap: TypesMap, functionMeta: FunctionsMeta, httpWiringsMeta: HTTPWiringsMeta): Promise<Record<string, JSONValue>>;
|
|
6
6
|
export declare function saveSchemas(logger: CLILogger, schemaParentDir: string, schemas: Record<string, JSONValue>, typesMap: TypesMap, functionsMeta: FunctionsMeta, supportsImportAttributes: boolean): Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createGenerator, RootlessError } from 'ts-json-schema-generator';
|
|
2
2
|
import { writeFileInDir } from './utils.js';
|
|
3
3
|
import { mkdir, writeFile } from 'fs/promises';
|
|
4
|
-
export async function generateSchemas(logger, tsconfig, typesMap, functionMeta,
|
|
4
|
+
export async function generateSchemas(logger, tsconfig, typesMap, functionMeta, httpWiringsMeta) {
|
|
5
5
|
const schemasSet = new Set(typesMap.customTypes.keys());
|
|
6
6
|
for (const { inputs, outputs } of Object.values(functionMeta)) {
|
|
7
7
|
const types = [...(inputs || []), ...(outputs || [])];
|
|
@@ -12,7 +12,7 @@ export async function generateSchemas(logger, tsconfig, typesMap, functionMeta,
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
for (const { inputTypes } of
|
|
15
|
+
for (const { inputTypes } of httpWiringsMeta) {
|
|
16
16
|
if (inputTypes?.body) {
|
|
17
17
|
schemasSet.add(inputTypes.body);
|
|
18
18
|
}
|