@pikku/cli 0.9.0 → 0.9.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/CHANGELOG.md +30 -0
- package/bin/pikku-all.ts +9 -4
- package/bin/pikku-nextjs.ts +3 -3
- package/dist/bin/pikku-all.js +9 -4
- package/dist/bin/pikku-nextjs.js +3 -3
- package/dist/bin/pikku.js +0 -0
- package/dist/src/serialize-pikku-types.js +28 -25
- package/dist/src/utils.d.ts +5 -1
- package/dist/src/utils.js +17 -6
- package/dist/src/wirings/rpc/pikku-command-rpc-client.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/serialize-pikku-types.ts +28 -25
- package/src/utils.ts +26 -6
- package/src/wirings/rpc/pikku-command-rpc-client.ts +1 -1
- package/dist/src/events/channels/pikku-channels.d.ts +0 -2
- package/dist/src/events/channels/pikku-channels.js +0 -9
- package/dist/src/events/channels/pikku-command-channels-map.d.ts +0 -2
- package/dist/src/events/channels/pikku-command-channels-map.js +0 -8
- package/dist/src/events/channels/pikku-command-channels.d.ts +0 -2
- package/dist/src/events/channels/pikku-command-channels.js +0 -9
- package/dist/src/events/channels/pikku-command-websocket-typed.d.ts +0 -2
- package/dist/src/events/channels/pikku-command-websocket-typed.js +0 -15
- package/dist/src/events/channels/serialize-typed-channel-map.d.ts +0 -4
- package/dist/src/events/channels/serialize-typed-channel-map.js +0 -111
- package/dist/src/events/channels/serialize-websocket-wrapper.d.ts +0 -1
- package/dist/src/events/channels/serialize-websocket-wrapper.js +0 -75
- package/dist/src/events/fetch/index.d.ts +0 -2
- package/dist/src/events/fetch/index.js +0 -12
- package/dist/src/events/functions/pikku-command-function-types.d.ts +0 -2
- package/dist/src/events/functions/pikku-command-function-types.js +0 -13
- package/dist/src/events/functions/pikku-command-functions.d.ts +0 -6
- package/dist/src/events/functions/pikku-command-functions.js +0 -35
- package/dist/src/events/functions/pikku-command-services.d.ts +0 -3
- package/dist/src/events/functions/pikku-command-services.js +0 -73
- package/dist/src/events/functions/pikku-function-types.d.ts +0 -2
- package/dist/src/events/functions/pikku-function-types.js +0 -13
- package/dist/src/events/functions/pikku-functions.d.ts +0 -6
- package/dist/src/events/functions/pikku-functions.js +0 -35
- package/dist/src/events/http/openapi-spec-generator.d.ts +0 -79
- package/dist/src/events/http/openapi-spec-generator.js +0 -145
- package/dist/src/events/http/pikku-command-http-map.d.ts +0 -2
- package/dist/src/events/http/pikku-command-http-map.js +0 -8
- package/dist/src/events/http/pikku-command-http-routes.d.ts +0 -2
- package/dist/src/events/http/pikku-command-http-routes.js +0 -9
- package/dist/src/events/http/pikku-command-nextjs.d.ts +0 -2
- package/dist/src/events/http/pikku-command-nextjs.js +0 -36
- package/dist/src/events/http/pikku-command-openapi.d.ts +0 -2
- package/dist/src/events/http/pikku-command-openapi.js +0 -20
- package/dist/src/events/http/pikku-http-routes.d.ts +0 -2
- package/dist/src/events/http/pikku-http-routes.js +0 -9
- package/dist/src/events/http/serialize-fetch-wrapper.d.ts +0 -1
- 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/http/serialize-typed-http-map.js +0 -100
- package/dist/src/events/mcp/pikku-command-mcp-json.d.ts +0 -2
- package/dist/src/events/mcp/pikku-command-mcp-json.js +0 -13
- package/dist/src/events/mcp/pikku-command-mcp.d.ts +0 -2
- package/dist/src/events/mcp/pikku-command-mcp.js +0 -54
- package/dist/src/events/mcp/serialize-mcp-json.d.ts +0 -5
- package/dist/src/events/mcp/serialize-mcp-json.js +0 -101
- package/dist/src/events/queue/pikku-command-queue-map.d.ts +0 -2
- package/dist/src/events/queue/pikku-command-queue-map.js +0 -8
- package/dist/src/events/queue/pikku-command-queue-service.d.ts +0 -2
- package/dist/src/events/queue/pikku-command-queue-service.js +0 -12
- package/dist/src/events/queue/pikku-command-queue.d.ts +0 -2
- package/dist/src/events/queue/pikku-command-queue.js +0 -10
- package/dist/src/events/queue/pikku-queue-map.d.ts +0 -2
- package/dist/src/events/queue/pikku-queue-map.js +0 -8
- package/dist/src/events/queue/pikku-queue.d.ts +0 -2
- package/dist/src/events/queue/pikku-queue.js +0 -10
- package/dist/src/events/queue/serialize-queue-map.d.ts +0 -4
- package/dist/src/events/queue/serialize-queue-map.js +0 -77
- package/dist/src/events/queue/serialize-queue-meta.d.ts +0 -2
- package/dist/src/events/queue/serialize-queue-meta.js +0 -6
- package/dist/src/events/queue/serialize-queue-wrapper.d.ts +0 -1
- package/dist/src/events/queue/serialize-queue-wrapper.js +0 -35
- package/dist/src/events/rpc/index.d.ts +0 -2
- package/dist/src/events/rpc/index.js +0 -12
- package/dist/src/events/rpc/pikku-command-rpc-client.d.ts +0 -2
- package/dist/src/events/rpc/pikku-command-rpc-client.js +0 -12
- package/dist/src/events/rpc/pikku-command-rpc-map.d.ts +0 -2
- package/dist/src/events/rpc/pikku-command-rpc-map.js +0 -8
- package/dist/src/events/rpc/pikku-command-rpc.d.ts +0 -2
- package/dist/src/events/rpc/pikku-command-rpc.js +0 -6
- package/dist/src/events/rpc/pikku-rpc.d.ts +0 -2
- package/dist/src/events/rpc/pikku-rpc.js +0 -6
- package/dist/src/events/rpc/serialize-rpc-wrapper.d.ts +0 -1
- package/dist/src/events/rpc/serialize-rpc-wrapper.js +0 -68
- package/dist/src/events/rpc/serialize-typed-rpc-map.d.ts +0 -4
- package/dist/src/events/rpc/serialize-typed-rpc-map.js +0 -66
- package/dist/src/events/scheduler/pikku-command-scheduler.d.ts +0 -2
- package/dist/src/events/scheduler/pikku-command-scheduler.js +0 -10
- package/dist/src/events/scheduler/serialize-scheduler-meta.d.ts +0 -2
- package/dist/src/events/scheduler/serialize-scheduler-meta.js +0 -10
- package/lcov.info +0 -582
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
|
|
2
|
-
import { serializeTypedHTTPWiringsMap } from './serialize-typed-http-map.js';
|
|
3
|
-
export const pikkuHTTPMap = async (logger, { httpMapDeclarationFile, packageMappings }, { http, functions }) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Creating HTTP map', 'Created HTTP map', [http.files.size === 0], async () => {
|
|
5
|
-
const content = serializeTypedHTTPWiringsMap(httpMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, http.meta, http.metaInputTypes);
|
|
6
|
-
await writeFileInDir(logger, httpMapDeclarationFile, content);
|
|
7
|
-
});
|
|
8
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
|
-
export const pikkuHTTP = async (logger, cliConfig, visitState) => {
|
|
3
|
-
return await logCommandInfoAndTime(logger, 'Finding HTTP routes', 'Found HTTP routes', [visitState.http.files.size === 0], async () => {
|
|
4
|
-
const { httpWiringsFile, httpWiringMetaFile, packageMappings } = cliConfig;
|
|
5
|
-
const { http } = visitState;
|
|
6
|
-
await writeFileInDir(logger, httpWiringsFile, serializeFileImports('wireHTTP', httpWiringsFile, http.files, packageMappings));
|
|
7
|
-
await writeFileInDir(logger, httpWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`);
|
|
8
|
-
});
|
|
9
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { serializeNextJsBackendWrapper as serializeNextBackendWrapper } from '../../runtimes/nextjs/serialize-nextjs-backend-wrapper.js';
|
|
2
|
-
import { serializeNextJsHTTPWrapper as serializeNextHTTPWrapper } from '../../runtimes/nextjs/serialize-nextjs-http-wrapper.js';
|
|
3
|
-
import { getFileImportRelativePath, getPikkuFilesAndMethods, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
|
|
4
|
-
export const pikkuNext = async (logger, { nextBackendFile, nextHTTPFile, httpRoutesMapDeclarationFile, packageMappings, fetchFile, bootstrapFiles, }, visitState, options = {}) => {
|
|
5
|
-
return await logCommandInfoAndTime(logger, 'Generating nextjs wrapper', 'Generated nextjs wrapper', [
|
|
6
|
-
nextBackendFile === undefined && nextHTTPFile === undefined,
|
|
7
|
-
'nextjs outfile is not defined',
|
|
8
|
-
], async () => {
|
|
9
|
-
if (!nextBackendFile && !nextHTTPFile) {
|
|
10
|
-
throw new Error('nextBackendFile or nextHTTPFile is required in pikku config for nextJS');
|
|
11
|
-
}
|
|
12
|
-
if (nextHTTPFile && !fetchFile) {
|
|
13
|
-
throw new Error('fetchFile is required in pikku config in order for nextJS http wrapper to work');
|
|
14
|
-
}
|
|
15
|
-
if (nextBackendFile) {
|
|
16
|
-
const { pikkuConfigFactory, singletonServicesFactory, sessionServicesFactory, } = await getPikkuFilesAndMethods(logger, visitState, packageMappings, nextBackendFile, options, {
|
|
17
|
-
config: true,
|
|
18
|
-
singletonServicesFactory: true,
|
|
19
|
-
sessionServicesFactory: true,
|
|
20
|
-
});
|
|
21
|
-
const pikkuConfigImport = `import { ${pikkuConfigFactory.variable} as createConfig } from '${getFileImportRelativePath(nextBackendFile, pikkuConfigFactory.file, packageMappings)}'`;
|
|
22
|
-
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`;
|
|
23
|
-
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`;
|
|
24
|
-
const httpBootstrapPath = getFileImportRelativePath(nextBackendFile, bootstrapFiles.http, packageMappings);
|
|
25
|
-
const routesMapDeclarationPath = getFileImportRelativePath(nextBackendFile, httpRoutesMapDeclarationFile, packageMappings);
|
|
26
|
-
const content = serializeNextBackendWrapper(httpBootstrapPath, routesMapDeclarationPath, pikkuConfigImport, singletonServicesImport, sessionServicesImport);
|
|
27
|
-
await writeFileInDir(logger, nextBackendFile, content);
|
|
28
|
-
}
|
|
29
|
-
if (nextHTTPFile && fetchFile) {
|
|
30
|
-
const routesMapDeclarationPath = getFileImportRelativePath(nextHTTPFile, httpRoutesMapDeclarationFile, packageMappings);
|
|
31
|
-
const fetchPath = getFileImportRelativePath(nextHTTPFile, fetchFile, packageMappings);
|
|
32
|
-
const content = serializeNextHTTPWrapper(routesMapDeclarationPath, fetchPath);
|
|
33
|
-
await writeFileInDir(logger, nextHTTPFile, content);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
|
|
2
|
-
import { generateSchemas } from '../../schema-generator.js';
|
|
3
|
-
import { generateOpenAPISpec } from './openapi-spec-generator.js';
|
|
4
|
-
import { stringify } from 'yaml';
|
|
5
|
-
export const pikkuOpenAPI = async (logger, { tsconfig, openAPI }, { http, functions }) => {
|
|
6
|
-
return await logCommandInfoAndTime(logger, 'Creating OpenAPI spec', 'Created OpenAPI spec', [openAPI?.outputFile === undefined, 'openAPI outfile is not defined'], async () => {
|
|
7
|
-
if (!openAPI?.outputFile) {
|
|
8
|
-
throw new Error('openAPI is required');
|
|
9
|
-
}
|
|
10
|
-
const schemas = await generateSchemas(logger, tsconfig, functions.typesMap, functions.meta, http.meta);
|
|
11
|
-
const openAPISpec = await generateOpenAPISpec(functions.meta, http.meta, schemas, openAPI.additionalInfo);
|
|
12
|
-
if (openAPI.outputFile.endsWith('.json')) {
|
|
13
|
-
await writeFileInDir(logger, openAPI.outputFile, JSON.stringify(openAPISpec, null, 2), { ignoreModifyComment: true });
|
|
14
|
-
}
|
|
15
|
-
else if (openAPI.outputFile.endsWith('.yaml') ||
|
|
16
|
-
openAPI.outputFile.endsWith('.yml')) {
|
|
17
|
-
await writeFileInDir(logger, openAPI.outputFile, stringify(openAPISpec), { ignoreModifyComment: true });
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
|
-
export const pikkuHTTP = async (logger, cliConfig, visitState) => {
|
|
3
|
-
return await logCommandInfoAndTime(logger, 'Finding HTTP routes', 'Found HTTP routes', [visitState.http.files.size === 0], async () => {
|
|
4
|
-
const { httpWiringsFile, httpWiringMetaFile, packageMappings } = cliConfig;
|
|
5
|
-
const { http } = visitState;
|
|
6
|
-
await writeFileInDir(logger, httpWiringsFile, serializeFileImports('wireHTTP', httpWiringsFile, http.files, packageMappings));
|
|
7
|
-
await writeFileInDir(logger, httpWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`);
|
|
8
|
-
});
|
|
9
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const serializeFetchWrapper: (routesMapPath: string) => string;
|
|
@@ -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 { HTTPWiringsMeta } from '@pikku/core/http';
|
|
2
|
-
import { MetaInputTypes, TypesMap } from '@pikku/inspector';
|
|
3
|
-
import { FunctionsMeta } from '@pikku/core';
|
|
4
|
-
export declare const serializeTypedHTTPWiringsMap: (relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, functionsMeta: FunctionsMeta, wiringsMeta: HTTPWiringsMeta, metaTypes: MetaInputTypes) => string;
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { serializeImportMap } from '../../serialize-import-map.js';
|
|
2
|
-
import { generateCustomTypes } from '../../utils.js';
|
|
3
|
-
export const serializeTypedHTTPWiringsMap = (relativeToPath, packageMappings, typesMap, functionsMeta, wiringsMeta, metaTypes) => {
|
|
4
|
-
const requiredTypes = new Set();
|
|
5
|
-
const serializedCustomTypes = generateCustomTypes(typesMap, requiredTypes);
|
|
6
|
-
const serializedMetaTypes = generateMetaTypes(metaTypes, typesMap);
|
|
7
|
-
const serializedHTTPWirings = generateHTTPWirings(wiringsMeta, functionsMeta, typesMap, requiredTypes);
|
|
8
|
-
const serializedImportMap = serializeImportMap(relativeToPath, packageMappings, typesMap, requiredTypes);
|
|
9
|
-
return `/**
|
|
10
|
-
* This provides the structure needed for typescript to be aware of routes and their return types
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
${serializedImportMap}
|
|
14
|
-
${serializedCustomTypes}
|
|
15
|
-
${serializedMetaTypes}
|
|
16
|
-
|
|
17
|
-
interface HTTPWiringHandler<I, O> {
|
|
18
|
-
input: I;
|
|
19
|
-
output: O;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
${serializedHTTPWirings}
|
|
23
|
-
|
|
24
|
-
export type HTTPWiringHandlerOf<HTTPWiring extends keyof HTTPWiringsMap, Method extends keyof HTTPWiringsMap[HTTPWiring]> =
|
|
25
|
-
HTTPWiringsMap[HTTPWiring][Method] extends { input: infer I; output: infer O }
|
|
26
|
-
? HTTPWiringHandler<I, O>
|
|
27
|
-
: never;
|
|
28
|
-
|
|
29
|
-
export type HTTPWiringsWithMethod<Method extends string> = {
|
|
30
|
-
[HTTPWiring in keyof HTTPWiringsMap]: Method extends keyof HTTPWiringsMap[HTTPWiring] ? HTTPWiring : never;
|
|
31
|
-
}[keyof HTTPWiringsMap];
|
|
32
|
-
`;
|
|
33
|
-
};
|
|
34
|
-
function generateHTTPWirings(routesMeta, functionsMeta, typesMap, requiredTypes) {
|
|
35
|
-
// Initialize an object to collect routes
|
|
36
|
-
const routesObj = {};
|
|
37
|
-
for (const meta of routesMeta) {
|
|
38
|
-
const { route, method, pikkuFuncName } = meta;
|
|
39
|
-
const functionMeta = functionsMeta[pikkuFuncName];
|
|
40
|
-
if (!functionMeta) {
|
|
41
|
-
throw new Error(`Function ${pikkuFuncName} not found in functionsMeta. Please check your configuration.`);
|
|
42
|
-
}
|
|
43
|
-
const input = functionMeta.inputs ? functionMeta.inputs[0] : undefined;
|
|
44
|
-
const output = functionMeta.outputs ? functionMeta.outputs[0] : undefined;
|
|
45
|
-
// Initialize the route entry if it doesn't exist
|
|
46
|
-
if (!routesObj[route]) {
|
|
47
|
-
routesObj[route] = {};
|
|
48
|
-
}
|
|
49
|
-
// Store the input and output types separately for RouteHandler
|
|
50
|
-
const inputType = input ? typesMap.getTypeMeta(input).uniqueName : 'null';
|
|
51
|
-
const outputType = output ? typesMap.getTypeMeta(output).uniqueName : 'null';
|
|
52
|
-
requiredTypes.add(inputType);
|
|
53
|
-
requiredTypes.add(outputType);
|
|
54
|
-
// Add method entry
|
|
55
|
-
routesObj[route][method] = {
|
|
56
|
-
inputType,
|
|
57
|
-
outputType,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// Build the routes object as a string
|
|
61
|
-
let routesStr = 'export type RoutesMap = {\n';
|
|
62
|
-
for (const [routePath, methods] of Object.entries(routesObj)) {
|
|
63
|
-
routesStr += ` readonly '${routePath}': {\n`;
|
|
64
|
-
for (const [method, handler] of Object.entries(methods)) {
|
|
65
|
-
routesStr += ` readonly ${method.toUpperCase()}: RouteHandler<${handler.inputType}, ${handler.outputType}>,\n`;
|
|
66
|
-
}
|
|
67
|
-
routesStr += ' },\n';
|
|
68
|
-
}
|
|
69
|
-
routesStr += '};';
|
|
70
|
-
return routesStr;
|
|
71
|
-
}
|
|
72
|
-
const generateMetaTypes = (metaTypes, typesMap) => {
|
|
73
|
-
const nameToTypeMap = Array.from(metaTypes.entries()).reduce((result, [_name, { query, body, params }]) => {
|
|
74
|
-
const { uniqueName } = typesMap.getTypeMeta(_name);
|
|
75
|
-
const queryType = query && query.length > 0
|
|
76
|
-
? `Pick<${uniqueName}, '${query?.join("' | '")}'>`
|
|
77
|
-
: undefined;
|
|
78
|
-
if (queryType) {
|
|
79
|
-
result.set(`${uniqueName}Query`, queryType);
|
|
80
|
-
}
|
|
81
|
-
const paramsType = params && params.length > 0
|
|
82
|
-
? `Pick<${uniqueName}, '${params.join("' | '")}'>`
|
|
83
|
-
: undefined;
|
|
84
|
-
if (paramsType) {
|
|
85
|
-
result.set(`${uniqueName}Params`, paramsType);
|
|
86
|
-
}
|
|
87
|
-
const bodyType = (body && body.length > 0) || (params && params.length > 0)
|
|
88
|
-
? `Omit<${uniqueName}, '${[...new Set([...(query || []), ...(params || [])])].join("' | '")}'>`
|
|
89
|
-
: uniqueName;
|
|
90
|
-
if (bodyType) {
|
|
91
|
-
result.set(`${uniqueName}Body`, bodyType);
|
|
92
|
-
}
|
|
93
|
-
return result;
|
|
94
|
-
}, new Map());
|
|
95
|
-
return `
|
|
96
|
-
// The '& {}' is a workaround for not directly refering to a type since it confuses typescript
|
|
97
|
-
${Array.from(nameToTypeMap.entries())
|
|
98
|
-
.map(([name, type]) => `export type ${name} = ${type} & {}`)
|
|
99
|
-
.join('\n')}`;
|
|
100
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
|
|
2
|
-
import { serializeMCPJson } from './serialize-mcp-json.js';
|
|
3
|
-
export const pikkuMCPJSON = async (logger, { mcpJsonFile, schemaDirectory }, { mcpEndpoints, functions }) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Generating MCP JSON', 'Generated MCP JSON', [mcpEndpoints.files.size === 0 || !mcpJsonFile], async () => {
|
|
5
|
-
// Generate MCP JSON file
|
|
6
|
-
if (mcpJsonFile) {
|
|
7
|
-
const mcpJson = await serializeMCPJson(logger, schemaDirectory, functions.meta, functions.typesMap, mcpEndpoints.resourcesMeta, mcpEndpoints.toolsMeta, mcpEndpoints.promptsMeta);
|
|
8
|
-
await writeFileInDir(logger, mcpJsonFile, mcpJson, {
|
|
9
|
-
ignoreModifyComment: true,
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
|
-
import { readFile } from 'fs/promises';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
// Helper function to generate arguments from schema
|
|
5
|
-
const generateArgumentsFromSchema = async (inputSchema, schemaDirectory, typesMap, logger) => {
|
|
6
|
-
if (!inputSchema)
|
|
7
|
-
return [];
|
|
8
|
-
if (['boolean', 'string', 'number', 'null', 'undefined', 'void'].includes(inputSchema)) {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
const uniqueName = typesMap.getUniqueName(inputSchema);
|
|
12
|
-
if (!uniqueName)
|
|
13
|
-
return [];
|
|
14
|
-
try {
|
|
15
|
-
const schemaPath = join(schemaDirectory, 'schemas', `${uniqueName}.schema.json`);
|
|
16
|
-
const schemaContent = await readFile(schemaPath, 'utf-8');
|
|
17
|
-
const schema = JSON.parse(schemaContent);
|
|
18
|
-
const argumentsArray = [];
|
|
19
|
-
if (schema && typeof schema === 'object' && schema.properties) {
|
|
20
|
-
const properties = schema.properties;
|
|
21
|
-
const required = schema.required || [];
|
|
22
|
-
for (const [propName, propSchema] of Object.entries(properties)) {
|
|
23
|
-
argumentsArray.push({
|
|
24
|
-
name: propName,
|
|
25
|
-
description: propSchema.description || `${propName} parameter`,
|
|
26
|
-
required: required.includes(propName),
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return argumentsArray;
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
logger.warn(`Could not load schema for type: ${uniqueName}`);
|
|
34
|
-
return [];
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export const pikkuMCP = async (logger, { mcpWiringsFile, mcpWiringsMetaFile, packageMappings, schemaDirectory }, { mcpEndpoints, functions }) => {
|
|
38
|
-
return await logCommandInfoAndTime(logger, 'Finding MCP endpoints', 'Found MCP endpoints', [mcpEndpoints.files.size === 0], async () => {
|
|
39
|
-
await writeFileInDir(logger, mcpWiringsFile, serializeFileImports('wireMCPResource or wireMCPTool', mcpWiringsFile, mcpEndpoints.files, packageMappings));
|
|
40
|
-
// Populate arguments for prompts meta before serializing
|
|
41
|
-
const promptsMetaWithArguments = { ...mcpEndpoints.promptsMeta };
|
|
42
|
-
for (const promptMeta of Object.values(promptsMetaWithArguments)) {
|
|
43
|
-
const functionMeta = functions.meta[promptMeta.pikkuFuncName];
|
|
44
|
-
if (functionMeta) {
|
|
45
|
-
const inputType = functionMeta.inputs?.[0];
|
|
46
|
-
promptMeta.arguments = await generateArgumentsFromSchema(inputType || null, schemaDirectory || '', functions.typesMap, logger);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
await writeFileInDir(logger, mcpWiringsMetaFile, `import { pikkuState } from '@pikku/core'
|
|
50
|
-
pikkuState('mcp', 'resourcesMeta', ${JSON.stringify(mcpEndpoints.resourcesMeta, null, 2)})
|
|
51
|
-
pikkuState('mcp', 'toolsMeta', ${JSON.stringify(mcpEndpoints.toolsMeta, null, 2)})
|
|
52
|
-
pikkuState('mcp', 'promptsMeta', ${JSON.stringify(promptsMetaWithArguments, null, 2)})`);
|
|
53
|
-
});
|
|
54
|
-
};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core';
|
|
2
|
-
import { FunctionsMeta } from '@pikku/core';
|
|
3
|
-
import { TypesMap } from '@pikku/inspector';
|
|
4
|
-
import { CLILogger } from '../../utils.js';
|
|
5
|
-
export declare const serializeMCPJson: (logger: CLILogger, schemaDirectory: string, functionsMeta: FunctionsMeta, typesMap: TypesMap, mcpResourceMeta: MCPResourceMeta, mcpToolMeta: MCPToolMeta, mcpPromptMeta: MCPPromptMeta) => Promise<string>;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'fs/promises';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
export const serializeMCPJson = async (logger, schemaDirectory, functionsMeta, typesMap, mcpResourceMeta, mcpToolMeta, mcpPromptMeta) => {
|
|
4
|
-
const tools = [];
|
|
5
|
-
const resources = [];
|
|
6
|
-
const prompts = [];
|
|
7
|
-
// Helper function to load schema from file
|
|
8
|
-
const loadSchema = async (typeName) => {
|
|
9
|
-
if (!typeName ||
|
|
10
|
-
['boolean', 'string', 'number', 'null', 'undefined', 'void'].includes(typeName)) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
const uniqueName = typesMap.getUniqueName(typeName);
|
|
14
|
-
if (!uniqueName) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
const schemaPath = join(schemaDirectory, 'schemas', `${uniqueName}.schema.json`);
|
|
19
|
-
const schemaContent = await readFile(schemaPath, 'utf-8');
|
|
20
|
-
return JSON.parse(schemaContent);
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
logger.warn(`Could not load schema for type: ${uniqueName}`);
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
// Process MCP resources
|
|
28
|
-
for (const [name, endpointMeta] of Object.entries(mcpResourceMeta)) {
|
|
29
|
-
const functionMeta = functionsMeta[endpointMeta.pikkuFuncName];
|
|
30
|
-
if (!functionMeta) {
|
|
31
|
-
logger.warn(`Function ${endpointMeta.pikkuFuncName} not found in functionsMeta. Skipping resource ${name}.`);
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
const inputType = functionMeta.inputs?.[0];
|
|
35
|
-
const outputType = functionMeta.outputs?.[0];
|
|
36
|
-
const parameters = await loadSchema(inputType);
|
|
37
|
-
const returns = await loadSchema(outputType);
|
|
38
|
-
const endpoint = {
|
|
39
|
-
uri: name,
|
|
40
|
-
name,
|
|
41
|
-
description: endpointMeta.description,
|
|
42
|
-
...(parameters && { parameters }),
|
|
43
|
-
...(returns && { returns }),
|
|
44
|
-
...(endpointMeta.streaming && { streaming: true }),
|
|
45
|
-
};
|
|
46
|
-
resources.push(endpoint);
|
|
47
|
-
}
|
|
48
|
-
// Process MCP tools
|
|
49
|
-
for (const [name, endpointMeta] of Object.entries(mcpToolMeta)) {
|
|
50
|
-
const functionMeta = functionsMeta[endpointMeta.pikkuFuncName];
|
|
51
|
-
if (!functionMeta) {
|
|
52
|
-
logger.warn(`Function ${endpointMeta.pikkuFuncName} not found in functionsMeta. Skipping tool ${name}.`);
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
const inputType = functionMeta.inputs?.[0];
|
|
56
|
-
const outputType = functionMeta.outputs?.[0];
|
|
57
|
-
const parameters = await loadSchema(inputType);
|
|
58
|
-
const returns = await loadSchema(outputType);
|
|
59
|
-
const endpoint = {
|
|
60
|
-
name,
|
|
61
|
-
description: endpointMeta.description,
|
|
62
|
-
...(parameters && { parameters }),
|
|
63
|
-
...(returns && { returns }),
|
|
64
|
-
...(endpointMeta.streaming && { streaming: true }),
|
|
65
|
-
};
|
|
66
|
-
tools.push(endpoint);
|
|
67
|
-
}
|
|
68
|
-
// Process MCP prompts
|
|
69
|
-
for (const [name, endpointMeta] of Object.entries(mcpPromptMeta)) {
|
|
70
|
-
const functionMeta = functionsMeta[endpointMeta.pikkuFuncName];
|
|
71
|
-
if (!functionMeta) {
|
|
72
|
-
logger.warn(`Function ${endpointMeta.pikkuFuncName} not found in functionsMeta. Skipping prompt ${name}.`);
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
const inputType = functionMeta.inputs?.[0];
|
|
76
|
-
// TODO: this needs to be a json schema type, not any
|
|
77
|
-
const inputSchema = await loadSchema(inputType);
|
|
78
|
-
// Generate arguments from input schema
|
|
79
|
-
const argumentsArray = [];
|
|
80
|
-
if (inputSchema &&
|
|
81
|
-
typeof inputSchema === 'object' &&
|
|
82
|
-
inputSchema.properties) {
|
|
83
|
-
const properties = inputSchema.properties;
|
|
84
|
-
const required = inputSchema.required || [];
|
|
85
|
-
for (const [propName, propSchema] of Object.entries(properties)) {
|
|
86
|
-
argumentsArray.push({
|
|
87
|
-
name: propName,
|
|
88
|
-
description: propSchema.description || `${propName} parameter`,
|
|
89
|
-
required: required.includes(propName),
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const prompt = {
|
|
94
|
-
name,
|
|
95
|
-
description: endpointMeta.description,
|
|
96
|
-
arguments: argumentsArray,
|
|
97
|
-
};
|
|
98
|
-
prompts.push(prompt);
|
|
99
|
-
}
|
|
100
|
-
return JSON.stringify({ tools, resources, prompts }, null, 2);
|
|
101
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
|
|
2
|
-
import { serializeQueueMap } from './serialize-queue-map.js';
|
|
3
|
-
export const pikkuQueueMap = async (logger, { queueMapDeclarationFile, packageMappings }, { queueWorkers, functions }) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Creating Queue map', 'Created Queue map', [queueWorkers.files.size === 0], async () => {
|
|
5
|
-
const content = serializeQueueMap(queueMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, queueWorkers.meta);
|
|
6
|
-
await writeFileInDir(logger, queueMapDeclarationFile, content);
|
|
7
|
-
});
|
|
8
|
-
};
|
|
@@ -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, { queueWiringsFile, queueMapDeclarationFile, packageMappings }) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Generating queue service wrapper', 'Generated queue service wrapper', [queueWiringsFile === undefined, "queueWiringsFile isn't set in the pikku config"], async () => {
|
|
5
|
-
if (!queueWiringsFile) {
|
|
6
|
-
throw new Error("queueWiringsFile is isn't set in the pikku config");
|
|
7
|
-
}
|
|
8
|
-
const queueMapDeclarationPath = getFileImportRelativePath(queueWiringsFile, queueMapDeclarationFile, packageMappings);
|
|
9
|
-
const content = [serializeQueueWrapper(queueMapDeclarationPath)];
|
|
10
|
-
await writeFileInDir(logger, queueWiringsFile, content.join('\n'));
|
|
11
|
-
});
|
|
12
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
|
-
import { serializeQueueMeta } from './serialize-queue-meta.js';
|
|
3
|
-
export const pikkuQueue = async (logger, cliConfig, visitState) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Finding queues', 'Found queue', [visitState.queueWorkers.files.size === 0], async () => {
|
|
5
|
-
const { queueWorkersWiringFile, queueWorkersWiringMetaFile, packageMappings } = cliConfig;
|
|
6
|
-
const { queueWorkers } = visitState;
|
|
7
|
-
await writeFileInDir(logger, queueWorkersWiringMetaFile, serializeQueueMeta(queueWorkers.meta));
|
|
8
|
-
await writeFileInDir(logger, queueWorkersWiringFile, serializeFileImports('addQueueWorkers', queueWorkersWiringFile, queueWorkers.files, packageMappings));
|
|
9
|
-
});
|
|
10
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
|
|
2
|
-
import { serializeQueueMap } from './serialize-queue-map.js';
|
|
3
|
-
export const pikkuQueueMap = async (logger, { queueMapDeclarationFile, packageMappings }, { queueWorkers, functions }) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Creating Queue map', 'Created Queue map', [queueWorkers.files.size === 0], async () => {
|
|
5
|
-
const content = serializeQueueMap(queueMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, queueWorkers.meta);
|
|
6
|
-
await writeFileInDir(logger, queueMapDeclarationFile, content);
|
|
7
|
-
});
|
|
8
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
|
-
import { serializeQueueMeta } from './serialize-queue-meta.js';
|
|
3
|
-
export const pikkuQueue = async (logger, cliConfig, visitState) => {
|
|
4
|
-
return await logCommandInfoAndTime(logger, 'Finding queues', 'Found queue', [visitState.queueWorkers.files.size === 0], async () => {
|
|
5
|
-
const { queueWorkersWiringFile, queueWorkersWiringMetaFile, packageMappings } = cliConfig;
|
|
6
|
-
const { queueWorkers } = visitState;
|
|
7
|
-
await writeFileInDir(logger, queueWorkersWiringMetaFile, serializeQueueMeta(queueWorkers.meta));
|
|
8
|
-
await writeFileInDir(logger, queueWorkersWiringFile, serializeFileImports('addQueueWorkers', queueWorkersWiringFile, queueWorkers.files, packageMappings));
|
|
9
|
-
});
|
|
10
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { queueWorkersMeta } from '@pikku/core/queue';
|
|
2
|
-
import { TypesMap } from '@pikku/inspector';
|
|
3
|
-
import { FunctionsMeta } from '@pikku/core';
|
|
4
|
-
export declare const serializeQueueMap: (relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, functionsMeta: FunctionsMeta, queueWorkersMeta: queueWorkersMeta) => string;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { serializeImportMap } from '../../serialize-import-map.js';
|
|
2
|
-
import { generateCustomTypes } from '../../utils.js';
|
|
3
|
-
export const serializeQueueMap = (relativeToPath, packageMappings, typesMap, functionsMeta, queueWorkersMeta) => {
|
|
4
|
-
const requiredTypes = new Set();
|
|
5
|
-
const serializedCustomTypes = generateCustomTypes(typesMap, requiredTypes);
|
|
6
|
-
const serializedQueues = generateQueues(queueWorkersMeta, functionsMeta, typesMap, requiredTypes);
|
|
7
|
-
const serializedImportMap = serializeImportMap(relativeToPath, packageMappings, typesMap, requiredTypes);
|
|
8
|
-
return `/**
|
|
9
|
-
* This provides the structure needed for typescript to be aware of Queue workers and their input/output types
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
${serializedImportMap}
|
|
13
|
-
${serializedCustomTypes}
|
|
14
|
-
|
|
15
|
-
import type { QueueJob } from '@pikku/core/queue'
|
|
16
|
-
|
|
17
|
-
interface QueueHandler<I, O> {
|
|
18
|
-
input: I;
|
|
19
|
-
output: O;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
${serializedQueues}
|
|
23
|
-
|
|
24
|
-
type QueueAdd = <Name extends keyof QueueMap>(
|
|
25
|
-
name: Name,
|
|
26
|
-
data: QueueMap[Name]['input'],
|
|
27
|
-
options?: {
|
|
28
|
-
priority?: number
|
|
29
|
-
delay?: number
|
|
30
|
-
attempts?: number
|
|
31
|
-
removeOnComplete?: number
|
|
32
|
-
removeOnFail?: number
|
|
33
|
-
jobId?: string
|
|
34
|
-
}
|
|
35
|
-
) => Promise<string>
|
|
36
|
-
|
|
37
|
-
type QueueGetJob = <Name extends keyof QueueMap>(
|
|
38
|
-
name: Name,
|
|
39
|
-
jobId: string
|
|
40
|
-
) => Promise<QueueJob<QueueMap[Name]['input'], QueueMap[Name]['output']> | null>
|
|
41
|
-
|
|
42
|
-
export type TypedPikkuQueue = {
|
|
43
|
-
add: QueueAdd;
|
|
44
|
-
getJob: QueueGetJob;
|
|
45
|
-
}
|
|
46
|
-
`;
|
|
47
|
-
};
|
|
48
|
-
function generateQueues(queueWorkersMeta, functionsMeta, typesMap, requiredTypes) {
|
|
49
|
-
// Initialize an object to collect queues
|
|
50
|
-
const queuesObj = {};
|
|
51
|
-
// Iterate through Queue metadata
|
|
52
|
-
for (const [queueName, { pikkuFuncName }] of Object.entries(queueWorkersMeta)) {
|
|
53
|
-
const functionMeta = functionsMeta[pikkuFuncName];
|
|
54
|
-
if (!functionMeta) {
|
|
55
|
-
throw new Error(`Function ${queueName} not found in functionsMeta. Please check your configuration.`);
|
|
56
|
-
}
|
|
57
|
-
const input = functionMeta.inputs ? functionMeta.inputs[0] : undefined;
|
|
58
|
-
const output = functionMeta.outputs ? functionMeta.outputs[0] : undefined;
|
|
59
|
-
// Store the input and output types for QueueHandler
|
|
60
|
-
const inputType = input ? typesMap.getTypeMeta(input).uniqueName : 'null';
|
|
61
|
-
const outputType = output ? typesMap.getTypeMeta(output).uniqueName : 'null';
|
|
62
|
-
requiredTypes.add(inputType);
|
|
63
|
-
requiredTypes.add(outputType);
|
|
64
|
-
// Add Queue entry
|
|
65
|
-
queuesObj[queueName] = {
|
|
66
|
-
inputType,
|
|
67
|
-
outputType,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
// Build the Queues object as a string
|
|
71
|
-
let queuesStr = 'export type QueueMap = {\n';
|
|
72
|
-
for (const [queueName, handler] of Object.entries(queuesObj)) {
|
|
73
|
-
queuesStr += ` readonly '${queueName}': QueueHandler<${handler.inputType}, ${handler.outputType}>,\n`;
|
|
74
|
-
}
|
|
75
|
-
queuesStr += '};\n';
|
|
76
|
-
return queuesStr;
|
|
77
|
-
}
|