@pikku/cli 0.7.7 → 0.8.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.
Files changed (197) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/bin/pikku-all.ts +188 -91
  3. package/bin/pikku-fetch.ts +10 -38
  4. package/bin/pikku-nextjs.ts +12 -113
  5. package/bin/pikku-openapi.ts +9 -54
  6. package/bin/pikku-queue-service.ts +28 -0
  7. package/bin/pikku-schemas.ts +6 -32
  8. package/bin/pikku-websocket.ts +11 -41
  9. package/bin/pikku.ts +2 -0
  10. package/cli.schema.json +113 -10
  11. package/dist/bin/pikku-all.d.ts +1 -1
  12. package/dist/bin/pikku-all.js +105 -84
  13. package/dist/bin/pikku-fetch.d.ts +1 -3
  14. package/dist/bin/pikku-fetch.js +9 -15
  15. package/dist/bin/pikku-nextjs.d.ts +1 -4
  16. package/dist/bin/pikku-nextjs.js +10 -40
  17. package/dist/bin/pikku-openapi.d.ts +0 -3
  18. package/dist/bin/pikku-openapi.js +8 -24
  19. package/dist/bin/pikku-queue-service.d.ts +4 -0
  20. package/dist/bin/pikku-queue-service.js +19 -0
  21. package/dist/bin/pikku-schemas.d.ts +0 -3
  22. package/dist/bin/pikku-schemas.js +5 -11
  23. package/dist/bin/pikku-websocket.d.ts +1 -3
  24. package/dist/bin/pikku-websocket.js +9 -18
  25. package/dist/bin/pikku.js +2 -0
  26. package/dist/src/events/channels/pikku-channels.d.ts +2 -0
  27. package/dist/src/events/channels/pikku-channels.js +9 -0
  28. package/dist/src/events/channels/pikku-command-channels-map.d.ts +2 -0
  29. package/dist/src/events/channels/pikku-command-channels-map.js +8 -0
  30. package/dist/src/events/channels/pikku-command-channels.d.ts +2 -0
  31. package/dist/src/events/channels/pikku-command-channels.js +9 -0
  32. package/dist/src/events/channels/pikku-command-websocket-typed.d.ts +2 -0
  33. package/dist/src/events/channels/pikku-command-websocket-typed.js +15 -0
  34. package/dist/src/{serialize-typed-channel-map.js → events/channels/serialize-typed-channel-map.js} +2 -2
  35. package/dist/src/events/fetch/index.d.ts +2 -0
  36. package/dist/src/events/fetch/index.js +12 -0
  37. package/dist/src/events/functions/pikku-command-function-types.d.ts +2 -0
  38. package/dist/src/events/functions/pikku-command-function-types.js +13 -0
  39. package/dist/src/events/functions/pikku-command-functions.d.ts +6 -0
  40. package/dist/src/events/functions/pikku-command-functions.js +35 -0
  41. package/dist/src/events/functions/pikku-command-services.d.ts +3 -0
  42. package/dist/src/events/functions/pikku-command-services.js +73 -0
  43. package/dist/src/events/functions/pikku-function-types.d.ts +2 -0
  44. package/dist/{bin → src/events/functions}/pikku-function-types.js +6 -6
  45. package/dist/src/events/functions/pikku-functions.d.ts +6 -0
  46. package/dist/{bin → src/events/functions}/pikku-functions.js +5 -5
  47. package/dist/src/events/http/pikku-command-http-map.d.ts +2 -0
  48. package/dist/src/events/http/pikku-command-http-map.js +8 -0
  49. package/dist/src/events/http/pikku-command-http-routes.d.ts +2 -0
  50. package/dist/src/events/http/pikku-command-http-routes.js +9 -0
  51. package/dist/src/events/http/pikku-command-openapi.d.ts +2 -0
  52. package/dist/src/events/http/pikku-command-openapi.js +20 -0
  53. package/dist/src/events/http/pikku-http-routes.d.ts +2 -0
  54. package/dist/src/events/http/pikku-http-routes.js +9 -0
  55. package/dist/src/{serialize-typed-http-map.d.ts → events/http/serialize-typed-http-map.d.ts} +0 -1
  56. package/dist/src/{serialize-typed-http-map.js → events/http/serialize-typed-http-map.js} +2 -15
  57. package/dist/src/events/mcp/pikku-command-mcp-json.d.ts +2 -0
  58. package/dist/src/events/mcp/pikku-command-mcp-json.js +13 -0
  59. package/dist/src/events/mcp/pikku-command-mcp.d.ts +2 -0
  60. package/dist/src/events/mcp/pikku-command-mcp.js +54 -0
  61. package/dist/src/events/mcp/serialize-mcp-json.d.ts +5 -0
  62. package/dist/src/events/mcp/serialize-mcp-json.js +101 -0
  63. package/dist/src/events/queue/pikku-command-queue-map.d.ts +2 -0
  64. package/dist/src/events/queue/pikku-command-queue-map.js +8 -0
  65. package/dist/src/events/queue/pikku-command-queue-service.d.ts +2 -0
  66. package/dist/src/events/queue/pikku-command-queue-service.js +12 -0
  67. package/dist/src/events/queue/pikku-command-queue.d.ts +2 -0
  68. package/dist/src/events/queue/pikku-command-queue.js +10 -0
  69. package/dist/src/events/queue/pikku-queue-map.d.ts +2 -0
  70. package/dist/src/events/queue/pikku-queue-map.js +8 -0
  71. package/dist/src/events/queue/pikku-queue.d.ts +2 -0
  72. package/dist/src/events/queue/pikku-queue.js +10 -0
  73. package/dist/src/events/queue/serialize-queue-map.d.ts +4 -0
  74. package/dist/src/events/queue/serialize-queue-map.js +77 -0
  75. package/dist/src/events/queue/serialize-queue-meta.d.ts +2 -0
  76. package/dist/src/events/queue/serialize-queue-meta.js +6 -0
  77. package/dist/src/events/queue/serialize-queue-wrapper.d.ts +1 -0
  78. package/dist/src/events/queue/serialize-queue-wrapper.js +35 -0
  79. package/dist/src/events/rpc/pikku-command-rpc-client.d.ts +2 -0
  80. package/dist/src/events/rpc/pikku-command-rpc-client.js +12 -0
  81. package/dist/src/events/rpc/pikku-command-rpc-map.d.ts +2 -0
  82. package/dist/src/events/rpc/pikku-command-rpc-map.js +8 -0
  83. package/dist/src/events/rpc/pikku-command-rpc.d.ts +2 -0
  84. package/dist/src/events/rpc/pikku-command-rpc.js +6 -0
  85. package/dist/src/events/rpc/pikku-rpc.d.ts +2 -0
  86. package/dist/src/events/rpc/pikku-rpc.js +6 -0
  87. package/dist/src/events/rpc/serialize-rpc-wrapper.d.ts +1 -0
  88. package/dist/src/events/rpc/serialize-rpc-wrapper.js +29 -0
  89. package/dist/src/{serialize-typed-rpc-map.d.ts → events/rpc/serialize-typed-rpc-map.d.ts} +1 -1
  90. package/dist/src/{serialize-typed-rpc-map.js → events/rpc/serialize-typed-rpc-map.js} +3 -3
  91. package/dist/src/events/scheduler/pikku-command-scheduler.d.ts +2 -0
  92. package/dist/src/events/scheduler/pikku-command-scheduler.js +10 -0
  93. package/dist/src/inspector-glob.d.ts +1 -1
  94. package/dist/src/inspector-glob.js +4 -4
  95. package/dist/src/pikku-cli-config.d.ts +12 -2
  96. package/dist/src/pikku-cli-config.js +79 -30
  97. package/dist/src/pikku-command-schemas.d.ts +2 -0
  98. package/dist/src/pikku-command-schemas.js +8 -0
  99. package/dist/src/runtimes/nextjs/pikku-command-nextjs.d.ts +2 -0
  100. package/dist/src/runtimes/nextjs/pikku-command-nextjs.js +36 -0
  101. package/dist/src/schema-generator.d.ts +3 -2
  102. package/dist/src/schema-generator.js +9 -9
  103. package/dist/src/schemas.d.ts +2 -0
  104. package/dist/src/schemas.js +8 -0
  105. package/dist/src/{utils/serialize-import-map.js → serialize-import-map.js} +3 -0
  106. package/dist/src/serialize-pikku-types.js +378 -1
  107. package/dist/src/types.d.ts +5 -0
  108. package/dist/src/types.js +1 -0
  109. package/dist/src/{utils/utils.d.ts → utils.d.ts} +20 -7
  110. package/dist/src/{utils/utils.js → utils.js} +56 -32
  111. package/dist/tsconfig.tsbuildinfo +1 -1
  112. package/package.json +3 -3
  113. package/{bin → src/events/channels}/pikku-channels.ts +8 -3
  114. package/src/events/channels/pikku-command-channels-map.ts +26 -0
  115. package/src/events/channels/pikku-command-channels.ts +38 -0
  116. package/src/events/channels/pikku-command-websocket-typed.ts +36 -0
  117. package/src/{serialize-typed-channel-map.ts → events/channels/serialize-typed-channel-map.ts} +2 -2
  118. package/src/events/fetch/index.ts +33 -0
  119. package/src/events/functions/pikku-command-function-types.ts +48 -0
  120. package/src/events/functions/pikku-command-functions.ts +84 -0
  121. package/src/events/functions/pikku-command-services.ts +125 -0
  122. package/{bin → src/events/functions}/pikku-function-types.ts +12 -15
  123. package/{bin → src/events/functions}/pikku-functions.ts +9 -6
  124. package/src/events/http/pikku-command-http-map.ts +27 -0
  125. package/src/events/http/pikku-command-http-routes.ts +40 -0
  126. package/src/events/http/pikku-command-openapi.ts +54 -0
  127. package/{bin → src/events/http}/pikku-http-routes.ts +8 -3
  128. package/src/{serialize-typed-http-map.ts → events/http/serialize-typed-http-map.ts} +2 -19
  129. package/src/events/mcp/pikku-command-mcp-json.ts +33 -0
  130. package/src/events/mcp/pikku-command-mcp.ts +110 -0
  131. package/src/events/mcp/serialize-mcp-json.ts +159 -0
  132. package/src/events/queue/pikku-command-queue-map.ts +26 -0
  133. package/src/events/queue/pikku-command-queue-service.ts +33 -0
  134. package/src/events/queue/pikku-command-queue.ts +42 -0
  135. package/src/events/queue/pikku-queue-map.ts +26 -0
  136. package/src/events/queue/pikku-queue.ts +40 -0
  137. package/src/events/queue/serialize-queue-map.ts +119 -0
  138. package/src/events/queue/serialize-queue-meta.ts +10 -0
  139. package/src/events/queue/serialize-queue-wrapper.ts +35 -0
  140. package/src/events/rpc/pikku-command-rpc-client.ts +33 -0
  141. package/src/events/rpc/pikku-command-rpc-map.ts +26 -0
  142. package/src/events/rpc/pikku-command-rpc.ts +22 -0
  143. package/{bin → src/events/rpc}/pikku-rpc.ts +8 -6
  144. package/src/events/rpc/serialize-rpc-wrapper.ts +29 -0
  145. package/src/{serialize-typed-rpc-map.ts → events/rpc/serialize-typed-rpc-map.ts} +5 -4
  146. package/{bin/pikku-scheduler.ts → src/events/scheduler/pikku-command-scheduler.ts} +11 -8
  147. package/src/inspector-glob.ts +4 -2
  148. package/src/pikku-cli-config.ts +119 -42
  149. package/src/pikku-command-schemas.ts +33 -0
  150. package/src/runtimes/nextjs/pikku-command-nextjs.ts +110 -0
  151. package/src/schema-generator.ts +10 -5
  152. package/src/schemas.ts +33 -0
  153. package/src/{utils/serialize-import-map.ts → serialize-import-map.ts} +5 -0
  154. package/src/serialize-pikku-types.ts +378 -1
  155. package/src/types.ts +16 -0
  156. package/src/{utils/utils.ts → utils.ts} +68 -34
  157. package/tsconfig.json +1 -1
  158. package/bin/pikku-channels-map.ts +0 -25
  159. package/bin/pikku-http-map.ts +0 -26
  160. package/bin/pikku-nextjs.test.ts +0 -279
  161. package/bin/pikku-rpc-map.ts +0 -25
  162. package/dist/bin/pikku-channels-map.d.ts +0 -3
  163. package/dist/bin/pikku-channels-map.js +0 -8
  164. package/dist/bin/pikku-channels.d.ts +0 -3
  165. package/dist/bin/pikku-channels.js +0 -9
  166. package/dist/bin/pikku-function-types.d.ts +0 -4
  167. package/dist/bin/pikku-functions.d.ts +0 -7
  168. package/dist/bin/pikku-http-map.d.ts +0 -3
  169. package/dist/bin/pikku-http-map.js +0 -8
  170. package/dist/bin/pikku-http-routes.d.ts +0 -3
  171. package/dist/bin/pikku-http-routes.js +0 -9
  172. package/dist/bin/pikku-rpc-map.d.ts +0 -3
  173. package/dist/bin/pikku-rpc-map.js +0 -8
  174. package/dist/bin/pikku-rpc.d.ts +0 -3
  175. package/dist/bin/pikku-rpc.js +0 -6
  176. package/dist/bin/pikku-scheduler.d.ts +0 -3
  177. package/dist/bin/pikku-scheduler.js +0 -10
  178. /package/dist/src/{serialize-typed-channel-map.d.ts → events/channels/serialize-typed-channel-map.d.ts} +0 -0
  179. /package/dist/src/{serialize-websocket-wrapper.d.ts → events/channels/serialize-websocket-wrapper.d.ts} +0 -0
  180. /package/dist/src/{serialize-websocket-wrapper.js → events/channels/serialize-websocket-wrapper.js} +0 -0
  181. /package/dist/src/{openapi-spec-generator.d.ts → events/http/openapi-spec-generator.d.ts} +0 -0
  182. /package/dist/src/{openapi-spec-generator.js → events/http/openapi-spec-generator.js} +0 -0
  183. /package/dist/src/{serialize-fetch-wrapper.d.ts → events/http/serialize-fetch-wrapper.d.ts} +0 -0
  184. /package/dist/src/{serialize-fetch-wrapper.js → events/http/serialize-fetch-wrapper.js} +0 -0
  185. /package/dist/src/{serialize-scheduler-meta.d.ts → events/scheduler/serialize-scheduler-meta.d.ts} +0 -0
  186. /package/dist/src/{serialize-scheduler-meta.js → events/scheduler/serialize-scheduler-meta.js} +0 -0
  187. /package/dist/src/{serialize-nextjs-backend-wrapper.d.ts → runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts} +0 -0
  188. /package/dist/src/{serialize-nextjs-backend-wrapper.js → runtimes/nextjs/serialize-nextjs-backend-wrapper.js} +0 -0
  189. /package/dist/src/{serialize-nextjs-http-wrapper.d.ts → runtimes/nextjs/serialize-nextjs-http-wrapper.d.ts} +0 -0
  190. /package/dist/src/{serialize-nextjs-http-wrapper.js → runtimes/nextjs/serialize-nextjs-http-wrapper.js} +0 -0
  191. /package/dist/src/{utils/serialize-import-map.d.ts → serialize-import-map.d.ts} +0 -0
  192. /package/src/{serialize-websocket-wrapper.ts → events/channels/serialize-websocket-wrapper.ts} +0 -0
  193. /package/src/{openapi-spec-generator.ts → events/http/openapi-spec-generator.ts} +0 -0
  194. /package/src/{serialize-fetch-wrapper.ts → events/http/serialize-fetch-wrapper.ts} +0 -0
  195. /package/src/{serialize-scheduler-meta.ts → events/scheduler/serialize-scheduler-meta.ts} +0 -0
  196. /package/src/{serialize-nextjs-backend-wrapper.ts → runtimes/nextjs/serialize-nextjs-backend-wrapper.ts} +0 -0
  197. /package/src/{serialize-nextjs-http-wrapper.ts → runtimes/nextjs/serialize-nextjs-http-wrapper.ts} +0 -0
@@ -0,0 +1,12 @@
1
+ import { serializeFetchWrapper } from '../http/serialize-fetch-wrapper.js';
2
+ import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
3
+ export const pikkuFetch = async (logger, { fetchFile, httpRoutesMapDeclarationFile, packageMappings }) => {
4
+ return await logCommandInfoAndTime(logger, 'Generating fetch wrapper', 'Generated fetch wrapper', [fetchFile === undefined, "fetchFile isn't set in the pikku config"], async () => {
5
+ if (!fetchFile) {
6
+ throw new Error("fetchFile is isn't set in the pikku config");
7
+ }
8
+ const routesMapDeclarationPath = getFileImportRelativePath(fetchFile, httpRoutesMapDeclarationFile, packageMappings);
9
+ const content = [serializeFetchWrapper(routesMapDeclarationPath)];
10
+ await writeFileInDir(logger, fetchFile, content.join('\n'));
11
+ });
12
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuFunctionTypes: PikkuCommand;
@@ -0,0 +1,13 @@
1
+ import { getFileImportRelativePath, getPikkuFilesAndMethods, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
2
+ import { serializePikkuTypes } from '../../serialize-pikku-types.js';
3
+ export const pikkuFunctionTypes = async (logger, { typesDeclarationFile: typesFile, packageMappings, rpcMapDeclarationFile }, visitState, options = {}) => {
4
+ return await logCommandInfoAndTime(logger, 'Creating api types', 'Created api types', [false], async () => {
5
+ const { userSessionType, sessionServicesType, singletonServicesType } = await getPikkuFilesAndMethods(logger, visitState, packageMappings, typesFile, options, {
6
+ userSessionType: true,
7
+ sessionServiceType: true,
8
+ singletonServicesType: true,
9
+ });
10
+ const content = serializePikkuTypes(`import type { ${userSessionType.type} } from '${getFileImportRelativePath(typesFile, userSessionType.typePath, packageMappings)}'`, userSessionType.type, `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(typesFile, singletonServicesType.typePath, packageMappings)}'`, singletonServicesType.type, `import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(typesFile, sessionServicesType.typePath, packageMappings)}'`, `import type { TypedPikkuRPC } from '${getFileImportRelativePath(typesFile, rpcMapDeclarationFile, packageMappings)}'`);
11
+ await writeFileInDir(logger, typesFile, content);
12
+ });
13
+ };
@@ -0,0 +1,6 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const serializeFunctionImports: (outputPath: string, functionsMap: Map<string, {
3
+ path: string;
4
+ exportedName: string;
5
+ }>, packageMappings?: Record<string, string>) => string;
6
+ export declare const pikkuFunctions: PikkuCommand;
@@ -0,0 +1,35 @@
1
+ import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
2
+ export const serializeFunctionImports = (outputPath, functionsMap, packageMappings = {}) => {
3
+ const serializedImports = [
4
+ `/* Import and register RPCs */`,
5
+ `import { addFunction } from '@pikku/core'`,
6
+ ];
7
+ const serializedRegistrations = [];
8
+ // Sort by function name for consistent output
9
+ const sortedEntries = Array.from(functionsMap.entries()).sort((a, b) => a[0].localeCompare(b[0]));
10
+ for (const [name, { path, exportedName }] of sortedEntries) {
11
+ const filePath = getFileImportRelativePath(outputPath, path, packageMappings);
12
+ // For directly exported functions, we can just import and register them
13
+ if (name === exportedName) {
14
+ serializedImports.push(`import { ${exportedName} } from '${filePath}'`);
15
+ serializedRegistrations.push(`addFunction('${name}', { func: ${exportedName} })`);
16
+ }
17
+ // For renamed functions, we need to import and alias them
18
+ else {
19
+ serializedImports.push(`import { ${exportedName} as ${name} } from '${filePath}'`);
20
+ serializedRegistrations.push(`addFunction('${name}', ${name})`);
21
+ }
22
+ }
23
+ // Add a blank line between imports and registrations
24
+ if (serializedImports.length > 0 && serializedRegistrations.length > 0) {
25
+ serializedImports.push('');
26
+ }
27
+ // Combine the imports and registrations
28
+ return [...serializedImports, ...serializedRegistrations].join('\n');
29
+ };
30
+ export const pikkuFunctions = async (logger, { functionsMetaFile, functionsFile, packageMappings }, { functions }) => {
31
+ return await logCommandInfoAndTime(logger, 'Serializing Pikku functions', 'Serialized Pikku functions', [false], async () => {
32
+ await writeFileInDir(logger, functionsFile, serializeFunctionImports(functionsFile, functions.files, packageMappings));
33
+ await writeFileInDir(logger, functionsMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(functions.meta, null, 2)})`);
34
+ });
35
+ };
@@ -0,0 +1,3 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const serializeServicesMap: (functionsMetaData: Record<string, any>, middlewareServices: string[] | undefined, servicesImport: string, sessionServicesImport: string) => string;
3
+ export declare const pikkuServices: PikkuCommand;
@@ -0,0 +1,73 @@
1
+ import { getFileImportRelativePath, getPikkuFilesAndMethods, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
2
+ export const serializeServicesMap = (functionsMetaData, middlewareServices = [], servicesImport, sessionServicesImport) => {
3
+ // Extract all unique services from all functions
4
+ const usedServices = new Set();
5
+ // Internal services that are created internally and not via the create service script
6
+ const internalServices = new Set(['rpc', 'mcp', 'channel', 'userSession']);
7
+ for (const funcMeta of Object.values(functionsMetaData)) {
8
+ if (funcMeta.services && Array.isArray(funcMeta.services.services)) {
9
+ funcMeta.services.services.forEach((service) => {
10
+ // Only include services that are not internal
11
+ if (!internalServices.has(service)) {
12
+ usedServices.add(service);
13
+ }
14
+ });
15
+ }
16
+ }
17
+ // Add middleware services that might not be detected from function inspection
18
+ middlewareServices.forEach((service) => {
19
+ if (!internalServices.has(service)) {
20
+ usedServices.add(service);
21
+ }
22
+ });
23
+ // Create a map of services with true for all needed services
24
+ const servicesMap = Object.fromEntries(Array.from(usedServices)
25
+ .sort()
26
+ .map((service) => [service, true]));
27
+ // Generate the TypeScript code
28
+ const serviceKeys = Object.keys(servicesMap).sort();
29
+ // Services that are always required internally by the framework
30
+ const defaultServices = ['config', 'logger', 'variables', 'schema'];
31
+ // Combine default services with detected services
32
+ const allRequiredServices = [
33
+ ...new Set([...defaultServices, ...serviceKeys]),
34
+ ].sort();
35
+ // For RequiredSingletonServices, we need to pick from the actual SingletonServices interface
36
+ // This will be resolved at compile time based on what's actually in the SingletonServices interface
37
+ // We don't need to hardcode which services are singletons beyond the core framework ones
38
+ const code = [
39
+ '/**',
40
+ ' * This file was generated by the @pikku/cli',
41
+ ' */',
42
+ '',
43
+ servicesImport,
44
+ sessionServicesImport,
45
+ "import type { PikkuInteraction } from '@pikku/core'",
46
+ '',
47
+ 'export const singletonServices = {',
48
+ ...Object.keys(servicesMap).map((service) => ` '${service}': true,`),
49
+ '} as const',
50
+ '',
51
+ '// Singleton services (created once at startup)',
52
+ '// Only includes services that are both required and available in SingletonServices',
53
+ `export type RequiredSingletonServices = Pick<SingletonServices, Extract<keyof SingletonServices, ${allRequiredServices.map((key) => `'${key}'`).join(' | ')}>> & Partial<Omit<SingletonServices, ${allRequiredServices.map((key) => `'${key}'`).join(' | ')}>>`,
54
+ '',
55
+ '// Session services (created per request, can access singleton services)',
56
+ '// Omits singleton services and PikkuInteraction (mcp, rpc, http, channel)',
57
+ `export type RequiredSessionServices = Omit<Services, keyof SingletonServices | keyof PikkuInteraction>`,
58
+ '',
59
+ ].join('\n');
60
+ return code;
61
+ };
62
+ export const pikkuServices = async (logger, cliConfig, visitState) => {
63
+ return await logCommandInfoAndTime(logger, 'Generating Pikku services map', 'Generated Pikku services map', [visitState.functions.files.size === 0], async () => {
64
+ const { sessionServicesType, singletonServicesType } = await getPikkuFilesAndMethods(logger, visitState, cliConfig.packageMappings, cliConfig.typesDeclarationFile, {}, {
65
+ sessionServiceType: true,
66
+ singletonServicesType: true,
67
+ });
68
+ const servicesImport = `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(cliConfig.typesDeclarationFile, singletonServicesType.typePath, cliConfig.packageMappings)}'`;
69
+ const sessionServicesImport = `import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(cliConfig.typesDeclarationFile, sessionServicesType.typePath, cliConfig.packageMappings)}'`;
70
+ const servicesCode = serializeServicesMap(visitState.functions.meta, cliConfig.middlewareServices, servicesImport, sessionServicesImport);
71
+ await writeFileInDir(logger, cliConfig.servicesFile, servicesCode);
72
+ });
73
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuFunctionTypes: PikkuCommand;
@@ -1,13 +1,13 @@
1
- import { getFileImportRelativePath, getPikkuFilesAndMethods, logCommandInfoAndTime, writeFileInDir, } from '../src/utils/utils.js';
2
- import { serializePikkuTypes } from '../src/serialize-pikku-types.js';
3
- export const pikkuFunctionTypes = async ({ typesDeclarationFile: typesFile, packageMappings, rpcMapDeclarationFile, }, options, visitState) => {
4
- await logCommandInfoAndTime('Creating api types', 'Created api types', [false], async () => {
5
- const { userSessionType, sessionServicesType, singletonServicesType } = await getPikkuFilesAndMethods(visitState, packageMappings, typesFile, options, {
1
+ import { getFileImportRelativePath, getPikkuFilesAndMethods, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
2
+ import { serializePikkuTypes } from '../../serialize-pikku-types.js';
3
+ export const pikkuFunctionTypes = async (logger, { typesDeclarationFile: typesFile, packageMappings, rpcMapDeclarationFile }, visitState, options = {}) => {
4
+ return await logCommandInfoAndTime(logger, 'Creating api types', 'Created api types', [false], async () => {
5
+ const { userSessionType, sessionServicesType, singletonServicesType } = await getPikkuFilesAndMethods(logger, visitState, packageMappings, typesFile, options, {
6
6
  userSessionType: true,
7
7
  sessionServiceType: true,
8
8
  singletonServicesType: true,
9
9
  });
10
10
  const content = serializePikkuTypes(`import type { ${userSessionType.type} } from '${getFileImportRelativePath(typesFile, userSessionType.typePath, packageMappings)}'`, userSessionType.type, `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(typesFile, singletonServicesType.typePath, packageMappings)}'`, singletonServicesType.type, `import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(typesFile, sessionServicesType.typePath, packageMappings)}'`, `import type { TypedPikkuRPC } from '${getFileImportRelativePath(typesFile, rpcMapDeclarationFile, packageMappings)}'`);
11
- await writeFileInDir(typesFile, content);
11
+ await writeFileInDir(logger, typesFile, content);
12
12
  });
13
13
  };
@@ -0,0 +1,6 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const serializeFunctionImports: (outputPath: string, functionsMap: Map<string, {
3
+ path: string;
4
+ exportedName: string;
5
+ }>, packageMappings?: Record<string, string>) => string;
6
+ export declare const pikkuFunctions: PikkuCommand;
@@ -1,4 +1,4 @@
1
- import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../src/utils/utils.js';
1
+ import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
2
2
  export const serializeFunctionImports = (outputPath, functionsMap, packageMappings = {}) => {
3
3
  const serializedImports = [
4
4
  `/* Import and register RPCs */`,
@@ -27,9 +27,9 @@ export const serializeFunctionImports = (outputPath, functionsMap, packageMappin
27
27
  // Combine the imports and registrations
28
28
  return [...serializedImports, ...serializedRegistrations].join('\n');
29
29
  };
30
- export const pikkuFunctions = async ({ functionsMetaFile, functionsFile, packageMappings }, { functions }) => {
31
- return await logCommandInfoAndTime('Serializing Pikku functions', 'Serialized Pikku functions', [false], async () => {
32
- await writeFileInDir(functionsFile, serializeFunctionImports(functionsFile, functions.files, packageMappings));
33
- await writeFileInDir(functionsMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(functions.meta, null, 2)})`);
30
+ export const pikkuFunctions = async (logger, { functionsMetaFile, functionsFile, packageMappings }, { functions }) => {
31
+ return await logCommandInfoAndTime(logger, 'Serializing Pikku functions', 'Serialized Pikku functions', [false], async () => {
32
+ await writeFileInDir(logger, functionsFile, serializeFunctionImports(functionsFile, functions.files, packageMappings));
33
+ await writeFileInDir(logger, functionsMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(functions.meta, null, 2)})`);
34
34
  });
35
35
  };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuHTTPMap: PikkuCommand;
@@ -0,0 +1,8 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuHTTP: PikkuCommand;
@@ -0,0 +1,9 @@
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 { httpRoutesFile, httpRoutesMetaFile, packageMappings } = cliConfig;
5
+ const { http } = visitState;
6
+ await writeFileInDir(logger, httpRoutesFile, serializeFileImports('addHTTPRoute', httpRoutesFile, http.files, packageMappings));
7
+ await writeFileInDir(logger, httpRoutesMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`);
8
+ });
9
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuOpenAPI: PikkuCommand;
@@ -0,0 +1,20 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuHTTP: PikkuCommand;
@@ -0,0 +1,9 @@
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 { httpRoutesFile, httpRoutesMetaFile, packageMappings } = cliConfig;
5
+ const { http } = visitState;
6
+ await writeFileInDir(logger, httpRoutesFile, serializeFileImports('addHTTPRoute', httpRoutesFile, http.files, packageMappings));
7
+ await writeFileInDir(logger, httpRoutesMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`);
8
+ });
9
+ };
@@ -2,4 +2,3 @@ import { HTTPRoutesMeta } from '@pikku/core/http';
2
2
  import { MetaInputTypes, TypesMap } from '@pikku/inspector';
3
3
  import { FunctionsMeta } from '@pikku/core';
4
4
  export declare const serializeTypedRoutesMap: (relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, functionsMeta: FunctionsMeta, routesMeta: HTTPRoutesMeta, metaTypes: MetaInputTypes) => string;
5
- export declare function generateCustomTypes(typesMap: TypesMap, requiredTypes: Set<string>): string;
@@ -1,4 +1,5 @@
1
- import { serializeImportMap } from './utils/serialize-import-map.js';
1
+ import { serializeImportMap } from '../../serialize-import-map.js';
2
+ import { generateCustomTypes } from '../../utils.js';
2
3
  export const serializeTypedRoutesMap = (relativeToPath, packageMappings, typesMap, functionsMeta, routesMeta, metaTypes) => {
3
4
  const requiredTypes = new Set();
4
5
  const serializedCustomTypes = generateCustomTypes(typesMap, requiredTypes);
@@ -30,20 +31,6 @@ export type RoutesWithMethod<Method extends string> = {
30
31
  }[keyof RoutesMap];
31
32
  `;
32
33
  };
33
- export function generateCustomTypes(typesMap, requiredTypes) {
34
- return `
35
- // Custom types are those that are defined directly within generics
36
- // or are broken into simpler types
37
- ${Array.from(typesMap.customTypes.entries())
38
- .map(([name, { type, references }]) => {
39
- references.forEach((name) => {
40
- const originalName = typesMap.getTypeMeta(name).originalName;
41
- requiredTypes.add(originalName);
42
- });
43
- return `export type ${name} = ${type}`;
44
- })
45
- .join('\n')}`;
46
- }
47
34
  function generateRoutes(routesMeta, functionsMeta, typesMap, requiredTypes) {
48
35
  // Initialize an object to collect routes
49
36
  const routesObj = {};
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuMCPJSON: PikkuCommand;
@@ -0,0 +1,13 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuMCP: PikkuCommand;
@@ -0,0 +1,54 @@
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, { mcpEndpointsFile, mcpEndpointsMetaFile, packageMappings, schemaDirectory }, { mcpEndpoints, functions }) => {
38
+ return await logCommandInfoAndTime(logger, 'Finding MCP endpoints', 'Found MCP endpoints', [mcpEndpoints.files.size === 0], async () => {
39
+ await writeFileInDir(logger, mcpEndpointsFile, serializeFileImports('addMCPResource or addMCPTool', mcpEndpointsFile, 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, mcpEndpointsMetaFile, `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
+ };
@@ -0,0 +1,5 @@
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>;
@@ -0,0 +1,101 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuQueueMap: PikkuCommand;
@@ -0,0 +1,8 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommandWithoutState } from '../../types.js';
2
+ export declare const pikkuQueueService: PikkuCommandWithoutState;
@@ -0,0 +1,12 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuQueue: PikkuCommand;
@@ -0,0 +1,10 @@
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 { queueWorkersFile, queueWorkersMetaFile, packageMappings } = cliConfig;
6
+ const { queueWorkers } = visitState;
7
+ await writeFileInDir(logger, queueWorkersMetaFile, serializeQueueMeta(queueWorkers.meta));
8
+ await writeFileInDir(logger, queueWorkersFile, serializeFileImports('addQueueWorkers', queueWorkersFile, queueWorkers.files, packageMappings));
9
+ });
10
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuQueueMap: PikkuCommand;
@@ -0,0 +1,8 @@
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
+ };
@@ -0,0 +1,2 @@
1
+ import { PikkuCommand } from '../../types.js';
2
+ export declare const pikkuQueue: PikkuCommand;
@@ -0,0 +1,10 @@
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 { queueWorkersFile, queueWorkersMetaFile, packageMappings } = cliConfig;
6
+ const { queueWorkers } = visitState;
7
+ await writeFileInDir(logger, queueWorkersMetaFile, serializeQueueMeta(queueWorkers.meta));
8
+ await writeFileInDir(logger, queueWorkersFile, serializeFileImports('addQueueWorkers', queueWorkersFile, queueWorkers.files, packageMappings));
9
+ });
10
+ };
@@ -0,0 +1,4 @@
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;